mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-30631: Fixed the default grade import for the question for both CC
1.0 and 1.1
This commit is contained in:
parent
f89a83b87b
commit
986dc51a72
@ -208,9 +208,8 @@ class entities {
|
||||
if (!empty($files)) {
|
||||
|
||||
foreach ($files as $file) {
|
||||
|
||||
$source = cc2moodle::$path_to_manifest_folder . DIRECTORY_SEPARATOR . $file->nodeValue;
|
||||
$destination = $destination_folder . DIRECTORY_SEPARATOR . $file->nodeValue;
|
||||
$source = cc2moodle::$path_to_manifest_folder . DIRECTORY_SEPARATOR . $file;
|
||||
$destination = $destination_folder . DIRECTORY_SEPARATOR . $file;
|
||||
|
||||
$destination_directory = dirname($destination);
|
||||
|
||||
@ -251,10 +250,9 @@ class entities {
|
||||
if (in_array($ext, array('html', 'htm', 'xhtml'))) {
|
||||
continue;
|
||||
}
|
||||
$all_files[] = $file;
|
||||
$all_files[] = $file->nodeValue;
|
||||
}
|
||||
}
|
||||
|
||||
unset($files);
|
||||
}
|
||||
|
||||
@ -264,8 +262,8 @@ class entities {
|
||||
if (!empty($labels) && ($labels->length > 0)) {
|
||||
$tname = 'course_files';
|
||||
$dpath = cc2moodle::$path_to_manifest_folder . DIRECTORY_SEPARATOR . $tname;
|
||||
$fpath = $dpath . DIRECTORY_SEPARATOR . 'folder.gif';
|
||||
$rfpath = $tname.'/folder.gif';
|
||||
$rfpath = 'folder.gif';
|
||||
$fpath = $dpath . DIRECTORY_SEPARATOR . $rfpath;
|
||||
|
||||
if (!file_exists($dpath)) {
|
||||
mkdir($dpath);
|
||||
|
@ -51,7 +51,7 @@ class entities11 extends entities {
|
||||
if (in_array($ext, array('html', 'htm', 'xhtml'))) {
|
||||
continue;
|
||||
}
|
||||
$all_files[] = $file;
|
||||
$all_files[] = $file->nodeValue;
|
||||
}
|
||||
unset($files);
|
||||
}
|
||||
@ -62,8 +62,8 @@ class entities11 extends entities {
|
||||
if (!empty($labels) && ($labels->length > 0)) {
|
||||
$tname = 'course_files';
|
||||
$dpath = cc2moodle::$path_to_manifest_folder . DIRECTORY_SEPARATOR . $tname;
|
||||
$rfpath = 'folder.gif';
|
||||
$fpath = $dpath . DIRECTORY_SEPARATOR . 'folder.gif';
|
||||
$rfpath = $tname.'/folder.gif';
|
||||
if (!file_exists($dpath)) {
|
||||
mkdir($dpath);
|
||||
}
|
||||
|
@ -276,6 +276,7 @@ class cc_quiz extends entities {
|
||||
'[#question_text#]',
|
||||
'[#question_type#]',
|
||||
'[#question_general_feedback#]',
|
||||
'[#question_defaultgrade#]',
|
||||
'[#date_now#]',
|
||||
'[#question_type_nodes#]',
|
||||
'[#question_stamp#]',
|
||||
@ -308,6 +309,7 @@ class cc_quiz extends entities {
|
||||
self::safexml($question['title']),
|
||||
$question_moodle_type,
|
||||
self::safexml($question['feedback']),
|
||||
$question['defaultgrade'], //default grade
|
||||
time(),
|
||||
$question_type_node,
|
||||
$quiz_stamp,
|
||||
@ -368,6 +370,7 @@ class cc_quiz extends entities {
|
||||
$questions[$question_identifier]['moodle_type'] = $question_type['moodle'];
|
||||
$questions[$question_identifier]['cc_type'] = $question_type['cc'];
|
||||
$questions[$question_identifier]['feedback'] = $this->get_general_feedback($assessment, $question_identifier);
|
||||
$questions[$question_identifier]['defaultgrade'] = $this->get_defaultgrade($assessment, $question_identifier);
|
||||
$questions[$question_identifier]['answers'] = $this->get_answers($question_identifier, $assessment, $last_answer_id);
|
||||
|
||||
}
|
||||
@ -395,6 +398,21 @@ class cc_quiz extends entities {
|
||||
}
|
||||
}
|
||||
|
||||
private function get_defaultgrade($assessment, $question_identifier) {
|
||||
$result = 1;
|
||||
$xpath = cc2moodle::newx_path($assessment, cc2moodle::getquizns());
|
||||
$query = '//xmlns:item[@ident="' . $question_identifier . '"]';
|
||||
$query .= '//xmlns:qtimetadatafield[xmlns:fieldlabel="cc_weighting"]/xmlns:fieldentry';
|
||||
$defgrade = $xpath->query($query);
|
||||
if (!empty($defgrade) && ($defgrade->length > 0)) {
|
||||
$resp = (int)$defgrade->item(0)->nodeValue;
|
||||
if ($resp >= 0 && $resp <= 99) {
|
||||
$result = $resp;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function get_general_feedback ($assessment, $question_identifier) {
|
||||
|
||||
$xpath = cc2moodle::newx_path($assessment, cc2moodle::getquizns());
|
||||
|
@ -276,6 +276,7 @@ class cc11_quiz extends entities11 {
|
||||
'[#question_text#]',
|
||||
'[#question_type#]',
|
||||
'[#question_general_feedback#]',
|
||||
'[#question_defaultgrade#]',
|
||||
'[#date_now#]',
|
||||
'[#question_type_nodes#]',
|
||||
'[#question_stamp#]',
|
||||
@ -308,6 +309,7 @@ class cc11_quiz extends entities11 {
|
||||
self::safexml($question['title']),
|
||||
$question_moodle_type,
|
||||
self::safexml($question['feedback']),
|
||||
$question['defaultgrade'],
|
||||
time(),
|
||||
$question_type_node,
|
||||
$quiz_stamp,
|
||||
@ -368,6 +370,7 @@ class cc11_quiz extends entities11 {
|
||||
$questions[$question_identifier]['moodle_type'] = $question_type['moodle'];
|
||||
$questions[$question_identifier]['cc_type'] = $question_type['cc'];
|
||||
$questions[$question_identifier]['feedback'] = $this->get_general_feedback($assessment, $question_identifier);
|
||||
$questions[$question_identifier]['defaultgrade'] = $this->get_defaultgrade($assessment, $question_identifier);
|
||||
$questions[$question_identifier]['answers'] = $this->get_answers($question_identifier, $assessment, $last_answer_id);
|
||||
|
||||
}
|
||||
@ -395,6 +398,21 @@ class cc11_quiz extends entities11 {
|
||||
}
|
||||
}
|
||||
|
||||
private function get_defaultgrade($assessment, $question_identifier) {
|
||||
$result = 1;
|
||||
$xpath = cc2moodle::newx_path($assessment, cc2moodle::getquizns());
|
||||
$query = '//xmlns:item[@ident="' . $question_identifier . '"]';
|
||||
$query .= '//xmlns:qtimetadatafield[xmlns:fieldlabel="cc_weighting"]/xmlns:fieldentry';
|
||||
$defgrade = $xpath->query($query);
|
||||
if (!empty($defgrade) && ($defgrade->length > 0)) {
|
||||
$resp = (int)$defgrade->item(0)->nodeValue;
|
||||
if ($resp >= 0 && $resp <= 99) {
|
||||
$result = $resp;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function get_general_feedback ($assessment, $question_identifier) {
|
||||
|
||||
$xpath = cc112moodle::newx_path($assessment, cc112moodle::getquizns());
|
||||
|
@ -6,7 +6,7 @@
|
||||
<QUESTIONTEXTFORMAT>1</QUESTIONTEXTFORMAT>
|
||||
<IMAGE></IMAGE>
|
||||
<GENERALFEEDBACK>[#question_general_feedback#]</GENERALFEEDBACK>
|
||||
<DEFAULTGRADE>1</DEFAULTGRADE>
|
||||
<DEFAULTGRADE>[#question_defaultgrade#]</DEFAULTGRADE>
|
||||
<PENALTY>0</PENALTY>
|
||||
<QTYPE>[#question_type#]</QTYPE>
|
||||
<LENGTH>1</LENGTH>
|
||||
|
Loading…
x
Reference in New Issue
Block a user