Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…xercise) = number of gaps
  • Loading branch information...
commit 14b348d17809b87c203acfcc276584657ce7833e 1 parent aa35bd0
gbateson authored

Showing 1 changed file with 9 additions and 5 deletions. Show diff stats Hide diff stats

  1. +9 5 mod/quiz/format/hotpot/format.php
14 mod/quiz/format/hotpot/format.php
@@ -64,8 +64,10 @@ function readquestions ($lines) {
64 64 } // end class
65 65
66 66 function process_jcloze(&$xml, &$questions) {
  67 + // define default grade (per cloze gap)
  68 + $defaultgrade = 1;
67 69
68   - // sniff early Moodles
  70 + // detect old Moodles (1.4 and earlier)
69 71 global $CFG, $db;
70 72 $moodle_14 = false;
71 73 if ($columns = $db->MetaColumns("{$CFG->prefix}quiz_multianswers")) {
@@ -83,7 +85,6 @@ function process_jcloze(&$xml, &$questions) {
83 85 $question = new stdClass();
84 86
85 87 $question->qtype = MULTIANSWER;
86   - $question->defaultgrade = 1;
87 88 $question->usecase = 0; // Ignore case
88 89 $question->image = ""; // No images with this format
89 90
@@ -112,13 +113,13 @@ function process_jcloze(&$xml, &$questions) {
112 113 if ($moodle_14) {
113 114 $question->answers[$q]->positionkey = $positionkey;
114 115 $question->answers[$q]->answertype = SHORTANSWER;
115   - $question->answers[$q]->norm = 1;
  116 + $question->answers[$q]->norm = $defaultgrade;
116 117 $question->answers[$q]->alternatives = array();
117 118 } else {
118 119 $wrapped = new stdClass();
119 120 $wrapped->qtype = SHORTANSWER;
120 121 $wrapped->usecase = 0;
121   - $wrapped->defaultgrade = 1;
  122 + $wrapped->defaultgrade = $defaultgrade;
122 123 $wrapped->questiontextformat = 0;
123 124 $wrapped->answer = array();
124 125 $wrapped->fraction = array();
@@ -150,14 +151,17 @@ function process_jcloze(&$xml, &$questions) {
150 151 if ($moodle_14) {
151 152 // do nothing
152 153 } else {
153   - $wrapped->questiontext = '{:SHORTANSWER:'.implode('~', $answers).'}';
  154 + $wrapped->questiontext = '{'.$defaultgrade.':SHORTANSWER:'.implode('~', $answers).'}';
154 155 $question->options->questions[] = $wrapped;
155 156 }
156 157 $q++;
157 158 }
  159 + // add trailing text, if any
158 160 if (isset($exercise[$q])) {
159 161 $question->questiontext .= addslashes($exercise[$q]);
160 162 }
  163 + // define total grade for this exercise
  164 + $question->defaultgrade = $q * $defaultgrade;
161 165
162 166 $questions[] = $question;
163 167 $x++;

0 comments on commit 14b348d

Please sign in to comment.
Something went wrong with that request. Please try again.