Skip to content

Commit

Permalink
MDL-30631: Fixed the default grade import for the question for both CC
Browse files Browse the repository at this point in the history
1.0 and 1.1
  • Loading branch information
Darko Miletic authored and stronk7 committed Dec 20, 2011
1 parent 72b01fb commit fe2a74d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 10 deletions.
12 changes: 5 additions & 7 deletions backup/cc/entities.class.php
Expand Up @@ -208,9 +208,8 @@ public function move_files ($files, $destination_folder) {
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);

Expand Down Expand Up @@ -251,10 +250,9 @@ protected function get_all_files () {
if (in_array($ext, array('html', 'htm', 'xhtml'))) {
continue;
}
$all_files[] = $file;
$all_files[] = $file->nodeValue;
}
}

unset($files);
}

Expand All @@ -264,8 +262,8 @@ protected function get_all_files () {
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);
Expand Down
4 changes: 2 additions & 2 deletions backup/cc/entities11.class.php
Expand Up @@ -51,7 +51,7 @@ protected function get_all_files () {
if (in_array($ext, array('html', 'htm', 'xhtml'))) {
continue;
}
$all_files[] = $file;
$all_files[] = $file->nodeValue;
}
unset($files);
}
Expand All @@ -62,8 +62,8 @@ protected function get_all_files () {
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);
}
Expand Down
18 changes: 18 additions & 0 deletions backup/cc/entity.quiz.class.php
Expand Up @@ -276,6 +276,7 @@ private function create_node_course_question_categories_question_category_questi
'[#question_text#]',
'[#question_type#]',
'[#question_general_feedback#]',
'[#question_defaultgrade#]',
'[#date_now#]',
'[#question_type_nodes#]',
'[#question_stamp#]',
Expand Down Expand Up @@ -308,6 +309,7 @@ private function create_node_course_question_categories_question_category_questi
self::safexml($question['title']),
$question_moodle_type,
self::safexml($question['feedback']),
$question['defaultgrade'], //default grade
time(),
$question_type_node,
$quiz_stamp,
Expand Down Expand Up @@ -368,6 +370,7 @@ private function get_questions ($assessment, &$last_question_id, &$last_answer_i
$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);

}
Expand Down Expand Up @@ -395,6 +398,21 @@ private function str_replace_once ($search, $replace, $subject) {
}
}

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());
Expand Down
18 changes: 18 additions & 0 deletions backup/cc/entity11.quiz.class.php
Expand Up @@ -276,6 +276,7 @@ private function create_node_course_question_categories_question_category_questi
'[#question_text#]',
'[#question_type#]',
'[#question_general_feedback#]',
'[#question_defaultgrade#]',
'[#date_now#]',
'[#question_type_nodes#]',
'[#question_stamp#]',
Expand Down Expand Up @@ -308,6 +309,7 @@ private function create_node_course_question_categories_question_category_questi
self::safexml($question['title']),
$question_moodle_type,
self::safexml($question['feedback']),
$question['defaultgrade'],
time(),
$question_type_node,
$quiz_stamp,
Expand Down Expand Up @@ -368,6 +370,7 @@ private function get_questions ($assessment, &$last_question_id, &$last_answer_i
$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);

}
Expand Down Expand Up @@ -395,6 +398,21 @@ private function str_replace_once ($search, $replace, $subject) {
}
}

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());
Expand Down
Expand Up @@ -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>
Expand Down

0 comments on commit fe2a74d

Please sign in to comment.