Permalink
Browse files

for JCloze import, defaultgrade (per gap)= 1, and defaultgrade (per e…

…xercise) = number of gaps
  • Loading branch information...
1 parent aa35bd0 commit 14b348d17809b87c203acfcc276584657ce7833e gbateson committed Dec 31, 2005
Showing with 9 additions and 5 deletions.
  1. +9 −5 mod/quiz/format/hotpot/format.php
@@ -64,8 +64,10 @@ function readquestions ($lines) {
} // end class
function process_jcloze(&$xml, &$questions) {
+ // define default grade (per cloze gap)
+ $defaultgrade = 1;
- // sniff early Moodles
+ // detect old Moodles (1.4 and earlier)
global $CFG, $db;
$moodle_14 = false;
if ($columns = $db->MetaColumns("{$CFG->prefix}quiz_multianswers")) {
@@ -83,7 +85,6 @@ function process_jcloze(&$xml, &$questions) {
$question = new stdClass();
$question->qtype = MULTIANSWER;
- $question->defaultgrade = 1;
$question->usecase = 0; // Ignore case
$question->image = ""; // No images with this format
@@ -112,13 +113,13 @@ function process_jcloze(&$xml, &$questions) {
if ($moodle_14) {
$question->answers[$q]->positionkey = $positionkey;
$question->answers[$q]->answertype = SHORTANSWER;
- $question->answers[$q]->norm = 1;
+ $question->answers[$q]->norm = $defaultgrade;
$question->answers[$q]->alternatives = array();
} else {
$wrapped = new stdClass();
$wrapped->qtype = SHORTANSWER;
$wrapped->usecase = 0;
- $wrapped->defaultgrade = 1;
+ $wrapped->defaultgrade = $defaultgrade;
$wrapped->questiontextformat = 0;
$wrapped->answer = array();
$wrapped->fraction = array();
@@ -150,14 +151,17 @@ function process_jcloze(&$xml, &$questions) {
if ($moodle_14) {
// do nothing
} else {
- $wrapped->questiontext = '{:SHORTANSWER:'.implode('~', $answers).'}';
+ $wrapped->questiontext = '{'.$defaultgrade.':SHORTANSWER:'.implode('~', $answers).'}';
$question->options->questions[] = $wrapped;
}
$q++;
}
+ // add trailing text, if any
if (isset($exercise[$q])) {
$question->questiontext .= addslashes($exercise[$q]);
}
+ // define total grade for this exercise
+ $question->defaultgrade = $q * $defaultgrade;
$questions[] = $question;
$x++;

0 comments on commit 14b348d

Please sign in to comment.