diff --git a/mod/hotpot/README.TXT b/mod/hotpot/README.TXT
index 411570779df..baf1654d342 100644
--- a/mod/hotpot/README.TXT
+++ b/mod/hotpot/README.TXT
@@ -1,4 +1,4 @@
-This is v2.1.11 of the HotPot module
+This is v2.1.12 of the HotPot module
This module allows teachers to administer Hot Potatoes and TexToys quizzes via Moodle.
It has been tested on:
- Hot Potatoes 6
diff --git a/mod/hotpot/lib.php b/mod/hotpot/lib.php
index 9df8ec77673..ee321a818a5 100644
--- a/mod/hotpot/lib.php
+++ b/mod/hotpot/lib.php
@@ -1,2362 +1,2362 @@
-hotpot_showtimes)) {
- set_config("hotpot_showtimes", 0);
-}
-if (!isset($CFG->hotpot_excelencodings)) {
- set_config("hotpot_excelencodings", "");
-}
-
-//////////////////////////////////
-/// CONSTANTS and GLOBAL VARIABLES
-
-$CFG->hotpotroot = "$CFG->dirroot/mod/hotpot";
-$CFG->hotpottemplate = "$CFG->hotpotroot/template";
-$CFG->hotpotismobile = preg_match('/Alcatel|ATTWS|DoCoMo|Doris|Hutc3G|J-PHONE|Java|KDDI|KGT|LGE|MOT|Nokia|portalmmm|ReqwirelessWeb|SAGEM|SHARP|SIE-|SonyEricsson|Teleport|UP\.Browser|UPG1|Wapagsim/', $_SERVER['HTTP_USER_AGENT']);
-
-define("HOTPOT_JS", "$CFG->wwwroot/mod/hotpot/hotpot-full.js");
-
-define("HOTPOT_NO", "0");
-define("HOTPOT_YES", "1");
-
-define ("HOTPOT_TEXTSOURCE_QUIZ", "0");
-define ("HOTPOT_TEXTSOURCE_FILENAME", "1");
-define ("HOTPOT_TEXTSOURCE_FILEPATH", "2");
-define ("HOTPOT_TEXTSOURCE_SPECIFIC", "3");
-
-define("HOTPOT_LOCATION_COURSEFILES", "0");
-define("HOTPOT_LOCATION_SITEFILES", "1");
-
-$HOTPOT_LOCATION = array (
- HOTPOT_LOCATION_COURSEFILES => get_string("coursefiles"),
- HOTPOT_LOCATION_SITEFILES => get_string("sitefiles"),
-);
-
-define("HOTPOT_OUTPUTFORMAT_BEST", "1");
-define("HOTPOT_OUTPUTFORMAT_V3", "10");
-define("HOTPOT_OUTPUTFORMAT_V4", "11");
-define("HOTPOT_OUTPUTFORMAT_V5", "12");
-define("HOTPOT_OUTPUTFORMAT_V5_PLUS", "13");
-define("HOTPOT_OUTPUTFORMAT_V6", "14");
-define("HOTPOT_OUTPUTFORMAT_V6_PLUS", "15");
-define("HOTPOT_OUTPUTFORMAT_FLASH", "20");
-define("HOTPOT_OUTPUTFORMAT_MOBILE", "30");
-
-$HOTPOT_OUTPUTFORMAT = array (
- HOTPOT_OUTPUTFORMAT_BEST => get_string("outputformat_best", "hotpot"),
- HOTPOT_OUTPUTFORMAT_V6_PLUS => get_string("outputformat_v6_plus", "hotpot"),
- HOTPOT_OUTPUTFORMAT_V6 => get_string("outputformat_v6", "hotpot"),
- HOTPOT_OUTPUTFORMAT_V5_PLUS => get_string("outputformat_v5_plus", "hotpot"),
- HOTPOT_OUTPUTFORMAT_V5 => get_string("outputformat_v5", "hotpot"),
- HOTPOT_OUTPUTFORMAT_V4 => get_string("outputformat_v4", "hotpot"),
- HOTPOT_OUTPUTFORMAT_V3 => get_string("outputformat_v3", "hotpot"),
- HOTPOT_OUTPUTFORMAT_FLASH => get_string("outputformat_flash", "hotpot"),
- HOTPOT_OUTPUTFORMAT_MOBILE => get_string("outputformat_mobile", "hotpot"),
-);
-$HOTPOT_OUTPUTFORMAT_DIR = array (
- HOTPOT_OUTPUTFORMAT_V6_PLUS => 'v6',
- HOTPOT_OUTPUTFORMAT_V6 => 'v6',
- HOTPOT_OUTPUTFORMAT_V5_PLUS => 'v5',
- HOTPOT_OUTPUTFORMAT_V5 => 'v5',
- HOTPOT_OUTPUTFORMAT_V4 => 'v4',
- HOTPOT_OUTPUTFORMAT_V3 => 'v3',
- HOTPOT_OUTPUTFORMAT_FLASH => 'flash',
- HOTPOT_OUTPUTFORMAT_MOBILE => 'mobile',
-);
-foreach ($HOTPOT_OUTPUTFORMAT_DIR as $format=>$dir) {
- if (is_file("$CFG->hotpottemplate/$dir.php") && is_dir("$CFG->hotpottemplate/$dir")) {
- // do nothing ($format is available)
- } else {
- // $format is not available, so remove it
- unset($HOTPOT_OUTPUTFORMAT[$format]);
- unset($HOTPOT_OUTPUTFORMAT_DIR[$format]);
- }
-}
-define("HOTPOT_NAVIGATION_BAR", "1");
-define("HOTPOT_NAVIGATION_FRAME", "2");
-define("HOTPOT_NAVIGATION_IFRAME", "3");
-define("HOTPOT_NAVIGATION_BUTTONS", "4");
-define("HOTPOT_NAVIGATION_GIVEUP", "5");
-define("HOTPOT_NAVIGATION_NONE", "6");
-
-$HOTPOT_NAVIGATION = array (
- HOTPOT_NAVIGATION_BAR => get_string("navigation_bar", "hotpot"),
- HOTPOT_NAVIGATION_FRAME => get_string("navigation_frame", "hotpot"),
- HOTPOT_NAVIGATION_IFRAME => get_string("navigation_iframe", "hotpot"),
- HOTPOT_NAVIGATION_BUTTONS => get_string("navigation_buttons", "hotpot"),
- HOTPOT_NAVIGATION_GIVEUP => get_string("navigation_give_up", "hotpot"),
- HOTPOT_NAVIGATION_NONE => get_string("navigation_none", "hotpot"),
-);
-
-define("HOTPOT_JCB", "1");
-define("HOTPOT_JCLOZE", "2");
-define("HOTPOT_JCROSS", "3");
-define("HOTPOT_JMATCH", "4");
-define("HOTPOT_JMIX", "5");
-define("HOTPOT_JQUIZ", "6");
-define("HOTPOT_TEXTOYS_RHUBARB", "7");
-define("HOTPOT_TEXTOYS_SEQUITUR", "8");
-
-$HOTPOT_QUIZTYPE = array(
- HOTPOT_JCB => 'JCB',
- HOTPOT_JCLOZE => 'JCloze',
- HOTPOT_JCROSS => 'JCross',
- HOTPOT_JMATCH => 'JMatch',
- HOTPOT_JMIX => 'JMix',
- HOTPOT_JQUIZ => 'JQuiz',
- HOTPOT_TEXTOYS_RHUBARB => 'Rhubarb',
- HOTPOT_TEXTOYS_SEQUITUR => 'Sequitur'
-);
-
-define("HOTPOT_JQUIZ_MULTICHOICE", "1");
-define("HOTPOT_JQUIZ_SHORTANSWER", "2");
-define("HOTPOT_JQUIZ_HYBRID", "3");
-define("HOTPOT_JQUIZ_MULTISELECT", "4");
-
-define("HOTPOT_GRADEMETHOD_HIGHEST", "1");
-define("HOTPOT_GRADEMETHOD_AVERAGE", "2");
-define("HOTPOT_GRADEMETHOD_FIRST", "3");
-define("HOTPOT_GRADEMETHOD_LAST", "4");
-
-$HOTPOT_GRADEMETHOD = array (
- HOTPOT_GRADEMETHOD_HIGHEST => get_string("gradehighest", "quiz"),
- HOTPOT_GRADEMETHOD_AVERAGE => get_string("gradeaverage", "quiz"),
- HOTPOT_GRADEMETHOD_FIRST => get_string("attemptfirst", "quiz"),
- HOTPOT_GRADEMETHOD_LAST => get_string("attemptlast", "quiz"),
-);
-
-define("HOTPOT_STATUS_INPROGRESS", "1");
-define("HOTPOT_STATUS_TIMEDOUT", "2");
-define("HOTPOT_STATUS_ABANDONED", "3");
-define("HOTPOT_STATUS_COMPLETED", "4");
-
-$HOTPOT_STATUS = array (
- HOTPOT_STATUS_INPROGRESS => get_string("inprogress", "hotpot"),
- HOTPOT_STATUS_TIMEDOUT => get_string("timedout", "hotpot"),
- HOTPOT_STATUS_ABANDONED => get_string("abandoned", "hotpot"),
- HOTPOT_STATUS_COMPLETED => get_string("completed", "hotpot"),
-);
-
-define("HOTPOT_FEEDBACK_NONE", "0");
-define("HOTPOT_FEEDBACK_WEBPAGE", "1");
-define("HOTPOT_FEEDBACK_FORMMAIL", "2");
-define("HOTPOT_FEEDBACK_MOODLEFORUM", "3");
-define("HOTPOT_FEEDBACK_MOODLEMESSAGING", "4");
-
-$HOTPOT_FEEDBACK = array (
- HOTPOT_FEEDBACK_NONE => get_string("feedbacknone", "hotpot"),
- HOTPOT_FEEDBACK_WEBPAGE => get_string("feedbackwebpage", "hotpot"),
- HOTPOT_FEEDBACK_FORMMAIL => get_string("feedbackformmail", "hotpot"),
- HOTPOT_FEEDBACK_MOODLEFORUM => get_string("feedbackmoodleforum", "hotpot"),
- HOTPOT_FEEDBACK_MOODLEMESSAGING => get_string("feedbackmoodlemessaging", "hotpot"),
-);
-if (empty($CFG->messaging)) { // Moodle 1.4 (and less)
- unset($HOTPOT_FEEDBACK[HOTPOT_FEEDBACK_MOODLEMESSAGING]);
-}
-
-define("HOTPOT_DISPLAYNEXT_QUIZ", "0");
-define("HOTPOT_DISPLAYNEXT_COURSE", "1");
-define("HOTPOT_DISPLAYNEXT_INDEX", "2");
-
-//////////////////////////////////
-/// CORE FUNCTIONS
-
-
-// possible return values:
-// false:
-// display moderr.html (if exists) OR "Could not update" and return to couse view
-// string:
-// display as error message and return to course view
-// true (or non-zero number):
-// continue to $hp->redirect (if set) OR hotpot/view.php (to displsay quiz)
-
-// $hp is an object containing the values of the form in mod.html
-// i.e. all the fields in the 'hotpot' table, plus the following:
-// $hp->course : an id in the 'course' table
-// $hp->coursemodule : an id in the 'course_modules' table
-// $hp->section : an id in the 'course_sections' table
-// $hp->module : an id in the 'modules' table
-// $hp->modulename : always 'hotpot'
-// $hp->instance : an id in the 'hotpot' table
-// $hp->mode : 'add' or 'update'
-// $hp->sesskey : unique string required for Moodle's session management
-
-function hotpot_add_instance(&$hp) {
- if (hotpot_set_form_values($hp)) {
- $result = insert_record("hotpot", $hp);
- } else {
- $result= false;
- }
- return $result;
-}
-
-function hotpot_update_instance(&$hp) {
- if (hotpot_set_form_values($hp)) {
- $hp->id = $hp->instance;
- $result = update_record("hotpot", $hp);
- } else {
- $result= false;
- }
- return $result;
-}
-
-function hotpot_set_form_values(&$hp) {
- $ok = true;
- $hp->errors = array(); // these will be reported by moderr.html
-
- if (empty($hp->reference)) {
- $ok = false;
- $hp->errors['reference']= get_string('error_nofilename', 'hotpot');
- }
-
- if ($hp->studentfeedbackurl=='http://') {
- $hp->studentfeedbackurl = '';
- }
-
- if (empty($hp->studentfeedbackurl)) {
- switch ($hp->studentfeedback) {
- case HOTPOT_FEEDBACK_WEBPAGE:
- $ok = false;
- $hp->errors['studentfeedbackurl']= get_string('error_nofeedbackurlwebpage', 'hotpot');
- break;
- case HOTPOT_FEEDBACK_FORMMAIL:
- $ok = false;
- $hp->errors['studentfeedbackurl']= get_string('error_nofeedbackurlformmail', 'hotpot');
- break;
- }
- }
-
- $time = time();
- $hp->timecreated = $time;
- $hp->timemodified = $time;
-
- if (empty($hp->enabletimeopen)) {
- $hp->timeopen = 0;
- } else {
- $hp->timeopen = make_timestamp(
- $hp->openyear, $hp->openmonth, $hp->openday,
- $hp->openhour, $hp->openminute, 0
- );
- }
-
- if (empty($hp->enabletimeclose)) {
- $hp->timeclose = 0;
- } else {
- $hp->timeclose = make_timestamp(
- $hp->closeyear, $hp->closemonth, $hp->closeday,
- $hp->closehour, $hp->closeminute, 0
- );
- }
-
- if ($hp->quizchain==HOTPOT_YES) {
- switch ($hp->mode) {
- case 'add':
- $ok = hotpot_add_chain($hp);
- break;
- case 'update':
- $ok = hotpot_update_chain($hp);
- break;
- }
- } else { // $hp->quizchain==HOTPOT_NO
- hotpot_set_name_summary_reference($hp);
- }
-
- switch ($hp->displaynext) {
- // N.B. redirection only works for Moodle 1.5+
- case HOTPOT_DISPLAYNEXT_COURSE:
- $hp->redirect = true;
- $hp->redirecturl = "view.php?id=$hp->course";
- break;
- case HOTPOT_DISPLAYNEXT_INDEX:
- $hp->redirect = true;
- $hp->redirecturl = "../mod/hotpot/index.php?id=$hp->course";
- break;
- default:
- // use Moodle default action (i.e. go on to display the hotpot quiz)
- }
-
- // if ($ok && $hp->setdefaults) {
- if ($ok) {
- set_user_preference('hotpot_timeopen', $hp->timeopen);
- set_user_preference('hotpot_timeclose', $hp->timeclose);
- set_user_preference('hotpot_navigation', $hp->navigation);
- set_user_preference('hotpot_outputformat', $hp->outputformat);
- set_user_preference('hotpot_studentfeedback', $hp->studentfeedback);
- set_user_preference('hotpot_studentfeedbackurl', $hp->studentfeedbackurl);
- set_user_preference('hotpot_forceplugins', $hp->forceplugins);
- set_user_preference('hotpot_shownextquiz', $hp->shownextquiz);
- set_user_preference('hotpot_review', $hp->review);
- set_user_preference('hotpot_grade', $hp->grade);
- set_user_preference('hotpot_grademethod', $hp->grademethod);
- set_user_preference('hotpot_attempts', $hp->attempts);
- set_user_preference('hotpot_subnet', $hp->subnet);
- set_user_preference('hotpot_displaynext', $hp->displaynext);
- if ($hp->mode=='add') {
- set_user_preference('hotpot_quizchain', $hp->quizchain);
- set_user_preference('hotpot_namesource', $hp->namesource);
- set_user_preference('hotpot_summarysource', $hp->summarysource);
- }
- }
- return $ok;
-}
-function hotpot_get_chain(&$cm) {
- // get details of course_modules in this section
- $course_module_ids = get_field('course_sections', 'sequence', 'id', $cm->section);
- if (empty($course_module_ids)) {
- $hotpot_modules = array();
- } else {
- $hotpot_modules = get_records_select('course_modules', "id IN ($course_module_ids) AND module=$cm->module");
- if (empty($hotpot_modules)) {
- $hotpot_modules = array();
- }
- }
-
- // get ids of hotpot modules in this section
- $ids = array();
- foreach ($hotpot_modules as $hotpot_module) {
- $ids[] = $hotpot_module->instance;
- }
-
- // get details of hotpots in this section
- if (empty($ids)) {
- $hotpots = array();
- } else {
- $hotpots = get_records_list('hotpot', 'id', implode(',', $ids));
- }
-
- $found = false;
- $chain = array();
-
- // loop through course_modules in this section
- $ids = explode(',', $course_module_ids);
- foreach ($ids as $id) {
-
- // check this course_module is a hotpot activity
- if (isset($hotpot_modules[$id])) {
-
- // store details of this course module and hotpot activity
- $hotpot_id = $hotpot_modules[$id]->instance;
- $chain[$id] = &$hotpot_modules[$id];
- $chain[$id]->hotpot = &$hotpots[$hotpot_id];
-
- // set $found, if this is the course module we're looking for
- if (isset($cm->coursemodule)) {
- if ($id==$cm->coursemodule) {
- $found = true;
- }
- } else {
- if ($id==$cm->id) {
- $found = true;
- }
- }
-
- // is this the end of a chain
- if (empty($hotpots[$hotpot_id]->shownextquiz)) {
- if ($found) {
- break; // out of loop
- } else {
- // restart chain (target cm has not been found yet)
- $chain = array();
- }
- }
- }
- } // end foreach $ids
-
- return $found ? $chain : false;
-}
-function hotpot_is_visible(&$cm) {
- if (!isset($cm->sectionvisible)) {
- if ($section = get_record('course_sections', 'id', $cm->section)) {
- $cm->sectionvisible = $section->visible;
- } else {
- error('Course module record contains invalid section');
- }
- }
-
- if (empty($cm->sectionvisible)) {
- $visible = HOTPOT_NO;
- } else {
- $visible = HOTPOT_YES;
- if (empty($cm->visible)) {
- if ($chain = hotpot_get_chain($cm)) {
- $startofchain = array_shift($chain);
- $visible = $startofchain->visible;
- }
- }
- }
- return $visible;
-}
-function hotpot_add_chain(&$hp) {
-/// add a chain of hotpot actiivities
-
- global $CFG, $course;
-
- $ok = true;
- $hp->names = array();
- $hp->summaries = array();
- $hp->references = array();
-
- $xml_quiz = new hotpot_xml_quiz($hp, false, false, false, false, false);
-
- if (isset($xml_quiz->error)) {
- $hp->errors['reference'] = $xml_quiz->error;
- $ok = false;
-
- } else if (is_dir($xml_quiz->filepath)) {
-
- // get list of hotpot files in this folder
- if ($dh = @opendir($xml_quiz->filepath)) {
- while ($file = @readdir($dh)) {
- if (preg_match('/\.(jbc|jcl|jcw|jmt|jmx|jqz|htm|html)$/', $file)) {
- $hp->references[] = "$xml_quiz->reference/$file";
- }
- }
- closedir($dh);
-
- // get titles
- foreach ($hp->references as $i=>$reference) {
- $filepath = $xml_quiz->fileroot.'/'.$reference;
- hotpot_get_titles_and_next_ex($hp, $filepath);
- $hp->names[$i] = $hp->exercisetitle;
- $hp->summaries[$i] = $hp->exercisesubtitle;
- }
-
- } else {
- $ok = false;
- $hp->errors['reference'] = get_string('error_couldnotopenfolder', 'hotpot', $hp->reference);
- }
-
- } else if (is_file($xml_quiz->filepath)) {
-
- $filerootlength = strlen($xml_quiz->fileroot) + 1;
-
- while ($xml_quiz->filepath) {
- hotpot_get_titles_and_next_ex($hp, $xml_quiz->filepath, true);
- $hp->names[] = $hp->exercisetitle;
- $hp->summaries[] = $hp->exercisesubtitle;
- $hp->references[] = substr($xml_quiz->filepath, $filerootlength);
-
- if ($hp->nextexercise) {
- $filepath = $xml_quiz->fileroot.'/'.$xml_quiz->filesubdir.$hp->nextexercise;
-
- // check file is not already in chain
- $reference = substr($filepath, $filerootlength);
- if (in_array($reference, $hp->references)) {
- $filepath = '';
- }
- } else {
- $filepath = '';
- }
- if ($filepath && file_exists($filepath) && is_file($filepath) && is_readable($filepath)) {
- $xml_quiz->filepath = $filepath;
- } else {
- $xml_quiz->filepath = false; // finish while loop
- }
- } // end while
-
- } else {
- $ok = false;
- $hp->errors['reference'] = get_string('error_notfileorfolder', 'hotpot', $hp->reference);
- }
-
- if (empty($hp->references) && empty($hp->errors['reference'])) {
- $ok = false;
- $hp->errors['reference'] = get_string('error_noquizzesfound', 'hotpot', $hp->reference);
- }
-
- if ($ok) {
- $hp->visible = HOTPOT_YES;
-
- if (trim($hp->name)=='') {
- $hp->name = get_string("modulename", $hp->modulename);
- }
- $hp->specificname = $hp->name;
- $hp->specificsummary = $hp->summary;
-
- // add all except last activity in chain
-
- $i_max = count($hp->references)-1;
- for ($i=0; $i<$i_max; $i++) {
-
- hotpot_set_name_summary_reference($hp, $i);
- $hp->reference = addslashes($hp->reference);
-
- if (!$hp->instance = insert_record("hotpot", $hp)) {
- error("Could not add a new instance of $hp->modulename", "view.php?id=$hp->course");
- }
-
- // store (hotpot table) id of start of chain
- if ($i==0) {
- $hp->startofchain = $hp->instance;
- }
-
- if (isset($course->groupmode)) {
- $hp->groupmode = $course->groupmode;
- }
-
- if (! $hp->coursemodule = add_course_module($hp)) {
- error("Could not add a new course module");
- }
- if (! $sectionid = add_mod_to_section($hp) ) {
- error("Could not add the new course module to that section");
- }
-
- if (! set_field("course_modules", "section", $sectionid, "id", $hp->coursemodule)) {
- error("Could not update the course module with the correct section");
- }
-
- add_to_log($hp->course, "course", "add mod",
- "../mod/$hp->modulename/view.php?id=$hp->coursemodule",
- "$hp->modulename $hp->instance"
- );
- add_to_log($hp->course, $hp->modulename, "add",
- "view.php?id=$hp->coursemodule",
- "$hp->instance", $hp->coursemodule
- );
-
- // hide tail of chain
- if ($hp->shownextquiz==HOTPOT_YES) {
- $hp->visible = HOTPOT_NO;
- }
- } // end for ($hp->references)
-
- // settings for final activity in chain
- hotpot_set_name_summary_reference($hp, $i);
- $hp->reference = addslashes($hp->references[$i]);
- $hp->shownextquiz = HOTPOT_NO;
-
- if (isset($hp->startofchain)) {
- // redirection only works for Moodle 1.5+
- $hp->redirect = true;
- $hp->redirecturl = "$CFG->wwwroot/mod/hotpot/view.php?hp=$hp->startofchain";
- }
- } // end if $ok
-
- return $ok;
-}
-function hotpot_set_name_summary_reference(&$hp, $chain_index=NULL) {
-
- $xml_quiz = NULL;
-
- $textfields = array('name', 'summary');
- foreach ($textfields as $textfield) {
-
- $textsource = $textfield.'source';
-
- // are we adding a chain?
- if (isset($chain_index)) {
-
- switch ($hp->$textsource) {
- case HOTPOT_TEXTSOURCE_QUIZ:
- if ($textfield=='name') {
- $hp->exercisetitle = $hp->names[$chain_index];
- } else if ($textfield=='summary') {
- $hp->exercisesubtitle = $hp->summaries[$chain_index];
- }
- break;
- case HOTPOT_TEXTSOURCE_SPECIFIC:
- $specifictext = 'specific'.$textfield;
- if (empty($hp->$specifictext) && trim($hp->$specifictext)=='') {
- $hp->$textfield = '';
- } else {
- $hp->$textfield = $hp->$specifictext.' ('.($chain_index+1).')';
- }
- break;
- }
- $hp->reference = $hp->references[$chain_index];
- }
-
- if ($hp->$textsource==HOTPOT_TEXTSOURCE_QUIZ) {
- if (empty($xml_quiz) && !isset($chain_index)) {
- $xml_quiz = new hotpot_xml_quiz($hp, false, false, false, false, false);
- hotpot_get_titles_and_next_ex($hp, $xml_quiz->filepath);
- }
- if ($textfield=='name') {
- $hp->$textfield = addslashes($hp->exercisetitle);
- } else if ($textfield=='summary') {
- $hp->$textfield = addslashes($hp->exercisesubtitle);
- }
- }
- switch ($hp->$textsource) {
- case HOTPOT_TEXTSOURCE_FILENAME:
- $hp->$textfield = basename($hp->reference);
- break;
- case HOTPOT_TEXTSOURCE_FILEPATH:
- $hp->$textfield = '';
- // continue to next lines
- default:
- if (empty($hp->$textfield)) {
- $hp->$textfield = str_replace('/', ' ', $hp->reference);
- }
- } // end switch
- } // end foreach
-}
-function hotpot_get_titles_and_next_ex(&$hp, $filepath, $get_next=false) {
-
- $hp->exercisetitle = '';
- $hp->exercisesubtitle = '';
- $hp->nextexercise = '';
-
- // read the quiz file source
- if ($source = file_get_contents($filepath)) {
-
- $next = '';
- $title = '';
- $subtitle = '';
-
- if (preg_match('|\.html?$|', $filepath)) {
- // html file
- if (preg_match('|
]*class="ExerciseTitle"[^>]*>(.*?)
|is', $source, $matches)) {
- $title = trim(strip_tags($matches[1]));
- }
- if (empty($title)) {
- if (preg_match('|]*>(.*?)|is', $source, $matches)) {
- $title = trim(strip_tags($matches[1]));
- }
- }
- if (preg_match('|]*class="ExerciseSubtitle"[^>]*>(.*?)
|is', $source, $matches)) {
- $subtitle = trim(strip_tags($matches[1]));
- }
- if ($get_next) {
- if (preg_match('|]*class="NavButtonBar"[^>]*>(.*?)
|is', $source, $matches)) {
- $navbuttonbar = $matches[1];
- if (preg_match_all('|