Skip to content

Commit

Permalink
for JCloze import, defaultgrade (per gap)= 1, and defaultgrade (per e…
Browse files Browse the repository at this point in the history
…xercise) = number of gaps
  • Loading branch information
gbateson committed Dec 31, 2005
1 parent aa35bd0 commit 14b348d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions mod/quiz/format/hotpot/format.php
Expand Up @@ -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")) {
Expand All @@ -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

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

0 comments on commit 14b348d

Please sign in to comment.