diff --git a/mod/hotpot/lang/en_utf8/help/hotpot/addquizchain.html b/mod/hotpot/lang/en_utf8/help/hotpot/addquizchain.html new file mode 100644 index 00000000000..dc77d6ef7e1 --- /dev/null +++ b/mod/hotpot/lang/en_utf8/help/hotpot/addquizchain.html @@ -0,0 +1,17 @@ +

Add quiz chain

+ +
+

+ No
+ Only one quiz will be added to the course +

+

+ Yes
+ If the "File name" is a file, it is treated as the start of a chain + of Hot Potatoes quizzes and all quizzes in the chain will be added to the course + with identical settings.
+
+ If the "File name" is a folder, all Hot Potatoes quizzes in the folder + will be added to the course as a chain of quizzes with identical settings. +

+
diff --git a/mod/hotpot/lang/en_utf8/help/hotpot/analysistable.html b/mod/hotpot/lang/en_utf8/help/hotpot/analysistable.html new file mode 100644 index 00000000000..d2a876f65da --- /dev/null +++ b/mod/hotpot/lang/en_utf8/help/hotpot/analysistable.html @@ -0,0 +1,8 @@ +

Item Response Analysis

+

This table lists the responses to each question and the frequency of each response.

+ diff --git a/mod/hotpot/lang/en_utf8/help/hotpot/clickreporting.html b/mod/hotpot/lang/en_utf8/help/hotpot/clickreporting.html new file mode 100644 index 00000000000..e4f4de2d3b9 --- /dev/null +++ b/mod/hotpot/lang/en_utf8/help/hotpot/clickreporting.html @@ -0,0 +1,19 @@ +

Enable click reporting

+ +
+

+ Yes
+ A separate record is stored in the database each time a + "hint", "clue" or "check" + button is clicked. This allows the teacher to see a very + detailed report showing the state of the quiz at each click. + However, it may also mean that the size of the database grows + very quickly, because several "click" records may + be stored for each attempt at a quiz. +

+

+ No
+ Only one record per attempt at a quiz is stored in the Moodle database. +

+
+

By the default this option is disabled.

diff --git a/mod/hotpot/lang/en_utf8/help/hotpot/clickreporttable.html b/mod/hotpot/lang/en_utf8/help/hotpot/clickreporttable.html new file mode 100644 index 00000000000..1906c5b38c1 --- /dev/null +++ b/mod/hotpot/lang/en_utf8/help/hotpot/clickreporttable.html @@ -0,0 +1,74 @@ +

Click Trail

+

+ This table shows details of every click by every student + during completed attempts at a particular Hot Potatoes quiz. +

+

+ Please note that this report is very wide and can be very + long, so it is intended to be downloaded and viewed using + a spreadsheet program, such as Microsoft Excel. +

+

+ Each row in the table contains the following information: +

+ +

+ Which click?
+ The following details identify to which click in which attempt + by which student at which quiz in which section of which course + this row refers: +

+ + +

+ Which questions were affected?
+ The following details are shown of which questions, + if any, were affected by the current click: +

+ + +

+ How many questions were affected?
+ The following details are shown of the total number + of questions, if any, affected by the current click + and the total number of questions affected so far + in the quiz: +

+ + +

+ Scores
+ The following details are shown about scores for this click + and for the quiz so far: +

+ diff --git a/mod/hotpot/lang/en_utf8/help/hotpot/forceplugins.html b/mod/hotpot/lang/en_utf8/help/hotpot/forceplugins.html new file mode 100644 index 00000000000..659dc1602e9 --- /dev/null +++ b/mod/hotpot/lang/en_utf8/help/hotpot/forceplugins.html @@ -0,0 +1,17 @@ +

Force Moodle to use Moodle-compatible media players

+ +
+

+ No
+ Moodle will not change the settings of any media players in the quiz +

+

+ Yes
+ Moodle will force the quiz to use Moodle-compatible media players to play files like: +

+

+
+

+ More information: + Relative URLs, media players and Hot Potatoes +

diff --git a/mod/hotpot/lang/en_utf8/help/hotpot/index.html b/mod/hotpot/lang/en_utf8/help/hotpot/index.html new file mode 100644 index 00000000000..4fae9ef3b6f --- /dev/null +++ b/mod/hotpot/lang/en_utf8/help/hotpot/index.html @@ -0,0 +1,16 @@ +

Hot Potatoes

+ diff --git a/mod/hotpot/lang/en_utf8/help/hotpot/mediaplayers.html b/mod/hotpot/lang/en_utf8/help/hotpot/mediaplayers.html new file mode 100644 index 00000000000..2a593057989 --- /dev/null +++ b/mod/hotpot/lang/en_utf8/help/hotpot/mediaplayers.html @@ -0,0 +1,28 @@ +

Relative URLs, media players and Hot Potatoes

+ +

Definitions

+ +
+

URL
+ the address of an internet resource, such as a webpage, image or sound file. +

+

+ absolute URL
+ a URL that begins with "http://" is called an absolute URL. + Wherever it is used, it always refers to the same target resource. +

+

+ relative URL
+ a URL that does not begin with "http://" is called a relative URL. + It can be combined with the absolute URL of a "base" page, to get + the absolute URL of the target resource. +

+
+ +

Relative URLs in Hot Potatoes quizzes

+

Relative URLs are a convenient way to specify images, sounds and videos in a Hot Potatoes quiz, because they allow the quiz to be viewed and tested on a local PC, before being uploaded to a Moodle site. When the quiz is uploaded to the Moodle site, the multimedia files must also be uploaded, so that they are available when the quiz is administered via Moodle.

+

For security reasons, Moodle does not allow direct access to course files. All requests for files in a given course go through a guardian script which verfies that the person requesting the file is enrolled in the course. However, this mechanism can break relative links used in the quiz, because the normal rules for deriving an absolute URL from a relative URL do not work.

+

The solution is simple enough: all relative URLs must be converted to absolute URLs by the time the quiz reaches the browser. In the case of Hot Potatoes quizzes, the URLs will be converted by Moodle, so content creators do not have to bother with this tedious and error-prone task.

+ +

Media players in Hot Potatoes quizzes

+

Some media players will not accept the media file if it comes via the script which guards the course files. In this situation, it is necessary to replace the media player with one that is known to be compatible with Moodle. You can do this yourself by modifying the reference to the media player in the quiz, or you can force Moodle to do it by setting the "Force media plugins" option on the quiz's settings page to "Yes".

diff --git a/mod/hotpot/lang/en_utf8/help/hotpot/mods.html b/mod/hotpot/lang/en_utf8/help/hotpot/mods.html new file mode 100644 index 00000000000..1e926264726 --- /dev/null +++ b/mod/hotpot/lang/en_utf8/help/hotpot/mods.html @@ -0,0 +1,8 @@ +

 Hot Potatoes

+
+ This module, the "HotPot" module, allows teachers to administer + Hot Potatoes quizzes via Moodle. + The quizzes are created on the teacher's computer and then uploaded to the Moodle course.
+ After students have attempted the quizzes, a number of reports are available which show how + individual questions were answered and some statistical trends in the scores. +
diff --git a/mod/hotpot/lang/en_utf8/help/hotpot/navigation.html b/mod/hotpot/lang/en_utf8/help/hotpot/navigation.html new file mode 100644 index 00000000000..61ab1e2f5f1 --- /dev/null +++ b/mod/hotpot/lang/en_utf8/help/hotpot/navigation.html @@ -0,0 +1,40 @@ +

Navigation

+

+ You can specify different navigation aids for a Hot Potatoes Quiz. +

+
+

+ Moodle navigation bar
+ The standard Moodle navigation bar will be displayed in the same + window as the quiz at the top of the page. +

+

+ Moodle navigation frame
+ The standard Moodle navigation bar will be displayed in a separate + frame at the top of the quiz. +

+

+ Embedded IFRAME
+ The standard Moodle navigation bar will be displayed in the same + window as the quiz and the quiz will be embedded in an IFRAME. +

+

+ Hot Potatoes quiz buttons
+ The quiz will be displayed with the navigation buttons, if any, + defined in the quiz. +

+

+ A single "Give Up" button
+ The quiz will be displayed with a single "Give Up" button + at the top of the page. +

+

+ None
+ The quiz will be displayed with no navigation aids. i.e. neither + a Moodle navigation bar nor any Hot Potatoes navigation buttons. + When all questions on the current quiz have been answered correctly, + Moodle will either return to the course page or display the next quiz, + depending on the setting of the "Show next quiz?" field + for the current quiz. +

+
diff --git a/mod/hotpot/lang/en_utf8/help/hotpot/outputformat.html b/mod/hotpot/lang/en_utf8/help/hotpot/outputformat.html new file mode 100644 index 00000000000..99f15ea767f --- /dev/null +++ b/mod/hotpot/lang/en_utf8/help/hotpot/outputformat.html @@ -0,0 +1,39 @@ +

Output Format

+

+ You can specify different formats to display the quiz +

+
+

+ best
+ The quiz will be displayed in the best format for the browser. +

+

+ v6+
+ The quiz will be displayed in a drag and drop format for v6+ browsers +

+

+ v6
+ The quiz will be displayed in format for v6 browsers +

+

+ v5
+ The quiz will be displayed in a format for v5 browsers +

+

+ v4
+ The quiz will be displayed in a format for v4 browsers +

+

+ v3
+ The quiz will be displayed in a format for v3 browsers +

+

+ Flash
+ The quiz will be displayed in using Flash +

+

+ mobile
+ The quiz will be displayed in a format suitable for viewing on + small mobile devices such as cell phones +

+
diff --git a/mod/hotpot/lang/en_utf8/help/hotpot/removegradeitem.html b/mod/hotpot/lang/en_utf8/help/hotpot/removegradeitem.html new file mode 100644 index 00000000000..b23dd24f326 --- /dev/null +++ b/mod/hotpot/lang/en_utf8/help/hotpot/removegradeitem.html @@ -0,0 +1,13 @@ +

Remove grade item

+ +
+

+ No
+ The grade item for this activity in the Moodle gradebook will not be removed +

+

+ Yes
+ If the maximum grade for this Hot Potatoes quiz is set to zero, + then the grade item for this activity will be removed from the Moodle gradebook +

+
diff --git a/mod/hotpot/lang/en_utf8/help/hotpot/reportcontent.html b/mod/hotpot/lang/en_utf8/help/hotpot/reportcontent.html new file mode 100644 index 00000000000..715bec82605 --- /dev/null +++ b/mod/hotpot/lang/en_utf8/help/hotpot/reportcontent.html @@ -0,0 +1,109 @@ +

Report Content

+

You can specify different content for the Hot Potatoes reports.

+ +

Selecting the type of report

+
+

+ Overview
+ This report is a list of all attempts at this quiz. + + It shows the picture and name of each user, along with their + grade for the quiz and the score, time and duration of each attempt. + + Attempts may be selected and then deleted if required. +

+

+ Simple statistics
+ This report is a list of all attempts at this quiz, + except "in progress" attempts. + + It shows the picture and name of each user, along with their + grade for the quiz, and the score of each question in each attempt. + + It also gives the average scores of the individual + questions and the quiz as a whole. +

+

+ Detailed statistics
+ This report shows full details of all attempts at this quiz, + except "in progress" attempts. + + The report contains the following tables: +

+ +

+ Click trail report
+ This report shows details of every click by every student in all attempts at this quiz, + except "in progress" attempts. + + The report can be very large and is intended to be downloaded and viewed in a spreadsheet + program, such as Microsoft Excel. + + Details of the columns in this report are available in the + click trail table + help file. +

+

+ The click trail report is only available if + click reporting + has been enabled for this HotPot activity. +

+
+ +

Selecting users

+
+

+ All users
+ The report will show responses by all users who have attempted this quiz. + This includes users who are not currently enrolled on the course, + the "guest" user, course creators and Moodle administrators. +

+

+ All participants
+ The report will show responses by all students and teachers who are currently + enrolled on this course, as well as responses by the "guest" user, + course creators and Moodle administrators. +

+

+ Group: group name
+ The report will show responses by all students in the group selected. + The group options will not appear on the drop-down menu if there are + no groups defined for this course. +

+

+ Enrolled students
+ The report will show responses by students currently enrolled in this course. + Teacher's responses will not be included in the report. +

+

+ Single student
+ The report will show responses by a single student selected from a drop-down list + of students' names. +

+
+ +

Selecting grades

+
+

+ All attempts
+ The report will include the responses from all the attempts by each user. +

+

+ Best attempt
+ The report will only include the responses from the highest scoring attempt by each user. +

+

+ First attempt
+ The report will only include the responses from the first attempt by each user. +

+

+ Last attempt
+ The report will only include the responses from the most recent attempt by each user. +

+
\ No newline at end of file diff --git a/mod/hotpot/lang/en_utf8/help/hotpot/reportformat.html b/mod/hotpot/lang/en_utf8/help/hotpot/reportformat.html new file mode 100644 index 00000000000..43a85d812d6 --- /dev/null +++ b/mod/hotpot/lang/en_utf8/help/hotpot/reportformat.html @@ -0,0 +1,60 @@ +

Report Format

+

+ You can specify different output formats for the Hot Potatoes reports. +

+ +

Report Format

+
+

+ HTML
+ the report will be generated in HTML format suitable for displaying in a web browser +

+

+ Excel
+ the report will be generated as an ".xls" file which can be opened by + a spreadsheet program, such as Microsoft Excel +

+

+ Text
+ the report will be generated a text file which can be opened by a text editor +

+
+ +

Encoding

+
+

+ A list of encodings may be offered which allows you to force the report values + into a specific encoding if your spreadsheet program requires it. + + For example, Microsoft Excel requires the "SJIS" encoding for Japanese. + + The list of possible encodings can be adjusted by the site administrator on the + "Settings" page for the HotPot module +

+
+ +

Wrap data

+
+

+ Yes
+ long data values will be wrapped to fit into table cells. + This may make some rows very tall +

+

+ No
+ data values will not be wrapped +

+
+ +

Show legend

+
+

+ Yes
+ in the main report, questions and answers will be represented by letters. + A legend will be generated which shows which letters represent which questions or answers +

+

+ No
+ questions and answers will appear in full in the report and no legend will be generated +

+
diff --git a/mod/hotpot/lang/en_utf8/help/hotpot/responsestable.html b/mod/hotpot/lang/en_utf8/help/hotpot/responsestable.html new file mode 100644 index 00000000000..1889b87d8e2 --- /dev/null +++ b/mod/hotpot/lang/en_utf8/help/hotpot/responsestable.html @@ -0,0 +1,22 @@ +

Individual Responses

+

+ This table shows how each user responded to each + question in each of their attempts at the quiz. +

+

+ The responses are color-coded as follows: +

+ diff --git a/mod/hotpot/lang/en_utf8/help/hotpot/shownextquiz.html b/mod/hotpot/lang/en_utf8/help/hotpot/shownextquiz.html new file mode 100644 index 00000000000..471e51ffe9c --- /dev/null +++ b/mod/hotpot/lang/en_utf8/help/hotpot/shownextquiz.html @@ -0,0 +1,17 @@ +

Show next quiz

+ +
+

+ No
+ When the Hot Potatoes quiz is finished, Moodle will + record the results and return to the main page for the + current course +

+

+ Yes
+ When the Hot Potatoes quiz is finished, Moodle will + record the results and then display the next Hot Potatoes + quiz in the current section. If there is no such quiz, + Moodle will return to the main page for the current course +

+
diff --git a/mod/hotpot/lang/en_utf8/help/hotpot/studentfeedback.html b/mod/hotpot/lang/en_utf8/help/hotpot/studentfeedback.html new file mode 100644 index 00000000000..cc4fc784b33 --- /dev/null +++ b/mod/hotpot/lang/en_utf8/help/hotpot/studentfeedback.html @@ -0,0 +1,38 @@ +

Student feedback

+

+ If this option is enabled, a link to a popup feedback window will be displayed + whenever the student clicks on the "Check" button. The feedback window + allows students to send feedback to the teacher regarding the quiz. +

+

+ This option can have the following settings: +

+
+

+ None
+ no feedback window will be displayed +

+

+ Web page
+ a web page will be displayed in the feedback window. + You will need to enter the URL of the web page, for example: + http://myserver.com/feedbackform.html +

+

+ Feedback form
+ a form suitable for sending to a standard form-to-email script, + such as formmail.pl, will be displayed in the feedback window. + You should also enter the URL of the form script, for example: + http://myserver.com/cgi-bin/formmail.pl +

+

+ Moodle forum
+ the forum index for this Moodle course will be displayed +

+

+ Moodle messaging
+ the Moodle instant messaging window will be displayed. + If the course has several teachers, the student will be + prompted to select a teacher before the messaging page appears. +

+
diff --git a/mod/hotpot/lang/en_utf8/help/hotpot/updatequizchain.html b/mod/hotpot/lang/en_utf8/help/hotpot/updatequizchain.html new file mode 100644 index 00000000000..f9f947ca181 --- /dev/null +++ b/mod/hotpot/lang/en_utf8/help/hotpot/updatequizchain.html @@ -0,0 +1,13 @@ +

Update next quiz

+ +
+

+ No
+ Only the current quiz will be updated +

+

+ Yes
+ If this quiz is part of a chain of Hot Potatoes quizzes, then all quizzes + in the chain will be assigned identical settings to the current quiz. +

+
diff --git a/mod/hotpot/lang/en_utf8/hotpot.php b/mod/hotpot/lang/en_utf8/hotpot.php new file mode 100644 index 00000000000..8c1f550843e --- /dev/null +++ b/mod/hotpot/lang/en_utf8/hotpot.php @@ -0,0 +1,160 @@ + diff --git a/mod/hotpot/lib.php b/mod/hotpot/lib.php index 36d90270333..5e93d8b06e3 100644 --- a/mod/hotpot/lib.php +++ b/mod/hotpot/lib.php @@ -1097,7 +1097,7 @@ function hotpot_get_recent_mod_activity(&$activities, &$index, $sincetime, $cour } } -function hotpot_print_recent_mod_activity($activity, $course, $detail=false) { +function hotpot_print_recent_mod_activity($activity, $courseid, $detail=false) { /// Basically, this function prints the results of "hotpot_get_recent_activity" global $CFG, $THEME, $USER; @@ -1108,10 +1108,14 @@ function hotpot_print_recent_mod_activity($activity, $course, $detail=false) { $bgcolor = ''; } + if (is_object($courseid) && isset($courseid->id)) { + $courseid = $courseid->id; // shouldn't happen !! + } + print ''; print ''; - print_user_picture($activity->user->userid, $course, $activity->user->picture); + print_user_picture($activity->user->userid, $courseid, $activity->user->picture); print '
'; if ($detail) { @@ -1123,7 +1127,7 @@ function hotpot_print_recent_mod_activity($activity, $course, $detail=false) { $href = "$CFG->wwwroot/mod/hotpot/view.php?hp=$activity->instance"; print ''.$activity->name.' - '; } - if (has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $course))) { + if (has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $courseid))) { // score (with link to attempt details) $href = "$CFG->wwwroot/mod/hotpot/review.php?hp=$activity->instance&attempt=".$activity->content->attemptid; print '('.hotpot_format_score($activity->content).') '; @@ -1133,7 +1137,7 @@ function hotpot_print_recent_mod_activity($activity, $course, $detail=false) { } // link to user - $href = "$CFG->wwwroot/user/view.php?id=$activity->user->userid&course=$course"; + $href = "$CFG->wwwroot/user/view.php?id=$activity->user->userid&course=$courseid"; print ''.$activity->user->fullname.' '; // time and date @@ -1805,7 +1809,7 @@ class hotpot_xml_quiz extends hotpot_xml_tree { $quoteopen = '("|"|")'; // open quote $quoteclose = '\\5'; // close quote (to match open quote) - $tags = array('script'=>'src', 'link'=>'href', 'a'=>'href','img'=>'src','param'=>'value', 'object'=>'data', 'embed'=>'src'); + $tags = array('script'=>'src', 'link'=>'href', 'a'=>'href','img'=>'src','param'=>'value', 'object'=>'data', 'embed'=>'src', '(?:table|th|td)' =>'background'); foreach ($tags as $tag=>$attribute) { if ($tag=='param') { $url = '\S+?\.\S+?'; // must include a filename and have no spaces diff --git a/mod/hotpot/restorelib.php b/mod/hotpot/restorelib.php index bdec5d10d11..c9c6a419a4a 100644 --- a/mod/hotpot/restorelib.php +++ b/mod/hotpot/restorelib.php @@ -298,8 +298,9 @@ function hotpot_restore_record(&$restore, $status, &$xml, $table, $foreign_keys, // maintain a cache of info on table columns static $table_columns = array(); if (empty($table_columns[$table])) { - global $CFG, $db; - $table_columns[$table] = $db->MetaColumns("$CFG->prefix$table"); + //global $CFG, $db; + //$table_columns[$table] = $db->MetaColumns("$CFG->prefix$table"); + $table_columns[$table] = $DB->get_columns($table); } // get values for fields in this record diff --git a/mod/hotpot/view.php b/mod/hotpot/view.php index 262771d60a1..698fbfa6e5c 100644 --- a/mod/hotpot/view.php +++ b/mod/hotpot/view.php @@ -141,7 +141,7 @@ // HP5 v5 $get_html = empty($framename) ? true : false; } - + if ($get_html) { if (HOTPOT_FIRST_ATTEMPT) { @@ -356,14 +356,20 @@ $body .= "" . '\n" diff --git a/question/format/hotpot/format.php b/question/format/hotpot/format.php index e31ec983d0b..33bdad3136c 100644 --- a/question/format/hotpot/format.php +++ b/question/format/hotpot/format.php @@ -42,7 +42,7 @@ class qformat_hotpot extends qformat_default { break; default: // shouldn't happen !! - $courseid = 0; + $courseid = 0; } require_once($CFG->libdir.'/filelib.php'); $baseurl = get_file_url($courseid).'/'; @@ -81,7 +81,12 @@ class qformat_hotpot extends qformat_default { $questions = array(); switch ($xml->quiztype) { case 'jcloze': - $this->process_jcloze($xml, $questions); + if (strpos($source, '')) { + $startwithgap = true; + } else { + $startwithgap = false; + } + $this->process_jcloze($xml, $questions, $startwithgap); break; case 'jcross': $this->process_jcross($xml, $questions); @@ -114,7 +119,7 @@ class qformat_hotpot extends qformat_default { } } - function process_jcloze(&$xml, &$questions) { + function process_jcloze(&$xml, &$questions, $startwithgap) { // define default grade (per cloze gap) $defaultgrade = 1; $gap_count = 0; @@ -144,10 +149,27 @@ class qformat_hotpot extends qformat_default { $question->usecase = 0; // Ignore case $question->image = ""; // No images with this format } - $question->qtype = MULTIANSWER; + $question->qtype = MULTIANSWER; $question->name = $this->hotpot_get_title($xml, $x); - $question->questiontext = $this->hotpot_get_reading($xml); + $question->questiontext = ''; + + // add get dropdown list, if any + if (intval($xml->xml_value('hotpot-config-file,'.$xml->quiztype.',use-drop-down-list'))) { + $dropdownlist = $this->hotpot_jcloze_wordlist($xml); + $answertype = MULTICHOICE; + } else { + $dropdownlist = false; + $answertype = SHORTANSWER; + + // add wordlist, if required (not required if we are using dropdowns) + if (intval($xml->xml_value('hotpot-config-file,'.$xml->quiztype.',include-word-list'))) { + $question->questiontext .= '

'.implode(' ', $this->hotpot_jcloze_wordlist($xml)).'

'; + } + } + + // add reading, if any + $question->questiontext .= $this->hotpot_get_reading($xml); // setup answer arrays if ($moodle_14) { @@ -160,71 +182,130 @@ class qformat_hotpot extends qformat_default { } $q = 0; - while ($text = $xml->xml_value($tags, $exercise."[$q]")) { - // add next bit of text - $question->questiontext .= $this->hotpot_prepare_str($text); + $looping = true; + while ($looping) { + // get next bit of text + $questiontext = $xml->xml_value($tags, $exercise."[$q]"); + $questiontext = $this->hotpot_prepare_str($questiontext); - // check for a gap + // get next gap + $gap = ''; $question_record = $exercise."['question-record'][$q]['#']"; if ($xml->xml_value($tags, $question_record)) { // add gap $gap_count ++; $positionkey = $q+1; - $question->questiontext .= '{#'.$positionkey.'}'; - + $gap = '{#'.$positionkey.'}'; + // initialize answer settings if ($moodle_14) { $question->answers[$q]->positionkey = $positionkey; - $question->answers[$q]->answertype = SHORTANSWER; + $question->answers[$q]->answertype = $answertype; $question->answers[$q]->norm = $defaultgrade; $question->answers[$q]->alternatives = array(); } else { $wrapped = new stdClass(); - $wrapped->qtype = SHORTANSWER; + $wrapped->qtype = $answertype; $wrapped->usecase = 0; $wrapped->defaultgrade = $defaultgrade; $wrapped->questiontextformat = 0; $wrapped->answer = array(); $wrapped->fraction = array(); $wrapped->feedback = array(); + // required for multichoice + $wrapped->single = 1; + $wrapped->answernumbering = 0; + $wrapped->shuffleanswers = 0; + $wrapped->correctfeedback = ''; + $wrapped->partiallycorrectfeedback = ''; + $wrapped->incorrectfeedback = ''; + // array of answers $answers = array(); } - + // add answers - $a = 0; - while (($answer=$question_record."['answer'][$a]['#']") && $xml->xml_value($tags, $answer)) { - $text = $this->hotpot_prepare_str($xml->xml_value($tags, $answer."['text'][0]['#']")); - $correct = $xml->xml_value($tags, $answer."['correct'][0]['#']"); - $feedback = $this->hotpot_prepare_str($xml->xml_value($tags, $answer."['feedback'][0]['#']")); - if (strlen($text)) { - // set score (0=0%, 1=100%) - $fraction = empty($correct) ? 0 : 1; - // store answer + if ($dropdownlist) { + + $a = 0; + $correcttext = ''; + $correctfeedback = ''; + while (($answer=$question_record."['answer'][$a]['#']") && $xml->xml_value($tags, $answer)) { + if (intval($xml->xml_value($tags, $answer."['correct'][0]['#']"))) { + $correcttext = $this->hotpot_prepare_str($xml->xml_value($tags, $answer."['text'][0]['#']")); + $correctfeedback = $this->hotpot_prepare_str($xml->xml_value($tags, $answer."['feedback'][0]['#']")); + break; + } + $a++; + } + + foreach ($dropdownlist as $a => $answer) { + if ($answer==$correcttext) { + $fraction = 1; + $feedback = $correctfeedback; + } else { + $fraction = 0; + $feedback = ''; + } if ($moodle_14) { $question->answers[$q]->alternatives[$a] = new stdClass(); - $question->answers[$q]->alternatives[$a]->answer = $text; + $question->answers[$q]->alternatives[$a]->answer = $answer; $question->answers[$q]->alternatives[$a]->fraction = $fraction; $question->answers[$q]->alternatives[$a]->feedback = $feedback; } else { - $wrapped->answer[] = $text; + $wrapped->answer[] = $answer; $wrapped->fraction[] = $fraction; $wrapped->feedback[] = $feedback; - $answers[] = (empty($fraction) ? '' : '=').$text.(empty($feedback) ? '' : ('#'.$feedback)); + $answers[] = ($fraction==0 ? '' : '=').$answer.($feedback=='' ? '' : ('#'.$feedback)); } } - $a++; + } else { + $a = 0; + while (($answer=$question_record."['answer'][$a]['#']") && $xml->xml_value($tags, $answer)) { + $text = $this->hotpot_prepare_str($xml->xml_value($tags, $answer."['text'][0]['#']")); + $correct = $xml->xml_value($tags, $answer."['correct'][0]['#']"); + $feedback = $this->hotpot_prepare_str($xml->xml_value($tags, $answer."['feedback'][0]['#']")); + if (strlen($text)) { + // set score (0=0%, 1=100%) + $fraction = empty($correct) ? 0 : 1; + // store answer + if ($moodle_14) { + $question->answers[$q]->alternatives[$a] = new stdClass(); + $question->answers[$q]->alternatives[$a]->answer = $text; + $question->answers[$q]->alternatives[$a]->fraction = $fraction; + $question->answers[$q]->alternatives[$a]->feedback = $feedback; + } else { + $wrapped->answer[] = $text; + $wrapped->fraction[] = $fraction; + $wrapped->feedback[] = $feedback; + $answers[] = (empty($fraction) ? '' : '=').$text.(empty($feedback) ? '' : ('#'.$feedback)); + } + } + $a++; + } } + // compile answers into question text, if necessary if ($moodle_14) { // do nothing } else { - $wrapped->questiontext = '{'.$defaultgrade.':SHORTANSWER:'.implode('~', $answers).'}'; + $wrapped->questiontext = '{'.$defaultgrade.':'.$answertype.':'.implode('~', $answers).'}'; $question->options->questions[] = $wrapped; } } // end if gap + + if (strlen($questiontext) || strlen($gap)) { + if ($startwithgap) { + $question->questiontext .= $gap.$questiontext; + } else { + $question->questiontext .= $questiontext.$gap; + } + } else { + $looping = false; + } + $q++; - } // end while $text + } // end while $looping if ($q) { // define total grade for this exercise @@ -241,6 +322,32 @@ class qformat_hotpot extends qformat_default { } // end while $exercise } + function hotpot_jcloze_wordlist(&$xml) { + $wordlist = array(); + + $q = 0; + $tags = 'data,gap-fill,question-record'; + while (($question="[$q]['#']") && $xml->xml_value($tags, $question)) { + $a = 0; + $aa = 0; + while (($answer=$question."['answer'][$a]['#']") && $xml->xml_value($tags, $answer)) { + $text = $xml->xml_value($tags, $answer."['text'][0]['#']"); + $correct = $xml->xml_value($tags, $answer."['correct'][0]['#']"); + if (strlen($text) && intval($correct)) { + $wordlist[] = $text; + $aa++; + } + $a++; + } + $q++; + } + + $wordlist = array_unique($wordlist); + sort($wordlist); + + return $wordlist; + } + function process_jcross(&$xml, &$questions) { // xml tags to the start of the crossword exercise clue items $tags = 'data,crossword,clues,item'; @@ -488,7 +595,7 @@ class qformat_hotpot extends qformat_default { $a++; } if ($correct_answers_all_zero) { - // correct answers all have score of 0%, + // correct answers all have score of 0%, // so reset score for correct answers 100% foreach ($correct_answers as $aa) { $question->fraction[$aa] = 1; @@ -531,10 +638,10 @@ class qformat_hotpot extends qformat_default { $tags = 'data,reading'; if ($xml->xml_value("$tags,include-reading")) { if ($title = $xml->xml_value("$tags,reading-title")) { - $str .= "

$title

"; + $str .= "

$title

"; } if ($text = $xml->xml_value("$tags,reading-text")) { - $str .= "

$text

"; + $str .= "

$text

"; } } return $this->hotpot_prepare_str($str); @@ -572,7 +679,7 @@ function hotpot_charcode_to_utf8($charcode) { return chr(($charcode >> 0x12) + 0xF0).chr((($charcode >> 0x0C) & 0x3F) + 0x80).chr((($charcode >> 0x06) & 0x3F) + 0x80).chr(($charcode & 0x3F) + 0x80); } // unidentified char code !! - return ' '; + return ' '; } function hotpot_convert_relative_urls($str, $baseurl, $filename) {