Browse files

MDL-30631: Fixed the default grade import for the question for both CC

1.0 and 1.1
  • Loading branch information...
1 parent f89a83b commit 986dc51a722e7a6ee60b93644b7da42ffb1df982 Darko Miletic committed Dec 15, 2011
View
12 backup/cc/entities.class.php
@@ -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);
@@ -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);
}
@@ -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);
View
4 backup/cc/entities11.class.php
@@ -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);
}
@@ -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);
}
View
18 backup/cc/entity.quiz.class.php
@@ -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#]',
@@ -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,
@@ -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);
}
@@ -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());
View
18 backup/cc/entity11.quiz.class.php
@@ -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#]',
@@ -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,
@@ -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);
}
@@ -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());
View
2 backup/cc/sheets/course_question_categories_question_category_question.xml
@@ -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>

0 comments on commit 986dc51

Please sign in to comment.