set_url('/mod/hotpot/report.php', array('id'=>$id));
- if (! $cm = get_coursemodule_from_id('hotpot', $id)) {
- print_error('invalidcoursemodule');
- }
- if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
- print_error('coursemisconf');
- }
- if (! $hotpot = $DB->get_record("hotpot", array("id"=>$cm->instance))) {
- print_error('invalidhotpotid', 'hotpot');
- }
-
- } else {
- $PAGE->set_url('/mod/hotpot/report.php', array('hp'=>$hp));
- if (! $hotpot = $DB->get_record("hotpot", array("id"=>$hp))) {
- print_error('invalidhotpotid', 'hotpot');
- }
- if (! $course = $DB->get_record("course", array("id"=>$hotpot->course))) {
- print_error('coursemisconf');
- }
- if (! $cm = get_coursemodule_from_instance("hotpot", $hotpot->id, $course->id)) {
- print_error('invalidcoursemodule');
- }
- }
-
- // get the roles context for this course
- $sitecontext = get_context_instance(CONTEXT_SYSTEM);
- $modulecontext = get_context_instance(CONTEXT_MODULE, $cm->id);
-
- // set homeurl of couse (for error messages)
- $course_homeurl = "$CFG->wwwroot/course/view.php?id=$course->id";
-
- require_login($course, true, $cm);
-
- // get report mode
- if (has_capability('mod/hotpot:viewreport',$modulecontext)) {
- $mode = optional_param('mode', 'overview', PARAM_ALPHA);
- } else {
- // ordinary students have no choice
- $mode = 'overview';
- }
-
- // assemble array of form data
- $formdata = array(
- 'mode' => $mode,
- 'reportusers' => has_capability('mod/hotpot:viewreport',$modulecontext) ? optional_param('reportusers', get_user_preferences('hotpot_reportusers', 'allusers'), PARAM_ALPHANUM) : 'this',
- 'reportattempts' => optional_param('reportattempts', get_user_preferences('hotpot_reportattempts', 'all'), PARAM_ALPHA),
- 'reportformat' => optional_param('reportformat', 'htm', PARAM_ALPHA),
- 'reportshowlegend' => optional_param('reportshowlegend', get_user_preferences('hotpot_reportshowlegend', '0'), PARAM_INT),
- 'reportencoding' => optional_param('reportencoding', get_user_preferences('hotpot_reportencoding', ''), PARAM_ALPHANUM),
- 'reportwrapdata' => optional_param('reportwrapdata', get_user_preferences('hotpot_reportwrapdata', '1'), PARAM_INT),
- );
-
- foreach ($formdata as $name=>$value) {
- set_user_preference("hotpot_$name", $value);
- }
-
-/// Start the report
-
- add_to_log($course->id, "hotpot", "report", "report.php?id=$cm->id&mode=$mode", "$hotpot->id", "$cm->id");
-
- // print page header. if required
- if ($formdata['reportformat']=='htm') {
- hotpot_print_report_heading($course, $cm, $hotpot, $mode);
- if (has_capability('mod/hotpot:viewreport',$modulecontext)) {
- hotpot_print_report_selector($course, $hotpot, $formdata);
- }
- }
-
- // delete selected attempts, if any
- if (has_capability('mod/hotpot:deleteattempt',$modulecontext)) {
- $del = optional_param('del', '', PARAM_ALPHA);
- hotpot_delete_selected_attempts($hotpot, $del);
- }
-
- // check for groups
- if (preg_match('/^group(\d*)$/', $formdata['reportusers'], $matches)) {
- $formdata['reportusers'] = 'group';
- $formdata['reportgroupid'] = 0;
- // validate groupid
- if ($groups = groups_get_all_groups($course->id)) {
- if (isset($groups[$matches[1]])) {
- $formdata['reportgroupid'] = $matches[1];
- }
- }
- }
-
- $user_ids = '';
- $users = array();
-
- switch ($formdata['reportusers']) {
-
- case 'allusers':
- // anyone who has ever attempted this hotpot
- if ($records = $DB->get_records('hotpot_attempts', array('hotpot'=>$hotpot->id), '', 'id,userid')) {
- foreach ($records as $record) {
- $users[$record->userid] = 0; // "0" means user is NOT currently allowed to attempt this HotPot
- }
- unset($records);
- }
- break;
-
- case 'group':
- // group members
- if ($members = groups_get_members($formdata['reportgroupid'])) {
- foreach ($members as $memberid=>$unused) {
- $users[$memberid] = 1; // "1" signifies currently recognized participant
- }
- }
- break;
-
- case 'allparticipants':
- // anyone currently allowed to attempt this HotPot
- if ($records = hotpot_get_users_by_capability($modulecontext, 'mod/hotpot:attempt')) {
- foreach ($records as $record) {
- $users[$record->id] = 1; // "1" means user is allowed to do this HotPot
- }
- unset($records);
- }
- break;
-
- case 'existingstudents':
- // anyone currently allowed to attempt this HotPot who is not a teacher
- $teachers = hotpot_get_users_by_capability($modulecontext, 'mod/hotpot:viewreport');
- if ($records = hotpot_get_users_by_capability($modulecontext, 'mod/hotpot:attempt')) {
- foreach ($records as $record) {
- if (empty($teachers[$record->id])) {
- $users[$record->id] = 1;
- }
- }
- unset($records);
- }
- break;
-
- case 'this': // current user only
- $user_ids = $USER->id;
- break;
-
- default: // specific user selected by teacher
- if (is_numeric($formdata['reportusers'])) {
- $user_ids = $formdata['reportusers'];
- }
- }
- if (empty($user_ids) && count($users)) {
- ksort($users);
- $user_ids = join(',', array_keys($users));
- }
- if (empty($user_ids)) {
- echo $OUTPUT->heading(get_string('nousersyet'));
- echo $OUTPUT->footer();
- exit;
- }
-
- // database table and selection conditions
- $table = "{hotpot_attempts} a";
- $select = "a.hotpot=:hotpotid AND a.userid IN ($user_ids)";
- if ($mode!='overview') {
- $select .= ' AND a.status<>'.HOTPOT_STATUS_INPROGRESS;
- }
- $params = array('hotpotid'=>$hotpot->id);
-
- // confine attempts if necessary
- switch ($formdata['reportattempts']) {
- case 'best':
- $function = 'MAX';
- $fieldnames = array('score', 'id', 'clickreportid');
- $defaultvalue = 0;
- break;
- case 'first':
- $function = 'MIN';
- $fieldnames = array('timefinish', 'id', 'clickreportid');
- $default_value = time();
- break;
- case 'last':
- $function = 'MAX';
- $fieldnames = array('timefinish', 'id', 'clickreportid');
- $defaultvalue = time();
- break;
- default: // 'all' and any others
- $function = '';
- $fieldnames = array();
- $defaultvalue = '';
- break;
- }
- if (empty($function) || empty($fieldnames)) {
- // do nothing (i.e. get ALL attempts)
- } else {
- $groupby = 'userid';
- $records = hotpot_get_records_groupby($function, $fieldnames, $table, $select, $params, $groupby);
-
- $select = '';
- $params = array();
- if ($records) {
- $ids = array();
- foreach ($records as $record) {
- $ids[] = $record->clickreportid;
- }
- if (count($ids)) {
- $select = "a.clickreportid IN (".join(',', $ids).")";
- }
- }
- }
-
- // pick out last attempt in each clickreport series
- if ($select) {
- $cr_attempts = hotpot_get_records_groupby('MAX', array('timefinish', 'id'), $table, $select, $params, 'clickreportid');
- } else {
- $cr_attempts = array();
- }
-
- $fields = 'a.*, u.firstname, u.lastname, u.picture';
- if ($mode=='click') {
- $fields .= ', u.idnumber';
- } else {
- // overview, simple and detailed reports
- // get last attempt record in clickreport series
- $ids = array();
- foreach ($cr_attempts as $cr_attempt) {
- $ids[] = $cr_attempt->id;
- }
- if (empty($ids)) {
- $select = "";
- } else {
- $ids = array_unique($ids);
- sort($ids);
- $select = "a.id IN (".join(',', $ids).")";
- }
- $params = array();
- }
-
- $attempts = array();
-
- if ($select) {
- // add user information to SQL query
- $select .= ' AND a.userid = u.id';
- $table .= ", {user} u";
- $order = "u.lastname, a.attempt, a.timefinish";
- // get the attempts (at last!)
- $attempts = $DB->get_records_sql("SELECT $fields FROM $table WHERE $select ORDER BY $order", $params);
- }
-
- // stop now if no attempts were found
- if (empty($attempts)) {
- echo $OUTPUT->heading(get_string('noattemptstoshow','quiz'));
- echo $OUTPUT->footer();
- exit;
- }
-
- // get the questions
- if (!$questions = $DB->get_records('hotpot_questions', array('hotpot'=>$hotpot->id))) {
- $questions = array();
- }
-
- // get grades
- $grades = hotpot_get_grades($hotpot, $user_ids);
-
- // get list of attempts by user and set reference to last attempt in clickreport series
- $users = array();
- foreach ($attempts as $id=>$attempt) {
-
- $userid = $attempt->userid;
-
- if (!isset($users[$userid])) {
- $users[$userid]->grade = isset($grades[$userid]) ? $grades[$userid] : ' ';
- $users[$userid]->attempts = array();
- }
-
- $users[$userid]->attempts[] = &$attempts[$id];
-
- if ($mode=='click') {
- // shortcut to clickreportid (=the id of the FIRST attempt in this clickreport series)
- $clickreportid = $attempt->clickreportid;
- if (isset($cr_attempts[$clickreportid])) {
- // store id and finish time of LAST attempt in this clickreport series
- $attempts[$id]->cr_lastclick = $cr_attempts[$clickreportid]->id;
- $attempts[$id]->cr_timefinish = $cr_attempts[$clickreportid]->timefinish;
- }
- }
- }
-
- if ($mode!='overview') {
-
- // initialise details of responses to questions in these attempts
- foreach ($attempts as $a=>$attempt) {
- $attempts[$a]->responses = array();
- }
- foreach ($questions as $q=>$question) {
- $questions[$q]->attempts = array();
- }
-
- // get reponses to these attempts
- $attempt_ids = join(',',array_keys($attempts));
- if (!$responses = $DB->get_records_sql("SELECT * FROM {hotpot_responses} WHERE attempt IN ($attempt_ids)")) {
- $responses = array();
- }
-
- // ids of questions used in these responses
- $questionids = array();
-
- foreach ($responses as $response) {
- // shortcuts to the attempt and question ids
- $a = $response->attempt;
- $q = $response->question;
-
- // check the attempt and question objects exist
- // (if they don't exist, something is very wrong!)
- if (isset($attempts[$a]) || isset($questions[$q])) {
-
- // add the response for this attempt
- $attempts[$a]->responses[$q] = $response;
-
- // add a reference from the question to the attempt which includes this question
- $questions[$q]->attempts[] = &$attempts[$a];
-
- // flag this id as being used
- $questionids[$q] = true;
- }
- }
-
- // remove unused questions
- $questionids = array_keys($questionids);
- foreach ($questions as $id=>$question) {
- if (!in_array($id, $questionids)) {
- unset($questions[$id]);
- }
- }
- }
-
-/// Open the selected hotpot report and display it
-
- if (! is_readable("report/$mode/report.php")) {
- print_error('unknownreport', 'hotpot', $course_homeurl, clean_text($mode));
- }
-
- include("report/default.php"); // Parent class
- include("report/$mode/report.php");
-
- $report = new hotpot_report();
-
- if (! $report->display($hotpot, $cm, $course, $users, $attempts, $questions, $formdata)) {
- print_error('error_processreport', 'hotpot', $course_homeurl);
- }
-
- if ($formdata['reportformat']=='htm') {
- echo $OUTPUT->footer();
- }
-
-//////////////////////////////////////////////
-/// functions to delete attempts and responses
-
-function hotpot_grade_heading($hotpot, $formdata) {
-
- global $HOTPOT_GRADEMETHOD;
- $grademethod = $HOTPOT_GRADEMETHOD[$hotpot->grademethod];
-
- if ($hotpot->grade!=100) {
- $grademethod = "$hotpot->grade x $grademethod/100";
- }
- if ($formdata['reportformat']=='htm') {
- $grademethod = ''.$grademethod.'';
- }
- $nl = $formdata['reportformat']=='htm' ? '
' : "\n";
- return get_string('grade')."$nl($grademethod)";
-}
-function hotpot_delete_selected_attempts(&$hotpot, $del) {
- global $DB;
-
- $select = '';
- $params = array('hotpotid'=>$hotpot->id);
- switch ($del) {
- case 'all' :
- $select = "hotpot=:hotpotid";
- break;
- case 'abandoned':
- $select = "hotpot=:hotpotid AND status=".HOTPOT_STATUS_ABANDONED;
- break;
- case 'selection':
- $ids = array();
- $data = (array)data_submitted();
- foreach ($data as $name => $value) {
- if (preg_match('/^box\d+$/', $name)) {
- $ids[] = intval($value);
- }
- }
- if (count($ids)) {
- list($ids, $idparams) = $DB->get_in_or_equal($ids, SQL_PARAMS_NAMED, 'crid0');
- $params = array_merge($params, $idparams);
- $select = "hotpot=:hotpotid AND clickreportid $ids";
- }
- break;
- }
-
- // delete attempts using $select, if it is set
- if ($select) {
-
- $table = 'hotpot_attempts';
- if ($attempts = $DB->get_records_select($table, $select, $params)) {
-
- hotpot_delete_and_notify($table, $select, $params, get_string('attempts', 'quiz'));
-
- $select = 'attempt IN ('.implode(',', array_keys($attempts)).')';
- $params = array();
- hotpot_delete_and_notify('hotpot_details', $select, $params, get_string('rawdetails', 'hotpot'));
- hotpot_delete_and_notify('hotpot_responses', $select, $params, get_string('answer', 'quiz'));
-
- // update grades for all users for this hotpot
- hotpot_update_grades($hotpot);
- }
- }
-
-}
-
-//////////////////////////////////////////////
-/// functions to print the report headings and
-/// report selector menus
-
-function hotpot_print_report_heading(&$course, &$cm, &$hotpot, &$mode) {
- global $OUTPUT;
- $strmodulenameplural = get_string("modulenameplural", "hotpot");
- $strmodulename = get_string("modulename", "hotpot");
-
- $modulecontext = get_context_instance(CONTEXT_MODULE, $cm->id);
- if (has_capability('mod/hotpot:viewreport',$modulecontext)) {
- if ($mode=='overview' || $mode=='simplestat' || $mode=='fullstat') {
- $module = "quiz";
- } else {
- $module = "hotpot";
- }
-
- $PAGE->navbar->add(get_string("report$mode", $module));
- } else {
- $PAGE->navbar->add(get_string("report", "quiz"));
- }
-
- $PAGE->set_title(format_string($course->shortname) . ": $hotpot->name");
- $PAGE->set_heading($course->fullname);
- echo $OUTPUT->header();
-
- $course_context = get_context_instance(CONTEXT_COURSE, $course->id);
- if (has_capability('gradereport/grader:view', $course_context) && has_capability('moodle/grade:viewall', $course_context)) {
- echo '';
- }
- echo $OUTPUT->heading($hotpot->name);
-}
-function hotpot_print_report_selector(&$course, &$hotpot, &$formdata) {
- global $CFG, $DB, $OUTPUT;
-
- $reports = hotpot_get_report_names('overview,simplestat,fullstat');
-
- print ''."\n";
-}
-function hotpot_get_report_names($names='') {
- // $names : optional list showing required order reports names
-
- $reports = array();
-
- // convert $names to an array, if necessary (usually is)
- if (!is_array($names)) {
- $names = explode(',', $names);
- }
-
- $plugins = get_list_of_plugins('mod/hotpot/report');
- foreach($names as $name) {
- if (is_numeric($i = array_search($name, $plugins))) {
- $reports[] = $name;
- unset($plugins[$i]);
- }
- }
-
- // append remaining plugins
- $reports = array_merge($reports, $plugins);
-
- return $reports;
-}
-
-function hotpot_get_records_groupby($function, $fieldnames, $table, $select, $params, $groupby) {
- // $function is an SQL aggregate function (MAX or MIN)
- global $DB;
-
- $fields = $DB->sql_concat_join("'_'", $fieldnames);
- $fields = "$groupby, $function($fields) AS joinedvalues";
-
- if ($fields) {
- $records = $DB->get_records_sql("SELECT $fields FROM $table WHERE $select GROUP BY $groupby", $params);
- }
-
- if (empty($fields) || empty($records)) {
- $records = array();
- }
-
- $fieldcount = count($fieldnames);
-
- foreach ($records as $id=>$record) {
- if (empty($record->joinedvalues)) {
- unset($records[$id]);
- } else {
- $values = explode('_', $record->joinedvalues);
-
- for ($i=0; $i<$fieldcount; $i++) {
- $fieldname = $fieldnames[$i];
- $records[$id]->$fieldname = $values[$i];
- }
- }
- unset($record->joinedvalues);
- }
-
- return $records;
-}
-function hotpot_get_users_by_capability(&$modulecontext, $capability) {
- static $users = array();
- if (! array_key_exists($capability, $users)) {
- $users[$capability] = get_users_by_capability($modulecontext, $capability, 'u.id,u.id', 'u.id');
- }
- return $users[$capability];
-}
-
diff --git a/mod/hotpot/report/click/report.php b/mod/hotpot/report/click/report.php
deleted file mode 100644
index 33e13202b89..00000000000
--- a/mod/hotpot/report/click/report.php
+++ /dev/null
@@ -1,542 +0,0 @@
-create_clickreport_table($hotpot, $cm, $course, $users, $attempts, $questions, $options, $tables);
- // print the tables
- $this->print_report($course, $hotpot, $tables, $options);
- return true;
- }
- function create_clickreport_table(&$hotpot, &$cm, &$course, &$users, &$attempts, &$questions, &$options, &$tables) {
- global $CFG;
- $is_html = ($options['reportformat']=='htm');
- // time and date format strings // date format strings
- $strftimetime = '%H:%M:%S';
- $strftimedate = get_string('strftimedate');
- // get the current time and max execution time
- $start_report_time = microtime();
- $max_execution_time = ini_get('max_execution_time');
- $correct = get_string('reportcorrectsymbol', 'hotpot');
- $wrong = get_string('reportwrongsymbol', 'hotpot');
- $nottried = get_string('reportnottriedsymbol', 'hotpot');
- // shortcuts for font tags
- $blank = $is_html ? ' ' : "";
- // store question count
- $questioncount = count($questions);
- // array to map columns onto question ids ($col => $id)
- $questionids = array_keys($questions);
- // store exercise type
- $exercisetype = $this->get_exercisetype($questions, $questionids, $blank);
- // initialize details ('events' must go last)
- $details = array('checks', 'status', 'answers', 'changes', 'hints', 'clues', 'events');
- // initialize $table
- unset($table);
- $table->border = 1;
- $table->width = '100%';
- // initialize legend, if necessary
- if (!empty($options['reportshowlegend'])) {
- $table->legend = array();
- }
- // start $table headings
- $this->set_head($options, $table, 'exercise');
- $this->set_head($options, $table, 'user');
- $this->set_head($options, $table, 'attempt');
- $this->set_head($options, $table, 'click');
- // store clicktype column number
- $clicktype_col = count($table->head)-1;
- // finish $table headings
- $this->set_head($options, $table, 'details', $exercisetype, $details, $questioncount);
- $this->set_head($options, $table, 'totals', $exercisetype);
- // set align and wrap
- $this->set_align_and_wrap($table);
- // is link to review allowed?
- $allow_review = ($is_html && (has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $course->id)) || $hotpot->review));
- // initialize array of data values
- $this->data = array();
- // set exercise data values
- $this->set_data_exercise($cm, $course, $hotpot, $questions, $questionids, $questioncount, $blank);
- // add details of users' responses
- foreach ($users as $user) {
- $this->set_data_user($options, $course, $user);
- unset($clickreportid);
- foreach ($user->attempts as $attempt) {
- // initialize totals for
- $click = array(
- 'qnumber' => array(),
- 'correct' => array(),
- 'wrong' => array(),
- 'answers' => array(),
- 'hints' => array(),
- 'clues' => array(),
- 'changes' => array(),
- 'checks' => array(),
- 'events' => array(),
- 'score' => array(),
- 'weighting' => array()
- );
- $clicktypes = array();
- // is the start of a new attempt?
- // (clicks in the same attempt have the same clickreportid)
- if (!isset($clickreportid) || $clickreportid != $attempt->clickreportid) {
- $clickcount = 1;
- $clickreportid = $attempt->clickreportid;
- // initialize totals for all clicks in this attempt
- $clicks = $click; // $click has just been initialized
- $this->set_data_attempt($attempt, $strftimedate, $strftimetime, $blank);
- }
- $cells = array();
- $this->set_data($cells, 'exercise');
- $this->set_data($cells, 'user');
- $this->set_data($cells, 'attempt');
- // get responses to questions in this attempt
- foreach ($attempt->responses as $response) {
- // set $q(uestion number)
- $q = array_search($response->question, $questionids);
- $click['qnumber'][$q] = true;
- // was this question answered correctly?
- if ($answer = hotpot_strings($response->correct)) {
- // mark the question as correctly answered
- if (empty($clicks['correct'][$q])) {
- $click['correct'][$q] = true;
- $clicks['correct'][$q] = true;
- }
- // unset 'wrong' flags, if necessary
- if (isset($click['wrong'][$q])) {
- unset($click['wrong'][$q]);
- }
- if (isset($clicks['wrong'][$q])) {
- unset($clicks['wrong'][$q]);
- }
- // otherwise, was the question answered wrongly?
- } else if ($answer = hotpot_strings($response->wrong)) {
- // mark the question as wrongly answered
- $click['wrong'][$q] = true;
- $clicks['wrong'][$q] = true;
- } else { // not correct or wrong (curious?!)
- unset($answer);
- }
- if (!empty($click['correct'][$q]) || !empty($click['wrong'][$q])) {
- $click['score'][$q] = $response->score;
- $clicks['score'][$q] = $response->score;
- $weighting = isset($response->weighting) ? $response->weighting : 100;
- $click['weighting'][$q] = $weighting;
- $clicks['weighting'][$q] =$weighting;
- }
- foreach($details as $detail) {
- switch ($detail) {
- case 'answers':
- if (isset($answer) && is_string($answer) && !empty($answer)) {
- $click[$detail][$q] = $answer;
- }
- break;
- case 'hints':
- case 'clues':
- case 'checks':
- if (isset($response->$detail) && is_numeric($response->$detail) && $response->$detail>0) {
- if (!isset($click[$detail][$q]) || $click[$detail][$q] < $response->$detail) {
- $click[$detail][$q] = $response->$detail;
- }
- }
- break;
- }
- } // end foreach $detail
- } // end foreach $response
- $click['types'] = array();
- $this->data['details'] = array();
- foreach($details as $detail) {
- for ($q=0; $q<$questioncount; $q++) {
- switch ($detail) {
- case 'status':
- if (isset($clicks['correct'][$q])) {
- $this->data['details'][] = $correct;
- } else if (isset($clicks['wrong'][$q])) {
- $this->data['details'][] = $wrong;
- } else if (isset($click['qnumber'][$q])) {
- $this->data['details'][] = $nottried;
- } else { // this question did not appear in this attempt
- $this->data['details'][] = $blank;
- }
- break;
- case 'answers':
- case 'hints':
- case 'clues':
- case 'checks':
- if (!isset($clicks[$detail][$q])) {
- if (!isset($click[$detail][$q])) {
- $this->data['details'][] = $blank;
- } else {
- $clicks[$detail][$q] = $click[$detail][$q];
- if ($detail=='answers') {
- $this->set_legend($table, $q, $click[$detail][$q], $questions[$questionids[$q]]);
- }
- $this->data['details'][] = $click[$detail][$q];
- $this->update_event_count($click, $detail, $q);
- }
- } else {
- if (!isset($click[$detail][$q])) {
- $this->data['details'][] = $blank;
- } else {
- $difference = '';
- if ($detail=='answers') {
- if ($click[$detail][$q] != $clicks[$detail][$q]) {
- $pattern = '/^'.preg_quote($clicks[$detail][$q], '/').',/';
- $difference = preg_replace($pattern, '', $click[$detail][$q], 1);
- }
- } else { // hints, clues, checks
- if ($click[$detail][$q] > $clicks[$detail][$q]) {
- $difference = $click[$detail][$q] - $clicks[$detail][$q];
- }
- }
- if ($difference) {
- $clicks[$detail][$q] = $click[$detail][$q];
- $click[$detail][$q] = $difference;
- if ($detail=='answers') {
- $this->set_legend($table, $q, $difference, $questions[$questionids[$q]]);
- }
- $this->data['details'][] = $difference;
- $this->update_event_count($click, $detail, $q);
- } else {
- unset($click[$detail][$q]);
- $this->data['details'][] = $blank;
- }
- }
- }
- break;
- case 'changes':
- case 'events':
- if (empty($click[$detail][$q])) {
- $this->data['details'][] = $blank;
- } else {
- $this->data['details'][] = $click[$detail][$q];
- }
- break;
- default:
- // do nothing
- break;
- } // end switch
- } // for $q
- } // foreach $detail
- // set data cell values for
- $this->set_data_click(
- $allow_review ? ''.$clickcount.'' : $clickcount,
- trim(userdate($attempt->timefinish, $strftimetime)),
- $exercisetype,
- $click
- );
- $this->set_data($cells, 'click');
- $this->set_data($cells, 'details');
- $this->set_data_totals($click, $clicks, $questioncount, $blank, $attempt);
- $this->set_data($cells, 'totals');
- $table->data[] = $cells;
- $clickcount++;
- } // end foreach $attempt
- // insert 'tabledivider' between users
- $table->data[] = 'hr';
- } // end foreach $user
- // remove final 'hr' from data rows
- array_pop($table->data);
- if ($is_html && $CFG->hotpot_showtimes) {
- $count = count($users);
- $duration = sprintf("%0.3f", microtime_diff($start_report_time, microtime()));
- print "$count users processed in $duration seconds (".sprintf("%0.3f", $duration/$count).' secs/user)
'."\n";
- }
- $tables[] = &$table;
- $this->create_legend_table($tables, $table);
- } // end function
- function get_exercisetype(&$questions, &$questionids, &$blank) {
- if (empty($questions)) {
- $type = $blank;
- } else {
- switch ($questions[$questionids[0]]->type) {
- case HOTPOT_JCB:
- $type = "JCB";
- break;
- case HOTPOT_JCLOZE :
- $type = "JCloze";
- break;
- case HOTPOT_JCROSS :
- $type = "JCross";
- break;
- case HOTPOT_JMATCH :
- $type = "JMatch";
- break;
- case HOTPOT_JMIX :
- $type = "JMix";
- break;
- case HOTPOT_JQUIZ :
- $type = "JQuiz";
- break;
- case HOTPOT_TEXTOYS_RHUBARB :
- $type = "Rhubarb";
- break;
- case HOTPOT_TEXTOYS_SEQUITUR :
- $type = "Sequitur";
- break;
- default:
- $type = $blank;
- }
- }
- return $type;
- }
- function set_head(&$options, &$table, $zone, $exercisetype='', $details=array(), $questioncount=0) {
- if (empty($table->head)) {
- $table->head = array();
- }
- switch ($zone) {
- case 'exercise':
- array_push($table->head,
- get_string('reportcoursename', 'hotpot'),
- get_string('reportsectionnumber', 'hotpot'),
- get_string('reportexercisenumber', 'hotpot'),
- get_string('reportexercisename', 'hotpot'),
- get_string('reportexercisetype', 'hotpot'),
- get_string('reportnumberofquestions', 'hotpot')
- );
- break;
- case 'user':
- array_push($table->head,
- get_string('reportstudentid', 'hotpot'),
- get_string('reportlogindate', 'hotpot'),
- get_string('reportlogintime', 'hotpot'),
- get_string('reportlogofftime', 'hotpot')
- );
- break;
- case 'attempt':
- array_push($table->head,
- get_string('reportattemptnumber', 'hotpot'),
- get_string('reportattemptstart', 'hotpot'),
- get_string('reportattemptfinish', 'hotpot')
- );
- break;
- case 'click':
- array_push($table->head,
- get_string('reportclicknumber', 'hotpot'),
- get_string('reportclicktime', 'hotpot'),
- get_string('reportclicktype', 'hotpot')
- );
- break;
- case 'details':
- foreach($details as $detail) {
- if ($exercisetype=='JQuiz' && $detail=='clues') {
- $detail = 'showanswer';
- }
- $detail = get_string("report$detail", 'hotpot');
- for ($i=0; $i<$questioncount; $i++) {
- $str = get_string('questionshort', 'hotpot', $i+1);
- if ($i==0 || $options['reportformat']!='htm') {
- $str = "$detail $str";
- }
- $table->head[] = $str;
- }
- }
- break;
- case 'totals':
- $reportpercentscore =get_string('reportpercentscore', 'hotpot');
- if (!function_exists('clean_getstring_data')) { // Moodle 1.4 (and less)
- $reportpercentscore = str_replace('%', '%%', $reportpercentscore);
- }
- array_push($table->head,
- get_string('reportthisclick', 'hotpot', get_string('reportquestionstried', 'hotpot')),
- get_string('reportsofar', 'hotpot', get_string('reportquestionstried', 'hotpot')),
- get_string('reportthisclick', 'hotpot', get_string('reportright', 'hotpot')),
- get_string('reportthisclick', 'hotpot', get_string('reportwrong', 'hotpot')),
- get_string('reportthisclick', 'hotpot', get_string('reportnottried', 'hotpot')),
- get_string('reportsofar', 'hotpot', get_string('reportright', 'hotpot')),
- get_string('reportsofar', 'hotpot', get_string('reportwrong', 'hotpot')),
- get_string('reportsofar', 'hotpot', get_string('reportnottried', 'hotpot')),
- get_string('reportthisclick', 'hotpot', get_string('reportanswers', 'hotpot')),
- get_string('reportthisclick', 'hotpot', get_string('reporthints', 'hotpot')),
- get_string('reportthisclick', 'hotpot', get_string($exercisetype=='JQuiz' ? 'reportshowanswer' : 'reportclues', 'hotpot')),
- get_string('reportthisclick', 'hotpot', get_string('reportevents', 'hotpot')),
- get_string('reportsofar', 'hotpot', get_string('reporthints', 'hotpot')),
- get_string('reportsofar', 'hotpot', get_string($exercisetype=='JQuiz' ? 'reportshowanswer' : 'reportclues', 'hotpot')),
- get_string('reportthisclick', 'hotpot', get_string('reportrawscore', 'hotpot')),
- get_string('reportthisclick', 'hotpot', get_string('reportmaxscore', 'hotpot')),
- get_string('reportthisclick', 'hotpot', $reportpercentscore),
- get_string('reportsofar', 'hotpot', get_string('reportrawscore', 'hotpot')),
- get_string('reportsofar', 'hotpot', get_string('reportmaxscore', 'hotpot')),
- get_string('reportsofar', 'hotpot', $reportpercentscore),
- get_string('reporthotpotscore', 'hotpot')
- );
- break;
- } // end switch
- }
- function set_align_and_wrap(&$table) {
- $count = count($table->head);
- for ($i=0; $i<$count; $i++) {
- if ($i==0 || $i==1 || $i==2 || $i==4 || $i==5 || $i>=7) {
- // numeric (and short text) columns
- $table->align[] = 'center';
- $table->wrap[] = '';
- } else {
- // text columns
- $table->align[] = 'left';
- $table->wrap[] = 'nowrap';
- }
- }
- }
- function set_data_exercise(&$cm, &$course, &$hotpot, &$questions, &$questionids, &$questioncount, &$blank) {
- global $DB;
-
- // get exercise details (course name, section number, activity number, quiztype and question count)
- $record = $DB->get_record("course_sections", array("id"=>$cm->section));
- $this->data['exercise'] = array(
- 'course' => $course->shortname,
- 'section' => empty($record) ? $blank : $record->section+1,
- 'number' => empty($record) ? $blank : array_search($cm->id, explode(',', $record->sequence))+1,
- 'name' => $hotpot->name,
- 'type' => $this->get_exercisetype($questions, $questionids, $blank),
- 'questioncount' => $questioncount
- );
- }
- function set_data_user(&$options, &$course, &$user) {
- global $CFG;
- // shortcut to first attempt record (which also hold user info)
- $attempt = &$user->attempts[0];
- $idnumber = $attempt->idnumber;
- if (empty($idnumber)) {
- $idnumber = fullname($attempt);
- }
- if ($options['reportformat']=='htm') {
- $idnumber = ''.$idnumber.'';
- }
- $this->data['user'] = array(
- 'idnumber' => $idnumber,
- );
- }
- function set_data_attempt(&$attempt, &$strftimedate, &$strftimetime, &$blank) {
- global $CFG, $DB;
- $records = $DB->get_records_sql_menu("
- SELECT userid, MAX(time) AS logintime
- FROM {log}
- WHERE userid=? AND action='login' AND time
- GROUP BY userid
- ", array($attempt->userid, $attempt->timestart));
- if (empty($records)) {
- $logindate = $blank;
- $logintime = $blank;
- } else {
- $logintime = $records[$attempt->userid];
- $logindate = trim(userdate($logintime, $strftimedate));
- $logintime = trim(userdate($logintime, $strftimetime));
- }
- $records = $DB->get_records_sql_menu("
- SELECT userid, MIN(time) AS logouttime
- FROM {log}
- WHERE userid=? AND action='logout' AND time>?
- GROUP BY userid
- ", array($attempt->userid, $attempt->cr_timefinish));
- if (empty($records)) {
- $logouttime = $blank;
- } else {
- $logouttime = $records[$attempt->userid];
- $logouttime = trim(userdate($logouttime, $strftimetime));
- }
- $this->data['attempt'] = array(
- 'logindate' => $logindate,
- 'logintime' => $logintime,
- 'logouttime' => $logouttime,
- 'number' => $attempt->attempt,
- 'start' => trim(userdate($attempt->timestart, $strftimetime)),
- 'finish' => trim(userdate($attempt->cr_timefinish, $strftimetime)),
- );
- }
- function set_data_click($number, $time, $exercisetype, $click) {
- $types = array();
- foreach (array_keys($click['types']) as $type) {
- if ($exercisetype=='JQuiz' && $type=='clues') {
- $type = 'showanswer';
- } else {
- // remove final 's'
- $type = substr($type, 0, strlen($type)-1);
- }
- // $types[] = get_string($type, 'hotpot');
- $types[] = $type;
- }
- $this->data['click'] = array(
- 'number' => $number,
- 'time' => $time,
- 'type' => empty($types) ? '??' : implode(',', $types)
- );
- }
- function set_data_totals(&$click, &$clicks, &$questioncount, &$blank, &$attempt) {
- $count= array(
- 'click' => array(
- 'correct' => count($click['correct']),
- 'wrong' => count($click['wrong']),
- 'answers' => count($click['answers']),
- 'hints' => array_sum($click['hints']),
- 'clues' => array_sum($click['clues']),
- 'events' => array_sum($click['events']),
- 'score' => array_sum($click['score']),
- 'maxscore' => array_sum($click['weighting']),
- ),
- 'clicks' => array(
- 'correct' => count($clicks['correct']),
- 'wrong' => count($clicks['wrong']),
- 'answers' => count($clicks['answers']),
- 'hints' => array_sum($clicks['hints']),
- 'clues' => array_sum($clicks['clues']),
- 'score' => array_sum($clicks['score']),
- 'maxscore' => array_sum($clicks['weighting']),
- )
- );
- foreach ($count as $period=>$values) {
- $count[$period]['nottried'] = $questioncount - ($values['correct'] + $values['wrong']);
- $count[$period]['percent'] = empty($values['maxscore']) ? $blank : round(100 * $values['score'] / $values['maxscore'], 0);
- // blank out zero click values
- if ($period=='click') {
- foreach ($values as $detail=>$value) {
- if ($detail=='answers' || $detail=='hints' || $detail=='clues' || $detail=='events') {
- if (empty($value)) {
- $count[$period][$detail] = $blank;
- }
- }
- }
- }
- }
- $this->data['totals'] = array(
- $count['click']['answers'], // "q's tried"
- $count['clicks']['answers'], // "q's tried so far"
- $count['click']['correct'], // "right"
- $count['click']['wrong'], // "wrong"
- $count['click']['nottried'], // "not tried"
- $count['clicks']['correct'], // "right so far"
- $count['clicks']['wrong'], // "wrong so far"
- $count['clicks']['nottried'], // "not tried so far"
- $count['click']['answers'], // "answers",
- $count['click']['hints'], // "hints",
- $count['click']['clues'], // "clues",
- $count['click']['events'], // "answers",
- $count['clicks']['hints'], // "hints so far",
- $count['clicks']['clues'], // "clues so far",
- $count['click']['score'], // 'raw score',
- $count['click']['maxscore'], // 'max score',
- $count['click']['percent'], // '% score'
- $count['clicks']['score'], // 'raw score,
- $count['clicks']['maxscore'], // 'max score,
- $count['clicks']['percent'], // '% score
- $attempt->score // 'hotpot score'
- );
- }
- function update_event_count(&$click, $detail, $q) {
- if ($detail=='checks' || $detail=='hints' || $detail=='clues') {
- $click['types'][$detail] = true;
- }
- if ($detail=='answers' || $detail=='hints' || $detail=='clues') {
- $click['events'][$q] = isset($click['events'][$q]) ? $click['events'][$q]+1 : 1;
- }
- if ($detail=='answers') {
- $click['changes'][$q] = isset($click['changes'][$q]) ? $click['changes'][$q]+1 : 1;
- }
- }
- function set_data(&$cells, $zone) {
- foreach ($this->data[$zone] as $name=>$value) {
- $cells[] = $value;
- }
- }
-} // end class
-
diff --git a/mod/hotpot/report/default.php b/mod/hotpot/report/default.php
deleted file mode 100644
index 37f1a97351a..00000000000
--- a/mod/hotpot/report/default.php
+++ /dev/null
@@ -1,851 +0,0 @@
-id" or q=$quiz->id", and "mode=reportname".
-////////////////////////////////////////////////////////////////////
-
-// Included by ../report.php
-
-class hotpot_default_report {
-
- function display($hotpot, $cm, $course, $users, $attempts, $questions, $options) {
- /// This function just displays the report
- // it is replaced by the "display" functions in the scripts in the "report" folder
- return true;
- }
-
- function add_question_headings(&$questions, &$table, $align='center', $size=50, $wrap=false, $fontsize=0) {
- $count = count($questions);
- for ($i=0; $i<$count; $i++) {
- $table->head[] = get_string('questionshort', 'hotpot', $i+1);
- if (isset($table->align)) {
- $table->align[] = $align;
- }
- if (isset($table->size)) {
- $table->size[] = $size;
- }
- if (isset($table->wrap)) {
- $table->wrap[] = $wrap;
- }
- if (isset($table->fontsize)) {
- $table->fontsize[] = $fontsize;
- }
- }
-
- }
-
- function set_legend(&$table, &$q, &$value, &$question) {
- // $q is the question number
- // $value is the value (=text) of the answer
-
- // check the legend is required
- if (isset($table->legend) && isset($value)) {
-
- // create question details array, if necessary
- if (empty($table->legend[$q])) {
- $table->legend[$q] = array(
- 'name' => hotpot_get_question_name($question),
- 'answers' => array()
- );
- }
-
- // search for this $value in answers array for this $q(uestion)
- $i_max = count($table->legend[$q]['answers']);
- for ($i=0; $i<$i_max; $i++) {
- if ($table->legend[$q]['answers'][$i]==$value) {
- break;
- }
- }
-
- // add $value to answers array, if it was not there
- if ($i==$i_max) {
- $table->legend[$q]['answers'][$i] = $value;
- }
-
- // convert $value to alphabetic index (A, B ... AA, AB ...)
- $value = $this->dec_to_ALPHA($i);
- }
- }
- function create_legend_table(&$tables, &$table) {
-
- if (isset($table->legend)) {
-
- $legend->width = '*';
- $legend->tablealign = '*';
- $legend->border = isset($table->border) ? $table->border : NULL;
- $legend->cellpadding = isset($table->cellpadding) ? $table->cellpadding : NULL;
- $legend->cellspacing = isset($table->cellspacing) ? $table->cellspacing : NULL;
- $legend->tableclass = isset($table->tableclass) ? $table->tableclass : NULL;
-
- $legend->caption = get_string('reportlegend', 'hotpot');
- $legend->align = array('right', 'left');
- $legend->statheadercols = array(0);
-
- $legend->stat = array();
-
- // put the questions in order
- ksort($table->legend);
-
- foreach($table->legend as $q=>$question) {
-
- $legend->stat[] = array(
- get_string('questionshort', 'hotpot', $q+1),
- $question['name']
- );
- foreach($question['answers'] as $a=>$answer) {
- $legend->stat[] = array(
- $this->dec_to_ALPHA($a),
- $answer
- );
- }
- }
-
- unset($table->legend);
- $tables[] = $legend;
- }
- }
- function dec_to_ALPHA($dec) {
- if ($dec < 26) {
- return chr(ord('A') + $dec);
- } else {
- return $this->dec_to_ALPHA(intval($dec/26)-1).$this->dec_to_ALPHA($dec % 26);
- }
- }
- function remove_column(&$table, $target_col) {
-
- if (is_array($table)) {
- unset($table[$target_col]);
- $table = array_values($table);
-
- } else if (is_object($table)) {
- $vars = get_object_vars($table);
- foreach ($vars as $name=>$value) {
- switch ($name) {
- case 'data' :
- case 'stat' :
- case 'foot' :
- $skipcol = array();
- $cells = &$table->$name;
-
- $row_max = count($cells);
- for ($row=0; $row<$row_max; $row++) {
-
- $col = 0;
- $col_max = count($cells[$row]);
-
- $current_col = 0;
- while ($current_col<$target_col && $col<$col_max) {
-
- if (empty($skipcol[$current_col])) {
-
- $cell = $cells[$row][$col++];
- if (is_object($cell)) {
- if (isset($cell->rowspan) && is_numeric($cell->rowspan) && ($cell->rowspan>0)) {
- // skip cells below this one
- $skipcol[$current_col] = $cell->rowspan-1;
- }
- if (isset($cell->colspan) && is_numeric($cell->colspan) && ($cell->colspan>0)) {
- // skip cells to the right of this one
- for ($c=1; $c<$cell->colspan; $c++) {
- if (empty($skipcol[$current_col+$c])) {
- $skipcol[$current_col+$c] = 1;
- } else {
- $skipcol[$current_col+$c] ++;
- }
- }
- }
- }
- } else {
- $skipcol[$current_col]--;
- }
- $current_col++;
- }
- if ($current_col==$target_col && $col<$col_max) {
- $this->remove_column($cells[$row], $col);
- }
- } // end for $row
- break;
- case 'head' :
- case 'align' :
- case 'class' :
- case 'fontsize' :
- case 'size' :
- case 'wrap' :
- $this->remove_column($table->$name, $target_col);
- break;
- case 'statheadercols' :
- $array = &$table->$name;
- $count = count($array);
- for ($i=0; $i<$count; $i++) {
- if ($array[$i]>=$target_col) {
- $array[$i] --;
- }
- }
- break;
- } // end switch
- } // end foreach
- } // end if
- } // end function
-
-
- function expand_spans(&$table, $zone) {
- // expand multi-column and multi-row cells in a specified $zone of a $table
-
- // do nothing if this $zone is empty
- if (empty($table->$zone)) return;
-
- // shortcut to rows in this $table $zone
- $rows = &$table->{$zone};
-
- // loop through the rows
- foreach ($rows as $row=>$cells) {
-
- // check this is an array
- if (is_array($cells)) {
-
- // loop through the cells in this row
- foreach ($cells as $col=>$cell) {
-
- if (is_object($cell)) {
- if (isset($cell->rowspan) && is_numeric($cell->rowspan) && ($cell->rowspan>1)) {
- // fill in cells below this one
- $new_cell = array($cell->text);
- for ($r=1; $r<$cell->rowspan; $r++) {
- array_splice($rows[$row+$r], $col, 0, $new_cell);
- }
- }
- if (isset($cell->colspan) && is_numeric($cell->colspan) && ($cell->colspan>1)) {
- // fill in cells to the right of this one
- $new_cells = array();
- for ($c=1; $c<$cell->colspan; $c++) {
- $new_cells[] = $cell->text;
- }
- array_splice($rows[$row], $col, 0, $new_cells);
- }
- // replace $cell object with plain text
- $rows[$row][$col] = $cell->text;
- }
- }
- }
- }
- }
-
-/////////////////////////////////////////////////
-/// print a report in html, text or Excel format
-/////////////////////////////////////////////////
-
-// the stuff to print is contained in $table
-// which has the following properties:
-
-// $table->border border width for the table
-// $table->cellpadding padding on each cell
-// $table->cellspacing spacing between cells
-// $table->tableclass class for table
-// $table->width table width
-
-// $table->align is an array of column alignments
-// $table->class is an array of column classes
-// $table->size is an array of column sizes
-// $table->wrap is an array of column wrap/nowrap switches
-// $table->fontsize is an array of fontsizes
-
-// $table->caption is a caption (=title) for the report
-// $table->head is an array of headings (all TH cells)
-// $table->data[] is an array of arrays containing the data (all TD cells)
-// if a row is given as "hr", a "tabledivider" is inserted
-// if a cell is a string, it is assumed to be the cell content
-// a cell can also be an object, thus:
-// $cell->text : the content of the cell
-// $cell->rowspan : the row span of this cell
-// $cell->colspan : the column span of this cell
-// if rowspan or colspan are specified, neighboring cells are shifted accordingly
-// $table->stat[] is an array of arrays containing the statistics rows (TD and TH cells)
-// $table->foot[] is an array of arrays containing the footer rows (all TH cells)
-
-// $table->statheadercols is an array of column numbers which are headers
-
-
-//////////////////////////////////////////
-/// print a report
-
- function print_report(&$course, &$hotpot, &$tables, &$options) {
- switch ($options['reportformat']) {
- case 'txt':
- $this->print_text_report($course, $hotpot, $tables, $options);
- break;
- case 'xls':
- $this->print_excel_report($course, $hotpot, $tables, $options);
- break;
- default: // 'htm' (and anything else)
- $this->print_html_report($tables);
- break;
- }
- }
-
- function print_report_start(&$course, &$hotpot, &$options, &$table) {
- switch ($options['reportformat']) {
- case 'txt':
- $this->print_text_start($course, $hotpot, $options);
- break;
- case 'xls':
- $this->print_excel_start($course, $hotpot, $options);
- break;
-
- case 'htm':
- $this->print_html_start($course, $hotpot, $options);
- break;
- }
- }
-
- function print_report_cells(&$table, &$options, $zone) {
- switch ($options['reportformat']) {
- case 'txt':
- $fmt = 'text';
- break;
- case 'xls':
- $fmt = 'excel';
- break;
- default: // 'htm' (and anything else)
- $fmt = 'html';
- break;
- }
- $fn = "print_{$fmt}_{$zone}";
- $this->$fn($table, $options);
- }
-
- function print_report_finish(&$course, &$hotpot, &$options) {
- switch ($options['reportformat']) {
- case 'txt' :
- // do nothing
- break;
- case 'xls':
- $this->print_excel_finish($course, $hotpot, $options);
- break;
- case 'htm':
- $this->print_html_finish($course, $hotpot, $options);
- break;
- }
- }
-
-//////////////////////////////////////////
-/// print an html report
-
- function print_html_report(&$tables) {
- global $OUTPUT;
- $count = count($tables);
- foreach($tables as $i=>$table) {
-
- $this->print_html_start($table);
- $this->print_html_head($table);
- $this->print_html_data($table);
- $this->print_html_stat($table);
- $this->print_html_foot($table);
- $this->print_html_finish($table);
-
- if (($i+1)<$count) {
- echo $OUTPUT->spacer(array('height'=>30, 'width'=>10, 'br'=>true)); // should be done with CSS instead
- }
- }
- }
- function print_html_start(&$table) {
- global $OUTPUT;
- // default class for the table
- if (empty($table->tableclass)) {
- $table->tableclass = 'generaltable';
- }
-
- // default classes for TD and TH
- $d = $table->tableclass.'cell';
- $h = $table->tableclass.'header';
-
- $table->th_side = '';
-
- $table->td = array();
- $table->th_top = array();
-
- if (empty($table->colspan)) {
- if (isset($table->head)) {
- $table->colspan = count($table->head);
- } else if (isset($table->data)) {
- $table->colspan = count($table->data[0]);
- } else if (isset($table->stat)) {
- $table->colspan = count($table->stat);
- } else if (isset($table->foot)) {
- $table->colspan = count($table->foot);
- } else {
- $table->colspan = 0;
- }
- }
-
- for ($i=0; $i<$table->colspan; $i++) {
-
- $align = empty($table->align[$i]) ? '' : ' align="'.$table->align[$i].'"';
- $class = empty($table->class[$i]) ? $d : ' class="'.$table->class[$i].'"';
- $class = ' class="'.(empty($table->class[$i]) ? $d : $table->class[$i]).'"';
- $size = empty($table->size[$i]) ? '' : ' width="'.$table->size[$i].'"';
- $wrap = empty($table->wrap[$i]) ? '' : ' nowrap="nowrap"';
-
- $table->th_top[$i] = ' | ';
-
- $table->td[$i] = ' | ';
-
- if (!empty($table->fontsize[$i])) {
- $table->td[$i] .= '';
- }
- }
-
- if (empty($table->border)) {
- $table->border = 0;
- }
- if (empty($table->cellpadding)) {
- $table->cellpadding = 5;
- }
- if (empty($table->cellspacing)) {
- $table->cellspacing = 1;
- }
- if (empty($table->width)) {
- $table->width = "80%"; // actually the width of the "simple box"
- }
- if (empty($table->tablealign)) {
- $table->tablealign = "center";
- }
-
- if (isset($table->start)) {
- print $table->start."\n";
- }
-
- echo $OUTPUT->box_start("generalbox boxalign$table->tablealign");
- print ''."\n";
-
- if (isset($table->caption)) {
- print ' '."\n";
- }
-
- }
- function print_html_head(&$table) {
- if (isset($table->head)) {
- print "\n";
- foreach ($table->head as $i=>$cell) {
- $th = $table->th_top[$i];
- print $th.$cell."\n";
- }
- print " \n";
- }
- }
- function print_html_data(&$table) {
- if (isset($table->data)) {
- $skipcol = array();
- foreach ($table->data as $cells) {
- print "\n";
- if (is_array($cells)) {
- $i = 0; // index on $cells
- $col = 0; // column index
- while ($col<$table->colspan && isset($cells[$i])) {
- if (empty($skipcol[$col])) {
- $cell = &$cells[$i++];
- $td = $table->td[$col];
- if (is_object($cell)) {
- $text = $cell->text;
- if (isset($cell->rowspan) && is_numeric($cell->rowspan) && ($cell->rowspan>0)) {
- $td = '| rowspan-1;
- }
- if (isset($cell->colspan) && is_numeric($cell->colspan) && ($cell->colspan>0)) {
- $td = ' | colspan; $c++) {
- if (empty($skipcol[$col+$c])) {
- $skipcol[$col+$c] = 1;
- } else {
- $skipcol[$col+$c] ++;
- }
- }
- }
- } else { // $cell is a string
- $text = $cell;
- }
- print $td.$text.(empty($table->fontsize[$col]) ? '' : '')." | \n";
- } else {
- $skipcol[$col]--;
- }
- $col++;
- } // end while
- } else if ($cells=='hr') {
- print ' | '."\n";
- }
- print " \n";
- }
- }
- }
- function print_html_stat(&$table) {
- if (isset($table->stat)) {
- if (empty($table->statheadercols)) {
- $table->statheadercols = array();
- }
- foreach ($table->stat as $cells) {
- print '';
- foreach ($cells as $i => $cell) {
- if (in_array($i, $table->statheadercols)) {
- $th = $table->th_side;
- print $th.$cell."\n";
- } else {
- $td = $table->td[$i];
- print $td.$cell."\n";
- }
- }
- print " \n";
- }
- }
- }
- function print_html_foot(&$table) {
- if (isset($table->foot)) {
- foreach ($table->foot as $cells) {
- print "\n";
- foreach ($cells as $i => $cell) {
- if ($i==0) {
- $th = $table->th_side;
- print $th.$cell."\n";
- } else {
- $th = $table->th_top[$i];
- print $th.$cell."\n";
- }
- }
- print " \n";
- }
- }
- }
- function print_html_finish(&$table) {
- global $OUTPUT;
- print " \n";
- echo $OUTPUT->box_end();
-
- if (isset($table->finish)) {
- print $table->finish."\n";
- }
- }
-
-//////////////////////////////////////////
-/// print a text report
-
- function print_text_report(&$course, &$hotpot, &$tables, &$options) {
- $this->print_text_start($course, $hotpot, $options);
- foreach ($tables as $table) {
- $this->print_text_head($table, $options);
- $this->print_text_data($table, $options);
- $this->print_text_stat($table, $options);
- $this->print_text_foot($table, $options);
- }
- }
- function print_text_start(&$course, &$hotpot, &$options) {
- $downloadfilename = clean_filename("$course->shortname $hotpot->name.txt");
- header("Content-Type: application/download\n");
- header("Content-Disposition: attachment; filename=$downloadfilename");
- header("Expires: 0");
- header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
- header("Pragma: public");
- }
- function print_text_head(&$table, &$options) {
- if (isset($table->caption)) {
- $i = strlen($table->caption);
- $data = array(
- array(str_repeat('=', $i)),
- array($table->caption),
- array(str_repeat('=', $i)),
- );
- foreach($data as $cells) {
- $this->print_text_cells($cells, $options);
- }
- }
- if (isset($table->head)) {
- $this->expand_spans($table, 'head');
- $this->print_text_cells($table->head, $options);
- }
- }
- function print_text_data(&$table, &$options) {
- if (isset($table->data)) {
- $this->expand_spans($table, 'data');
- foreach ($table->data as $cells) {
- $this->print_text_cells($cells, $options);
- }
- }
- }
- function print_text_stat(&$table, &$options) {
- if (isset($table->stat)) {
- $this->expand_spans($table, 'stat');
- foreach ($table->stat as $cells) {
- $this->print_text_cells($cells, $options);
- }
- }
- }
- function print_text_foot(&$table, &$options) {
- if (isset($table->foot)) {
- $this->expand_spans($table, 'foot');
- foreach ($table->foot as $cells) {
- $this->print_text_cells($cells, $options);
- }
- }
- }
- function print_text_cells(&$cells, &$options) {
-
- // do nothing if there are no cells
- if (empty($cells) || is_string($cells)) return;
-
- // convert to tab-delimted string
- $str = implode("\t", $cells);
-
- // replace newlines in string
- $str = preg_replace("/\n/", ",", $str);
-
- // set best newline for this browser (if it hasn't been done already)
- if (empty($this->nl)) {
- $s = &$_SERVER['HTTP_USER_AGENT'];
- $win = is_numeric(strpos($s, 'Win'));
- $mac = is_numeric(strpos($s, 'Mac')) && !is_numeric(strpos($s, 'OS X'));
- $this->nl = $win ? "\r\n" : ($mac ? "\r" : "\n");
- }
-
- print $str.$this->nl;
- }
-
-//////////////////////////////////////////
-/// print an Excel report
-
- function print_excel_report(&$course, &$hotpot, &$tables, &$options) {
- global $CFG;
-
- // create Excel workbook
- if (file_exists("$CFG->libdir/excellib.class.php")) {
- // Moodle >= 1.6
- require_once("$CFG->libdir/excellib.class.php");
- $wb = new MoodleExcelWorkbook("-");
- $wsnamelimit = 0; // no limit
- } else {
- // Moodle <= 1.5
- require_once("$CFG->libdir/excel/Worksheet.php");
- require_once("$CFG->libdir/excel/Workbook.php");
- $wb = new Workbook("-");
- $wsnamelimit = 31; // max length in chars
- }
-
- // send HTTP headers
- $this->print_excel_headers($wb, $course, $hotpot);
-
- // create one worksheet for each table
- foreach($tables as $table) {
- unset($ws);
- if (empty($table->caption)) {
- $wsname = '';
- } else {
- $wsname = strip_tags($table->caption);
- if ($wsnamelimit && strlen($wsname) > $wsnamelimit) {
- $wsname = substr($wsname, -$wsnamelimit); // end of string
- // $wsname = substr($wsname, 0, $wsnamelimit); // start of string
- }
- }
- $ws = &$wb->add_worksheet($wsname);
-
- $row = 0;
- $this->print_excel_head($wb, $ws, $table, $row, $options);
- $this->print_excel_data($wb, $ws, $table, $row, $options);
- $this->print_excel_stat($wb, $ws, $table, $row, $options);
- $this->print_excel_foot($wb, $ws, $table, $row, $options);
- }
-
- // close the workbook (and send it to the browser)
- $wb->close();
- }
- function print_excel_headers(&$wb, &$course, &$hotpot) {
- $downloadfilename = clean_filename("$course->shortname $hotpot->name.xls");
- if (method_exists($wb, 'send')) {
- // Moodle >=1.6
- $wb->send($downloadfilename);
- } else {
- // Moodle <=1.5
- header("Content-type: application/vnd.ms-excel");
- header("Content-Disposition: attachment; filename=$downloadfilename" );
- header("Expires: 0");
- header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
- header("Pragma: public");
- }
- }
- function print_excel_head(&$wb, &$ws, &$table, &$row, &$options) {
- // define format properties
- $properties = array(
- 'bold'=>1,
- 'align'=>'center',
- 'v_align'=>'bottom',
- 'text_wrap'=>1
- );
-
- // expand multi-column and multi-row cells
- $this->expand_spans($table, 'head');
-
- // print the headings
- $this->print_excel_cells($wb, $ws, $table, $row, $properties, $table->head, $options);
- }
- function print_excel_data(&$wb, &$ws, &$table, &$row, &$options) {
- // do nothing if there are no cells
- if (empty($table->data)) return;
-
- // define format properties
- $properties = array('text_wrap' => (empty($options['reportwrapdata']) ? 0 : 1));
-
- // expand multi-column and multi-row cells
- $this->expand_spans($table, 'data');
-
- // print rows
- foreach ($table->data as $cells) {
- $this->print_excel_cells($wb, $ws, $table, $row, $properties, $cells, $options);
- }
- }
- function print_excel_stat(&$wb, &$ws, &$table, &$row, &$options) {
- // do nothing if there are no cells
- if (empty($table->stat)) return;
-
- // define format properties
- $properties = array('align'=>'right');
-
- // expand multi-column and multi-row cells
- $this->expand_spans($table, 'stat');
-
- // print rows
- $i_count = count($table->stat);
- foreach ($table->stat as $i => $cells) {
-
- // set border on top and bottom row
- $properties['top'] = ($i==0) ? 1 : 0;
- $properties['bottom'] = ($i==($i_count-1)) ? 1 : 0;
-
- // print this row
- $this->print_excel_cells($wb, $ws, $table, $row, $properties, $cells, $options, $table->statheadercols);
- }
- }
- function print_excel_foot(&$wb, &$ws, &$table, &$row, &$options) {
- // do nothing if there are no cells
- if (empty($table->foot)) return;
-
- // define format properties
- $properties = array('bold'=>1, 'align'=>'center');
-
- // expand multi-column and multi-row cells
- $this->expand_spans($table, 'foot');
-
- // print rows
- $i_count = count($table->foot);
- foreach ($table->foot as $i => $cells) {
-
- // set border on top and bottom row
- $properties['top'] = ($i==0) ? 1 : 0;
- $properties['bottom'] = ($i==($i_count-1)) ? 1 : 0;
-
- // print this footer row
- $this->print_excel_cells($wb, $ws, $table, $row, $properties, $cells, $options);
- }
- }
-
- function print_excel_cells(&$wb, &$ws, &$table, &$row, &$properties, &$cells, &$options, $statheadercols=NULL) {
- // do nothing if there are no cells
- if (empty($cells) || is_string($cells)) return;
-
- // print cells
- foreach($cells as $col => $cell) {
-
- unset($fmt_properties);
- $fmt_properties = $properties;
-
- if (empty($fmt_properties['text_wrap'])) {
- if (strlen("$cell")>=9) {
- // long cell value
- $fmt_properties['align'] = 'left';
- }
- } else {
- if (strlen("$cell")<9 && strpos("$cell", "\n")===false) {
- // short cell value (wrapping not required)
- $fmt_properties['text_wrap'] = 0;
- }
- }
-
- // set bold, if required (for stat)
- if (isset($statheadercols)) {
- $fmt_properties['bold'] = in_array($col, $statheadercols) ? 1 : 0;
- $fmt_properties['align'] = in_array($col, $statheadercols) ? 'right' : $table->align[$col];
- }
-
- // set align, if required
- if (isset($table->align[$col]) && empty($fmt_properties['align'])) {
- $fmt_properties['align'] = $table->align[$col];
- }
-
- // check to see that an identical format object has not already been created
- unset($fmt);
-
- if (isset($wb->pear_excel_workbook)) {
- // Moodle >=1.6
- $fmt_properties_obj = (object)$fmt_properties;
- foreach ($wb->pear_excel_workbook->_formats as $id=>$format) {
- if ($format==$fmt_properties_obj) {
- $fmt = &$wb->pear_excel_workbook->_formats[$id];
- break;
- }
- }
- } else {
- // Moodle <=1.5
- foreach ($wb->formats as $id=>$format) {
- if (isset($format->properties) && $format->properties==$fmt_properties) {
- $fmt = &$wb->formats[$id];
- break;
- }
- }
- if (is_numeric($cell) || empty($options['reportencoding'])) {
- // do nothing
- } else {
- $in_charset = '';
- if (function_exists('mb_convert_encoding')) {
- $in_charset = mb_detect_encoding($cell, 'auto');
- }
- if (empty($in_charset)) {
- $in_charset = 'UTF-8';
- }
- if ($in_charset != 'ASCII' && function_exists('mb_convert_encoding')) {
- $cell = mb_convert_encoding($cell, $options['reportencoding'], $in_charset);
- }
- }
- }
-
- // create new format object, if necessary (to avoid "too many cell formats" error)
- if (!isset($fmt)) {
- $fmt = &$wb->add_format($fmt_properties);
- $fmt->properties = &$fmt_properties;
-
- // set vertical alignment
- if (isset($fmt->properties['v_align'])) {
- $fmt->set_align($fmt->properties['v_align']);
- } else {
- $fmt->set_align('top'); // default
- }
- }
-
- // write cell
- if (is_numeric($cell) && !preg_match("/^0./", $cell)) {
- $ws->write_number($row, $col, $cell, $fmt);
- } else {
- $ws->write_string($row, $col, $cell, $fmt);
- }
- } // end foreach $col
-
- // increment $row
- $row++;
- }
-}
-
-
diff --git a/mod/hotpot/report/fullstat/report.php b/mod/hotpot/report/fullstat/report.php
deleted file mode 100644
index f289bde7190..00000000000
--- a/mod/hotpot/report/fullstat/report.php
+++ /dev/null
@@ -1,449 +0,0 @@
-create_responses_table($hotpot, $course, $users, $attempts, $questions, $options, $tables);
- $this->create_analysis_table($users, $attempts, $questions, $options, $tables);
- // print report
- $this->print_report($course, $hotpot, $tables, $options);
- return true;
- }
- function create_responses_table(&$hotpot, &$course, &$users, &$attempts, &$questions, &$options, &$tables) {
- global $CFG, $OUTPUT;
- $is_html = ($options['reportformat']=='htm');
- // shortcuts for font tags
- $br = $is_html ? " \n" : "\n";
- $blank = $is_html ? ' ' : "";
- $font_end = $is_html ? '' : '';
- $font_red = $is_html ? '' : '';
- $font_blue = $is_html ? '' : '';
- $font_brown = $is_html ? '' : '';
- $font_green = $is_html ? '' : '';
- $font_small = $is_html ? '' : '';
- $nobr_start = $is_html ? '' : '';
- $nobr_end = $is_html ? '' : '';
- // is review allowed? (do this once here, to save time later)
- $allow_review = ($is_html && (has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $course->id)) || $hotpot->review));
- // assume penalties column is NOT required
- $show_penalties = false;
- // initialize $table
- unset($table);
- $table->border = 1;
- $table->width = '100%';
- // initialize legend, if necessary
- if (!empty($options['reportshowlegend'])) {
- $table->legend = array();
- }
- // headings for name, attempt number, score/grade and penalties
- $table->head = array(
- get_string("name"),
- hotpot_grade_heading($hotpot, $options),
- get_string('attempt', 'quiz'),
- );
- $table->align = array('left', 'center', 'center');
- $table->size = array(150, 80, 10);
- $table->wrap = array(0, 0, 0);
- $table->fontsize = array(0, 0, 0);
- // question headings
- $this->add_question_headings($questions, $table, 'left', 0, false, 2);
- // penalties (not always needed) and raw score
- array_push($table->head,
- get_string('penalties', 'hotpot'),
- get_string('score', 'quiz')
- );
- array_push($table->align, 'center', 'center');
- array_push($table->size, 50, 50);
- array_push($table->wrap, 0, 0);
- array_push($table->fontsize, 0, 0);
- // message strings
- $strnoresponse = get_string('noresponse', 'quiz');
- // array to map columns onto question ids ($col => $id)
- $questionids = array_keys($questions);
- // add details of users' responses
- foreach ($users as $user) {
- // shortcut to user info held in first attempt record
- $u = &$user->attempts[0];
- if (function_exists("fullname")) {
- $name = fullname($u);
- } else {
- $name = "$u->firstname $u->lastname";
- }
- if ($is_html) {
- $name = ''.$name.'';
- }
- $grade = isset($user->grade) ? $user->grade : $blank;
- foreach ($user->attempts as $attempt) {
- $attemptnumber = $attempt->attempt;
- if ($allow_review) {
- $attemptnumber = ' '.$attemptnumber.'';
- }
- $cells = array ($name, $grade, $attemptnumber);
- // $name and $grade are only printed on first line per user
- $name = $blank;
- $grade = $blank;
- $start_col = count($cells);
- foreach ($questionids as $col => $id) {
- $cells[$start_col + $col] = "$font_brown($strnoresponse)$font_end";
- }
- if (isset($attempt->penalties)) {
- $show_penalties = true;
- $penalties = $attempt->penalties;
- } else {
- $penalties = $blank;
- }
- array_push($cells, $penalties, hotpot_format_score($attempt));
- // get responses to questions in this attempt
- foreach ($attempt->responses as $response) {
- // check this question id is OK (should be)
- $col = array_search($response->question, $questionids);
- if (is_numeric($col)) {
- // correct
- if ($value = hotpot_strings($response->correct)) {
- $this->set_legend($table, $col, $value, $questions[$response->question]);
- } else {
- $value = "($strnoresponse)";
- }
- $cell = $font_red.$value.$font_end;
- // wrong
- if ($value = hotpot_strings($response->wrong)) {
- if (isset($table->legend)) {
- $values = array();
- foreach (explode(',', $value) as $v) {
- $this->set_legend($table, $col, $v, $questions[$response->question]);
- $values[] = $v;
- }
- $value = implode(',', $values);
- }
- $cell .= $br.$font_blue.$value.$font_end;
- }
- // ignored
- if ($value = hotpot_strings($response->ignored)) {
- if (isset($table->legend)) {
- $values = array();
- foreach (explode(',', $value) as $v) {
- $this->set_legend($table, $col, $v, $questions[$response->question]);
- $values[] = $v;
- }
- $value = implode(',', $values);
- }
- $cell .= $br.$font_brown.$value.$font_end;
- }
- // numeric
- if (is_numeric($response->score)) {
- if (empty($table->caption)) {
- $table->caption = get_string('indivresp', 'quiz');
- if ($is_html) {
- $table->caption .= $OUTPUT->old_help_icon('responsestable', $table->caption, 'hotpot');
- }
- }
- $hints = empty($response->hints) ? 0 : $response->hints;
- $clues = empty($response->clues) ? 0 : $response->clues;
- $checks = empty($response->checks) ? 0 : $response->checks;
- $numeric = $response->score.'% '.$blank.' ('.$hints.','.$clues.','.$checks.')';
- $cell .= $br.$nobr_start.$font_green.$numeric.$font_end.$nobr_end;
- }
- $cells[$start_col + $col] = $cell;
- }
- }
- $table->data[] = $cells;
- }
- // insert 'tabledivider' between users
- $table->data[] = 'hr';
- } // end foreach $users
- // remove final 'hr' from data rows
- array_pop($table->data);
- if (!$show_penalties) {
- $col = 3 + count($questionids);
- $this->remove_column($table, $col);
- }
- $tables[] = &$table;
- }
- function create_analysis_table(&$users, &$attempts, &$questions, &$options, &$tables) {
- global $OUTPUT;
- $is_html = ($options['reportformat']=='htm');
- // the fields we are interested in, in the order we want them
- $fields = array('correct', 'wrong', 'ignored', 'hints', 'clues', 'checks', 'weighting');
- $string_fields = array('correct', 'wrong', 'ignored');
- $q = array(); // statistics about the $q(uestions)
- $f = array(); // statistics about the $f(ields)
- ////////////////////////////////////////////
- // compile the statistics about the questions
- ////////////////////////////////////////////
- foreach ($questions as $id=>$question) {
- // extract scores for attempts at this question
- $scores = array();
- foreach ($question->attempts as $attempt) {
- $scores[] = $attempt->score;
- }
- // sort scores values (in ascending order)
- asort($scores);
- // get the borderline high and low scores
- $count = count($scores);
- switch ($count) {
- case 0:
- $lo_score = 0;
- $hi_score = 0;
- break;
- case 1:
- $lo_score = 0;
- $hi_score = $scores[0];
- break;
- default:
- $lo_score = $scores[round($count*1/3)];
- $hi_score = $scores[round($count*2/3)];
- break;
- }
- // get statistics for each attempt which includes this question
- foreach ($question->attempts as $attempt) {
- $is_hi_score = ($attempt->score >= $hi_score);
- $is_lo_score = ($attempt->score < $lo_score);
- // reference to the response to the current question
- $response = &$attempt->responses[$id];
- // update statistics for fields in this response
- foreach($fields as $field) {
- if (!isset($q[$id])) {
- $q[$id] = array();
- }
- if (!isset($f[$field])) {
- $f[$field] = array('count' => 0);
- }
- if (!isset($q[$id][$field])) {
- $q[$id][$field] = array('count' => 0);
- }
- $values = explode(',', $response->$field);
- $values = array_unique($values);
- foreach($values as $value) {
- // $value should be an integer (string_id or count)
- if (is_numeric($value)) {
- $f[$field]['count']++;
- if (!isset($q[$id][$field][$value])) {
- $q[$id][$field][$value] = 0;
- }
- $q[$id][$field]['count']++;
- $q[$id][$field][$value]++;
- }
- }
- } // end foreach $field
- // initialize counters for this question, if necessary
- if (!isset($q[$id]['count'])) {
- $q[$id]['count'] = array('hi'=>0, 'lo'=>0, 'correct'=>0, 'total'=>0, 'sum'=>0);
- }
- // increment counters
- $q[$id]['count']['sum'] += $response->score;
- $q[$id]['count']['total']++;
- if ($response->score==100) {
- $q[$id]['count']['correct']++;
- if ($is_hi_score) {
- $q[$id]['count']['hi']++;
- } else if ($is_lo_score) {
- $q[$id]['count']['lo']++;
- }
- }
- } // end foreach attempt
- } // end foreach question
- // check we have some details
- if (count($q)) {
- $showhideid = 'showhide';
- // shortcuts for html tags
- $bold_start = $is_html ? '' : "";
- $bold_end = $is_html ? '' : "";
- $div_start = $is_html ? '' : "";
- $div_end = $is_html ? ' ' : "";
- $font_red = $is_html ? '' : '';
- $font_blue = $is_html ? '' : '';
- $font_green = $is_html ? '' : '';
- $font_brown = $is_html ? '' : '';
- $font_end = $is_html ? ''."\n" : '';
- $br = $is_html ? ' ' : "\n";
- $space = $is_html ? ' ' : "";
- $no_value = $is_html ? '--' : "";
- $help_button = $is_html ? $OUTPUT->old_help_icon("discrimination", get_string('discrimination', 'quiz'), "quiz") : "";
- // table properties
- unset($table);
- $table->border = 1;
- $table->width = '100%';
- $table->caption = get_string('itemanal', 'quiz');
- if ($is_html) {
- $table->caption .= $OUTPUT->old_help_icon('analysistable', $table->caption, 'hotpot');
- }
- // initialize legend, if necessary
- if (!empty($options['reportshowlegend'])) {
- if (empty($tables) || empty($tables[0]->legend)) {
- $table->legend = array();
- } else {
- $table->legend = $tables[0]->legend;
- unset($tables[0]->legend);
- }
- }
- // headings for name, attempt number and score/grade
- $table->head = array($space);
- $table->align = array('right');
- $table->size = array(80);
- // question headings
- $this->add_question_headings($questions, $table, 'left', 0);
- // initialize statistics
- $table->stat = array();
- $table->statheadercols = array(0);
- // add headings for the $foot of the $table
- $table->foot = array();
- $table->foot[0] = array(get_string('average', 'hotpot'));
- $table->foot[1] = array(get_string('percentcorrect', 'quiz'));
- $table->foot[2] = array(get_string('discrimination', 'quiz').$help_button);
- // maximum discrimination index (also default the default value)
- $max_d_index = 10;
- ////////////////////////////////////////////
- // format the statistics into the $table
- ////////////////////////////////////////////
- // add $stat(istics) and $foot of $table
- $questionids = array_keys($q);
- foreach ($questionids as $col => $id) {
- $row = 0;
- // print the question text if there is no legend
- if (empty($table->legend)) {
- // add button to show/hide question text
- if (!isset($table->stat[0])) {
- $button = $is_html ? hotpot_showhide_button($showhideid) : "";
- $table->stat[0] = array(get_string('question', 'quiz').$button);
- }
- // add the question name/text
- $name = hotpot_get_question_name($questions[$id]);
- $table->stat[$row++][$col+1] = $div_start.$bold_start.$name.$bold_end.$div_end.$space;
- }
- // add details about each field
- foreach ($fields as $field) {
- // check this row is required
- if ($f[$field]['count']) {
- $values = array();
- $string_type = array_search($field, $string_fields);
- // get the value of each response to this field
- // and the count of that value
- foreach ($q[$id][$field] as $value => $count) {
- if (is_numeric($value) && $count) {
- if (is_numeric($string_type)) {
- $value = hotpot_string($value);
- $this->set_legend($table, $col, $value, $questions[$id]);
- switch ($string_type) {
- case 0: // correct
- $font_start = $font_red;
- break;
- case 1: // wrong
- $font_start = $font_blue;
- break;
- case 2: // ignored
- $font_start = $font_brown;
- break;
- }
- } else { // numeric field
- $font_start = $font_green;
- }
- $values[] = $font_start.round(100*$count/$q[$id]['count']['total']).'%'.$font_end.' '.$value;
- }
- } // end foreach $value => $count
- // initialize stat(istics) row for this field, if required
- if (!isset($table->stat[$row])) {
- $table->stat[$row] = array(get_string($field, 'hotpot'));
- }
- // sort the values by frequency (using user-defined function)
- usort($values, "hotpot_sort_stat_values");
- // add stat(istics) values for this field
- $table->stat[$row++][$col+1] = count($values) ? implode($br, $values) : $space;
- }
- } // end foreach field
- // default percent correct and discrimination index for this question
- $average = $no_value;
- $percent = $no_value;
- $d_index = $no_value;
- if (isset($q[$id]['count'])) {
- // average and percent correct
- if ($q[$id]['count']['total']) {
- $average = round($q[$id]['count']['sum'] / $q[$id]['count']['total']).'%';
- $percent = round(100*$q[$id]['count']['correct'] / $q[$id]['count']['total']).'%';
- $percent .= ' ('.$q[$id]['count']['correct'].'/'.$q[$id]['count']['total'].')';
- }
- // discrimination index
- if ($q[$id]['count']['lo']) {
- $d_index = min($max_d_index, round($q[$id]['count']['hi'] / $q[$id]['count']['lo'], 1));
- } else {
- $d_index = $q[$id]['count']['hi'] ? $max_d_index : 0;
- }
- $d_index .= ' ('.$q[$id]['count']['hi'].'/'.$q[$id]['count']['lo'].')';
- }
- $table->foot[0][$col+1] = $average;
- $table->foot[1][$col+1] = $percent;
- $table->foot[2][$col+1] = $d_index;
- } // end foreach $question ($col)
- // add javascript to show/hide question text
- if (isset($table->stat[0]) && $is_html && empty($table->legend)) {
- $i = count($table->stat[0]);
- $table->stat[0][$i-1] .= hotpot_showhide_set($showhideid);
- }
- $tables[] = &$table;
- $this->create_legend_table($tables, $table);
- } // end if (empty($q)
- } // end function
-} // end class
-function hotpot_sort_stat_values($a, $b) {
- // sorts in descending order
- // assumes first chars in $a and $b are a percentage
- $a_val = intval(strip_tags($a));
- $b_val = intval(strip_tags($b));
- return ($a_val<$b_val) ? 1 : ($a_val==$b_val ? 0 : -1);
-}
-function hotpot_showhide_button($id) {
- $show = get_string('show');
- $hide = get_string('hide');
- $pref = '1';
- $text = ($pref=='1' ? $hide : $show);
-return <<
-//';
- html += '';
- html += '';
- html += '';
- document.writeln(html);
- }
-//]]>
-
-SHOWHIDE_BUTTON
-;
-}
-function hotpot_showhide_set($id) {
-return <<
-//
-
-SHOWHIDE_SET
-;
-}
-
diff --git a/mod/hotpot/report/overview/report.php b/mod/hotpot/report/overview/report.php
deleted file mode 100644
index 310aacab29f..00000000000
--- a/mod/hotpot/report/overview/report.php
+++ /dev/null
@@ -1,172 +0,0 @@
-create_overview_table($hotpot, $cm, $course, $users, $attempts, $questions, $options, $tables);
- $this->print_report($course, $hotpot, $tables, $options);
- return true;
- }
- function create_overview_table(&$hotpot, &$cm, &$course, &$users, &$attempts, &$questions, &$options, &$tables) {
- global $CFG, $OUTPUT;
- $strtimeformat = get_string('strftimedatetime');
- $is_html = ($options['reportformat']=='htm');
- $spacer = $is_html ? ' ' : ' ';
- $br = $is_html ? " \n" : "\n";
- // initialize $table
- unset($table);
- $table->border = 1;
- $table->width = 10;
- $table->head = array();
- $table->align = array();
- $table->size = array();
- $table->wrap = array();
- // picture column, if required
- if ($is_html) {
- $table->head[] = $spacer;
- $table->align[] = 'center';
- $table->size[] = 10;
- $table->wrap[] = "nowrap";
- }
- array_push($table->head,
- get_string("name"),
- hotpot_grade_heading($hotpot, $options),
- get_string("attempt", "quiz"),
- get_string("time", "quiz"),
- get_string("reportstatus", "hotpot"),
- get_string("timetaken", "quiz"),
- get_string("score", "quiz")
- );
- array_push($table->align, "left", "center", "center", "left", "center", "center", "center");
- array_push($table->wrap, "nowrap", "nowrap", "nowrap", "nowrap", "nowrap", "nowrap", "nowrap");
- array_push($table->size, "*", "*", "*", "*", "*", "*", "*");
- $abandoned = 0;
- foreach ($users as $user) {
- // shortcut to user info held in first attempt record
- $u = &$user->attempts[0];
- $picture = '';
- $name = fullname($u);
- if ($is_html) {
- //grrrr
- $usr = clone($u);
- $u->id = $u->userid;
- $picture = $OUTPUT->user_picture($usr, array('courseid'=>$course->id));
- $name = ''.$name.'';
- }
- $grade = isset($user->grade) && $user->grade<>' ' ? $user->grade : $spacer;
- $attemptcount = count($user->attempts);
- if ($attemptcount>1) {
- $text = $name;
- $name = NULL;
- $name->text = $text;
- $name->rowspan = $attemptcount;
- $text = $grade;
- $grade = NULL;
- $grade->text = $text;
- $grade->rowspan = $attemptcount;
- }
- $data = array();
- if ($is_html) {
- if ($attemptcount>1) {
- $text = $picture;
- $picture = NULL;
- $picture->text = $text;
- $picture->rowspan = $attemptcount;
- }
- $data[] = $picture;
- }
- array_push($data, $name, $grade);
- foreach ($user->attempts as $attempt) {
- // increment count of abandoned attempts
- // if attempt is marked as finished but has no score
- if ($attempt->status==HOTPOT_STATUS_ABANDONED) {
- $abandoned++;
- }
- $attemptnumber = $attempt->attempt;
- $starttime = trim(userdate($attempt->timestart, $strtimeformat));
- if ($is_html && isset($attempt->score) && (has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $course->id)) || $hotpot->review)) {
- $attemptnumber = ''.$attemptnumber.'';
- $starttime = ''.$starttime.'';
- }
- if ($is_html && has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $course->id))) {
- $checkbox = ''.$spacer;
- } else {
- $checkbox = '';
- }
- $timetaken = empty($attempt->timefinish) ? $spacer : format_time($attempt->timefinish - $attempt->timestart);
- $score = hotpot_format_score($attempt);
- if ($is_html && is_numeric($score) && $score==$user->grade) { // best grade
- $score = ''.$score.'';
- }
- array_push($data,
- $attemptnumber,
- $checkbox.$starttime,
- hotpot_format_status($attempt),
- $timetaken,
- $score
- );
- $table->data[] = $data;
- $data = array();
- } // end foreach $attempt
- $table->data[] = 'hr';
- } // end foreach $user
- // remove final 'hr' from data rows
- array_pop($table->data);
- // add the "delete" form to the table
- if ($options['reportformat']=='htm' && has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $course->id))) {
- $strdeletecheck = get_string('deleteattemptcheck','quiz');
- $table->start = $this->deleteform_javascript();
- $table->start .= ''."\n";
- }
- $tables[] = &$table;
- }
- function deleteform_javascript() {
- $strselectattempt = addslashes_js(get_string('selectattempt','hotpot'));
- return <<
-
-
-END_OF_JAVASCRIPT
-;
- } // end function
-} // end class
-
diff --git a/mod/hotpot/report/simplestat/report.php b/mod/hotpot/report/simplestat/report.php
deleted file mode 100644
index 1ff5ddbf108..00000000000
--- a/mod/hotpot/report/simplestat/report.php
+++ /dev/null
@@ -1,203 +0,0 @@
-create_scores_table($hotpot, $course, $users, $attempts, $questions, $options, $tables);
- $this->print_report($course, $hotpot, $tables, $options);
- return true;
- }
- function create_scores_table(&$hotpot, &$course, &$users, &$attempts, &$questions, &$options, &$tables) {
- global $CFG, $OUTPUT;
- $download = ($options['reportformat']=='htm') ? false : true;
- $is_html = ($options['reportformat']=='htm');
- $blank = ($download ? '' : ' ');
- $no_value = ($download ? '' : '-');
- $allow_review = true;
- // start the table
- unset($table);
- $table->border = 1;
- $table->head = array();
- $table->align = array();
- $table->size = array();
- // picture column, if required
- if ($is_html) {
- $table->head[] = ' ';
- $table->align[] = 'center';
- $table->size[] = 10;
- }
- // name, grade and attempt number
- array_push($table->head,
- get_string("name"),
- hotpot_grade_heading($hotpot, $options),
- get_string("attempt", "quiz")
- );
- array_push($table->align, "left", "center", "center");
- array_push($table->size, '', '', '');
- // question headings
- $this->add_question_headings($questions, $table);
- // penalties and raw score
- array_push($table->head,
- get_string('penalties', 'hotpot'),
- get_string('score', 'quiz')
- );
- array_push($table->align, "center", "center");
- array_push($table->size, '', '');
- $table->data = array();
- $q = array(
- 'grade' => array('count'=>0, 'total'=>0),
- 'penalties' => array('count'=>0, 'total'=>0),
- 'score' => array('count'=>0, 'total'=>0),
- );
- foreach ($users as $user) {
- // shortcut to user info held in first attempt record
- $u = &$user->attempts[0];
- $picture = '';
- $name = fullname($u);
- if ($is_html) {
- $picture = $OUTPUT->user_picture($u, array('courseid'=>$course->id));
- $name = html_writer::link($CFG->wwwroot.'/user/view.php?id='.$u->userid.'&course='.$course->id, $name);
- }
- if (isset($user->grade)) {
- $grade = $user->grade;
- $q['grade']['count'] ++;
- if (is_numeric($grade)) {
- $q['grade']['total'] += $grade;
- }
- } else {
- $grade = $no_value;
- }
- $attemptcount = count($user->attempts);
- if ($attemptcount>1) {
- $text = $name;
- $name = NULL;
- $name->text = $text;
- $name->rowspan = $attemptcount;
- $text = $grade;
- $grade = NULL;
- $grade->text = $text;
- $grade->rowspan = $attemptcount;
- }
- $data = array();
- if ($is_html) {
- if ($attemptcount>1) {
- $text = $picture;
- $picture = NULL;
- $picture->text = $text;
- $picture->rowspan = $attemptcount;
- }
- $data[] = $picture;
- }
- array_push($data, $name, $grade);
- foreach ($user->attempts as $attempt) {
- // set flag if this is best grade
- $is_best_grade = ($is_html && $attempt->score==$user->grade);
- // get attempt number
- $attemptnumber= $attempt->attempt;
- if ($is_html && $allow_review) {
- $attemptnumber = ''.$attemptnumber.'';
- }
- if ($is_best_grade) {
- $score = ''.$attemptnumber.'';
- }
- $data[] = $attemptnumber;
- // get responses to questions in this attempt by this user
- foreach ($questions as $id=>$question) {
- if (!isset($q[$id])) {
- $q[$id] = array('count'=>0, 'total'=>0);
- }
- if (isset($attempt->responses[$id])) {
- $score = $attempt->responses[$id]->score;
- if (is_numeric($score)) {
- $q[$id]['count'] ++;
- $q[$id]['total'] += $score;
- if ($is_best_grade) {
- $score = ''.$score.'';
- }
- } else if (empty($score)) {
- $score = $no_value;
- }
- } else {
- $score = $no_value;
- }
- $data[] = $score;
- } // foreach $questions
- if (isset($attempt->penalties)) {
- $penalties = $attempt->penalties;
- if (is_numeric($penalties)) {
- $q['penalties']['count'] ++;
- $q['penalties']['total'] += $penalties;
- }
- if ($is_best_grade) {
- $penalties = ''.$penalties.'';
- }
- } else {
- $penalties = $no_value;
- }
- $data[] = $penalties;
- if (isset($attempt->score)) {
- $score = $attempt->score;
- if (is_numeric($score)) {
- $q['score']['total'] += $score;
- $q['score']['count'] ++;
- }
- if ($is_best_grade) {
- $score = ''.$score.'';
- }
- } else {
- $score = $no_value;
- }
- $data[] = $score;
- // append data for this attempt
- $table->data[] = $data;
- // reset data array for next attempt, if any
- $data = array();
- } // end foreach $attempt
- $table->data[] = 'hr';
- } // end foreach $user
- // remove final 'hr' from data rows
- array_pop($table->data);
- // add averages to foot of table
- $averages = array();
- if ($is_html) {
- $averages[] = $blank;
- }
- array_push($averages, get_string('average', 'hotpot'));
- $col = count($averages);
- if (empty($q['grade']['count'])) {
- // remove score $col from $table
- $this->remove_column($table, $col);
- } else {
- $precision = ($hotpot->grademethod==HOTPOT_GRADEMETHOD_AVERAGE || $hotpot->grade<100) ? 1 : 0;
- $averages[] = round($q['grade']['total'] / $q['grade']['count'], $precision);
- $col++;
- }
- // skip the attempt number column
- $averages[$col++] = $blank;
- foreach ($questions as $id=>$question) {
- if (empty($q[$id]['count'])) {
- // remove this question $col from $table
- $this->remove_column($table, $col);
- } else {
- $averages[$col++] = round($q[$id]['total'] / $q[$id]['count']);
- }
- }
- if (empty($q['penalties']['count'])) {
- // remove penalties $col from $table
- $this->remove_column($table, $col);
- } else {
- $averages[$col++] = round($q['penalties']['total'] / $q['penalties']['count']);
- }
- if (empty($q['score']['count'])) {
- // remove score $col from $table
- $this->remove_column($table, $col);
- } else {
- $averages[$col++] = round($q['score']['total'] / $q['score']['count']);
- }
- $table->foot = array($averages);
- $tables[] = &$table;
- }
-} // end class
-
diff --git a/mod/hotpot/restorelib.php b/mod/hotpot/restorelib.php
deleted file mode 100644
index 957a8cc4a62..00000000000
--- a/mod/hotpot/restorelib.php
+++ /dev/null
@@ -1,537 +0,0 @@
-id,
- // fk->course, files)
- // |
- // +--------------+---------------+
- // | |
- // hotpot_attempts hotpot_questions
- // (UL, pk->id, (UL, pk->id,
- // fk->hotpot) fk->hotpot, text)
- // | | |
- // +-------------------+----------+ |
- // | | |
- // hotpot_details hotpot_responses |
- // (UL, pk->id, (UL, pk->id, |
- // fk->attempt) fk->attempt, question, |
- // correct, wrong, ignored) |
- // | |
- // +-------+-------+
- // |
- // hotpot_strings
- // (UL, pk->id)
- //
- // Meaning: pk->primary key field of the table
- // fk->foreign key to link with parent
- // nt->nested field (recursive data)
- // CL->course level info
- // UL->user level info
- // files->table may have files
- //
- //-----------------------------------------------------------
-
-require_once ("$CFG->dirroot/mod/hotpot/lib.php");
-
-function hotpot_restore_mods($mod, $restore) {
- //This function restores a single hotpot activity
-
- // This function is called by "restore_create_modules" (in "backup/restorelib.php")
- // which is called by "backup/restore_execute.html" (included by "backup/restore.php")
- // $mod is an object
- // id : id field in 'modtype' table
- // modtype : 'hotpot'
- // $restore is an object
- // backup_unique_code : xxxxxxxxxx
- // file : '/full/path/to/backupfile.zip'
- // mods : an array of $modinfo's (see below)
- // restoreto : See RESTORETO_XXX constants in backup/lib.php
- // users : 0=all, 1=course, 2=none
- // logs : 0=no, 1=yes
- // user_files : 0=no, 1=yes
- // course_files : 0=no, 1=yes
- // course_id : id of course into which data is to be restored
- // deleting : true if 'restoreto'==RESTORETO_NEW_COURSE, otherwise false
- // original_wwwroot : 'http://your.server.com/moodle'
- // $modinfo is an array
- // 'modname' : array( 'restore'=> 0=no 1=yes, 'userinfo' => 0=no 1=yes)
-
- global $CFG;
- $status = true;
-
- // get course module data this hotpot activity
- $data = backup_getid($restore->backup_unique_code, 'hotpot', $mod->id);
- if ($data) {
- // $data is an object
- // backup_code => xxxxxxxxxx,
- // table_name => 'hotpot',
- // old_id => xxx,
- // new_id => NULL,
- // info => xml tree array of info backed up for this hotpot activity
- $xml = &$data->info['MOD']['#'];
- $table = 'hotpot';
- $foreign_keys = array('course' => $restore->course_id);
- $more_restore = '';
- // print a message after each hotpot is backed up
- if (!defined('RESTORE_SILENTLY')) {
- $more_restore .= 'print "".get_string("modulename", "hotpot")." "".format_string($record->name,true).""";';
- }
- $more_restore .= 'backup_flush(300);';
- if (function_exists('restore_userdata_selected')) {
- // Moodle >= 1.6
- $restore_userdata_selected = restore_userdata_selected($restore, 'hotpot', $mod->id);
- } else {
- // Moodle <= 1.5
- $restore_userdata_selected = $restore->mods['hotpot']->userinfo;
- }
- if ($restore_userdata_selected) {
- $has_details = false;
- if (isset($xml["ATTEMPT_DATA"]["0"]["#"]["ATTEMPT"]["0"]["#"]["DETAILS"]["0"]["#"])) {
- $details = trim($xml["ATTEMPT_DATA"]["0"]["#"]["ATTEMPT"]["0"]["#"]["DETAILS"]["0"]["#"]);
- if ($details<>'' && $details<>'') {
- $has_details = true;
- }
- }
- if ($has_details && empty($xml["STRING_DATA"]) && empty($xml["QUESTION_DATA"])) {
- // HotPot v2.0.x (regenerate questions, responses and strings from attempt details)
- $more_restore .= '$status = hotpot_restore_attempts($restore, $status, $xml, $record, true);';
- } else {
- // HotPot v2.1+
- $more_restore .= '$status = hotpot_restore_strings($restore, $status, $xml, $record);';
- $more_restore .= '$status = hotpot_restore_questions($restore, $status, $xml, $record);';
- $more_restore .= '$status = hotpot_restore_attempts($restore, $status, $xml, $record);';
- }
- }
-
- // if necessary, adjust HotPot date/time fields and write to restorelog
- if ($restore->course_startdateoffset) {
- restore_log_date_changes('Hotpot', $restore, $xml, array('TIMEOPEN', 'TIMECLOSE', 'TIMECREATED', 'TIMEMODIFIED'));
- }
-
- $status = hotpot_restore_records(
- $restore, $status, $xml, $table, $foreign_keys, $more_restore
- );
- }
- return $status;
-}
-function hotpot_restore_strings(&$restore, $status, &$xml, &$record) {
- // $xml is an XML tree for a hotpot record
- // $record is the newly added hotpot record
- return hotpot_restore_records(
- $restore, $status, $xml, 'hotpot_strings', array(), '', 'STRING_DATA', 'STRING', 'md5key'
- );
-}
-function hotpot_restore_questions(&$restore, $status, &$xml, &$record) {
- // $xml is an XML tree for a hotpot record
- // $record is the newly added hotpot record
- $foreignkeys = array(
- 'hotpot'=>$record->id,
- 'text'=>'hotpot_strings'
- );
- return hotpot_restore_records(
- $restore, $status, $xml, 'hotpot_questions', $foreignkeys, '', 'QUESTION_DATA', 'QUESTION'
- );
-}
-function hotpot_restore_attempts(&$restore, $status, &$xml, &$record, $hotpot_v20=false) {
- // $xml is an XML tree for a hotpot record
- // $record is the newly added hotpot record
- global $DB;
- $foreignkeys = array(
- 'userid'=>'user',
- 'hotpot'=>$record->id,
- );
- $more_restore = '';
- $more_restore .= 'hotpot_restore_details($restore, $status, $xml, $record);';
- if ($hotpot_v20) {
- // HotPot v2.0.x (regenerate questions and responses from details)
- $more_restore .= 'hotpot_add_attempt_details($record);'; // see "hotpot/lib.php"
- } else {
- // HotPot v2.1+
- $more_restore .= '$status = hotpot_restore_responses($restore, $status, $xml, $record);';
- // save clickreportid (to be updated it later)
- $more_restore .= 'if (!empty($record->clickreportid)) {';
- $more_restore .= '$GLOBALS["hotpot_backup_clickreportids"][$record->id]=$record->clickreportid;';
- $more_restore .= '}';
- // initialize global array to store clickreportids
- $GLOBALS["hotpot_backup_clickreportids"] = array();
- }
- $status = hotpot_restore_records(
- $restore, $status, $xml, 'hotpot_attempts', $foreignkeys, $more_restore, 'ATTEMPT_DATA', 'ATTEMPT'
- );
- if ($hotpot_v20) {
- if ($status) {
- global $CFG;
- // based on code in "mod/hotpot/db/update_to_v2.php"
- $params = array($record->id);
- $DB->execute("UPDATE {hotpot_attempts} SET status=1 WHERE hotpot=? AND timefinish=0 AND score IS NULL", $params);
- $DB->execute("UPDATE {hotpot_attempts} SET status=3 WHERE hotpot=? AND timefinish>0 AND score IS NULL", $params);
- $DB->execute("UPDATE {hotpot_attempts} SET status=4 WHERE hotpot=? AND timefinish>0 AND score IS NOT NULL", $params);
- $DB->execute("UPDATE {hotpot_attempts} SET clickreportid=id WHERE hotpot=? AND clickreportid IS NULL", $params);
- }
- } else {
- $status = hotpot_restore_clickreportids($restore, $status);
- unset($GLOBALS["hotpot_backup_clickreportids"]); // tidy up
- }
- return $status;
-}
-function hotpot_restore_clickreportids(&$restore, $status) {
- // update clickreport ids, if any
- global $CFG, $DB;
- foreach ($GLOBALS["hotpot_backup_clickreportids"] as $id=>$clickreportid) {
- if ($status) {
- $attempt_record = backup_getid($restore->backup_unique_code, 'hotpot_attempts', $clickreportid);
- if ($attempt_record) {
- $new_clickreportid = $attempt_record->new_id;
- $status = $DB->execute("UPDATE {hotpot_attempts} SET clickreportid=? WHERE id=?", array($new_clickreportid, $id));
- } else {
- // New clickreport id could not be found
- if (!defined('RESTORE_SILENTLY')) {
- print "- New clickreportid could not be found: attempt id=$id, clickreportid=$clickreportid
";
- }
- $status = false;
- }
- }
- }
- return $status;
-}
-function hotpot_restore_responses(&$restore, $status, &$xml, &$record) {
- // $xml is an XML tree for an attempt record
- // $record is the newly added attempt record
- $foreignkeys = array(
- 'attempt'=>$record->id,
- 'question'=>'hotpot_questions',
- 'correct'=>'hotpot_strings',
- 'wrong'=>'hotpot_strings',
- 'ignored'=>'hotpot_strings'
- );
- return hotpot_restore_records(
- $restore, $status, $xml, 'hotpot_responses', $foreignkeys, '', 'RESPONSE_DATA', 'RESPONSE'
- );
-}
-function hotpot_restore_details(&$restore, $status, &$xml, &$record) {
- global $DB;
- // $xml is an XML tree for an attempt record
- // $record is the newly added attempt record
- if (empty($record->details)) {
- $status = true;
- } else {
- $details = new stdClass();
- $details->attempt = $record->id;
- $details->details = $record->details;
- if ($DB->insert_record('hotpot_details', $details)) {
- $status = true;
- } else {
- if (!defined('RESTORE_SILENTLY')) {
- print "- Details record could not be updated: attempt=$record->attempt
";
- }
- $status = false;
- }
- }
- return $status;
-}
-function hotpot_restore_records(&$restore, $status, &$xml, $table, $foreign_keys, $more_restore='', $records_TAG='', $record_TAG='', $secondary_key='') {
-// general purpose function to restore a group of records
- // $restore : (see "hotpot_restore_mods" above)
- // $xml : an XML tree (or sub-tree)
- // $records_TAG : (optional) the name of an XML tag which starts a block of records
- // If no $records_TAG is specified, $xml is assumed to be a block of records
- // $record_TAG : (optional) the name of an XML tag which starts a single record
- // If no $record_TAG is specified, the block of records is assumed to be a single record
- // other parameters are explained in "hotpot_restore_record" below
-
- $i = 0; // index for $records_TAG
- do {
- unset($xml_records);
- if ($records_TAG) {
- if (isset($xml[$records_TAG][$i]['#'])) {
- $xml_records = &$xml[$records_TAG][$i]['#'];
- }
- } else {
- if ($i==0) {
- $xml_records = &$xml;
- }
- }
- if (isset($xml_records)) {
- $ii = 0; // index for $record_TAG
- do {
- unset($xml_record);
- if ($record_TAG) {
- if (isset($xml_records[$record_TAG][$ii]['#'])) {
- $xml_record = &$xml_records[$record_TAG][$ii]['#'];
- }
- } else {
- if ($ii==0) {
- $xml_record = &$xml_records;
- }
- }
- if (isset($xml_record)) {
- $status = hotpot_restore_record(
- $restore, $status, $xml_record, $table, $foreign_keys, $more_restore, $secondary_key
- );
- }
- $ii++;
- } while ($status && isset($xml_record));
- }
- $i++;
- } while ($status && isset($xml_records));
- return $status;
-}
-function hotpot_restore_record(&$restore, $status, &$xml, $table, $foreign_keys, $more_restore, $secondary_key) {
-// general purpose function to restore a single record
- // $restore : (see "hotpot_restore_mods" above)
- // $status : current status of backup (true or false)
- // $xml : XML tree of current record
- // $table : name of Moodle database table to restore to
- // $foreign_keys : array of foreign keys, if any, specifed as $key=>$value
- // $key : the name of a field in the current $record
- // $value : if $value is numeric, then $record->$key is set to $value.
- // Otherwise $value is assumed to be a table name and $record->$key
- // is treated as a comma separated list of ids in that table
- // $more_restore : optional PHP code to be eval(uated) for each record
- // $secondary_key :
- // the name of the secondary key field, if any, in the current $record.
- // If this field is specified, then the current record will only be added
- // if the $record->$secondarykey value does not already exist in $table
-
- // maintain a cache of info on table columns
- global $DB;
-
- static $table_columns = array();
- if (empty($table_columns[$table])) {
- global $CFG, $DB;
- $table_columns[$table] = $DB->get_columns($table);
- }
-
- // get values for fields in this record
- $record = new stdClass();
- $TAGS = array_keys($xml);
- foreach ($TAGS as $TAG) {
- $value = $xml[$TAG][0]['#'];
- if (is_string($value)) {
- $tag = strtolower($TAG);
- $record->$tag = backup_todb($value);
- }
- }
-
- // update foreign keys, if any
- $ok = true;
- foreach ($foreign_keys as $key=>$value) {
- if (is_numeric($value)) {
- $record->$key = $value;
- } else {
- $key_table = $value;
- $new_ids = array();
- if (isset($record->$key)) {
- $old_ids = explode(',', $record->$key);
- foreach ($old_ids as $old_id) {
- if (empty($old_id)) {
- // do nothing
- } else {
- $key_record = backup_getid($restore->backup_unique_code, $key_table, $old_id);
- if ($key_record) {
- $new_ids[] = $key_record->new_id;
- } else {
- // foreign key could not be updated
- if (!defined('RESTORE_SILENTLY')) {
- print "- Warning:
Foreign key could not be updated: ";
- print "'$key_table' record (old id=$old_id) is missing from backup data ";
- print "'$table' record ";
- if (isset($record->id)) {
- print "(old id=$record->id) ";
- }
- print "was not restored ";
- }
- $ok = false;
- }
- }
- }
- }
- $record->$key = implode(',', $new_ids);
- }
- }
-
- // set md5 keys if necessary (restoring from Moodle<1.6)
- if ($table=='hotpot_questions' && empty($record->md5key)) {
- $record->md5key = md5($record->name);
- }
- if ($table=='hotpot_strings' && empty($record->md5key)) {
- $record->md5key = md5($record->string);
- }
-
- // check all "not null" fields have been set
- foreach ($table_columns[$table] as $column) {
- if ($column->not_null) {
- $name = $column->name;
- if ($name=='id' || (isset($record->$name) && ! is_null($record->$name))) {
- // do nothing
- } else if (isset($column->default_value)) {
- $record->$name = $column->default_value;
- } else if (preg_match('/[INTD]/', $column->meta_type)) {
- $record->$name = 0;
- } else {
- $record->$name = '';
- }
- }
- }
-
- // check everything is OK so far
- if ($ok) {
- // store old record id, if necessary
- if (isset($record->id)) {
- $record->old_id = $record->id;
- unset($record->id);
- }
- // if there is a secondary key field ...
- if ($secondary_key) {
- // check to see if a record with the same value already exists
- $key_records = $DB->get_records($table, array($secondary_key=>$record->$secondary_key));
- if ($key_records) {
- // set new record id from already existing record
- $key_record = reset($key_records);
- $record->id = $key_record->id;
- }
- }
- if (empty($record->id)) {
- // add the $record (and get new id)
- $record->id = $DB->insert_record($table, $record);
- }
- // check $record was added (or found)
- if (is_numeric($record->id)) {
- // if there was an old id, save a mapping to the new id
- if (isset($record->old_id)) {
- backup_putid($restore->backup_unique_code, $table, $record->old_id, $record->id);
- }
- } else {
- // failed to add (or find) $record
- if (!defined('RESTORE_SILENTLY')) {
- print "- Record could not be added: table=$table
";
- }
- $status = false;
- }
- // restore related records, if required
- if ($more_restore) {
- eval($more_restore);
- }
- }
- return $status;
-}
-//This function returns a log record with all the necessay transformations
-//done. It's used by restore_log_module() to restore modules log.
-function hotpot_restore_logs($restore, $log) {
- // assume the worst
- $status = false;
- switch ($log->action) {
- case "add":
- case "update":
- case "view":
- if ($log->cmid) {
- //Get the new_id of the module (to recode the info field)
- $mod = backup_getid($restore->backup_unique_code, $log->module, $log->info);
- if ($mod) {
- $log->url = "view.php?id=".$log->cmid;
- $log->info = $mod->new_id;
- $status = true;
- }
- }
- break;
- case "view all":
- $log->url = "index.php?id=".$log->course;
- $status = true;
- break;
- case "report":
- if ($log->cmid) {
- //Get the new_id of the module (to recode the info field)
- $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
- if ($mod) {
- $log->url = "report.php?id=".$log->cmid;
- $log->info = $mod->new_id;
- $status = true;
- }
- }
- break;
- case "attempt":
- case "submit":
- case "review":
- if ($log->cmid) {
- //Get the new_id of the module (to recode the info field)
- $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
- if ($mod) {
- //Extract the attempt id from the url field
- $attemptid = substr(strrchr($log->url,"="),1);
- //Get the new_id of the attempt (to recode the url field)
- $attempt = backup_getid($restore->backup_unique_code,"hotpot_attempts",$attemptid);
- if ($attempt) {
- $log->url = "review.php?id=".$log->cmid."&attempt=".$attempt->new_id;
- $log->info = $mod->new_id;
- $status = true;
- }
- }
- }
- break;
- default:
- // Oops, unknown $log->action
- if (!defined('RESTORE_SILENTLY')) {
- print "action (".$log->module."-".$log->action.") unknown. Not restored ";
- }
- break;
- } // end switch
- return $status ? $log : false;
-}
-
-function hotpot_decode_content_links($content, $restore) {
- $search = '/\$@(HOTPOT)\*([a-z]+)\*([a-z]+)\*([0-9]+)@\$/is';
- if (preg_match_all($search, $content, $matches, PREG_OFFSET_CAPTURE)) {
- $i_max = count($matches[0]) - 1;
- for ($i=$i_max; $i>=0; $i--) {
- $start = $matches[0][$i][1];
- $length = strlen($matches[0][$i][0]);
- $replace = hotpot_decode_content_link(
- // $scriptname, $paramname, $paramvalue, $restore
- $matches[2][$i][0], $matches[3][$i][0], $matches[4][$i][0], $restore
- );
- $content = substr_replace($content, $replace, $start, $length);
- }
- }
- return $content;
-}
-
-function hotpot_decode_content_link($scriptname, $paramname, $paramvalue, &$restore) {
- global $CFG;
-
- $table = '';
- switch ($paramname) {
- case 'id':
- switch ($scriptname) {
- case 'index':
- $table = 'course';
- break;
- case 'report':
- case 'review':
- case 'view':
- $table = 'course_modules';
- break;
- case 'attempt':
- $table = 'hotpot_attempts';
- break;
- }
- break;
- case 'hp':
- case 'hotpotid':
- $table = 'hotpot';
- break;
- }
-
- $new_id = 0;
- if ($table) {
- if ($rec = backup_getid($restore->backup_unique_code, $table, $paramvalue)) {
- $new_id = $rec->new_id;
- }
- }
-
- return "$CFG->wwwroot/mod/hotpot/$scriptname.php?$paramname=$new_id";
-}
-
diff --git a/mod/hotpot/review.php b/mod/hotpot/review.php
deleted file mode 100644
index 70622268afd..00000000000
--- a/mod/hotpot/review.php
+++ /dev/null
@@ -1,251 +0,0 @@
-set_url('/mod/hotpot/review.php', array('id'=>$id,'attempt'=>$attempt));
- if (! $cm = get_coursemodule_from_id('hotpot', $id)) {
- print_error('invalidcoursemodule');
- }
- if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
- print_error('coursemisconf');
- }
- if (! $hotpot = $DB->get_record("hotpot", array("id"=>$cm->instance))) {
- print_error('invalidcoursemodule');
- }
- } else {
- $PAGE->set_url('/mod/hotpot/review.php', array('hp'=>$hp,'attempt'=>$attempt));
- if (! $hotpot = $DB->get_record("hotpot", array("id"=>$hp))) {
- print_error('invalidcoursemodule');
- }
- if (! $course = $DB->get_record("course", array("id"=>$hotpot->course))) {
- print_error('coursemisconf');
- }
- if (! $cm = get_coursemodule_from_instance("hotpot", $hotpot->id, $course->id)) {
- print_error('invalidcoursemodule');
- }
- }
- if (! $attempt = $DB->get_record("hotpot_attempts", array("id"=>$attempt))) {
- print_error('invalidattemptid', 'hotpot');
- }
-
- require_login($course, true, $cm);
-
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
- if (!has_capability('mod/hotpot:viewreport',$context)) {
- if (!$hotpot->review) {
- print_error("noreview", "quiz");
- }
- //if (time() < $hotpot->timeclose) {
- // print_error("noreviewuntil", "quiz", '', userdate($hotpot->timeclose));
- //}
- if ($attempt->userid != $USER->id) {
- print_error('notyourattempt', 'hotpot');
- }
- }
- add_to_log($course->id, "hotpot", "review", "review.php?id=$cm->id&attempt=$attempt->id", "$hotpot->id", "$cm->id");
-// Print the page header
- $strmodulenameplural = get_string("modulenameplural", "hotpot");
- $strmodulename = get_string("modulename", "hotpot");
- // print header
-
- $PAGE->requires->js('/lib/overlib/overlib.js', true);
- $PAGE->requires->js('/lib/overlib/overlib_cssstyle.js', true);
- $PAGE->set_title(format_string($course->shortname) . ": $hotpot->name");
- $PAGE->set_heading($course->fullname);
- echo $OUTPUT->header();
- print ''; // for overlib
- echo $OUTPUT->heading($hotpot->name);
- hotpot_print_attempt_summary($hotpot, $attempt);
- hotpot_print_review_buttons($course, $hotpot, $attempt, $context);
- $action = has_capability('mod/hotpot:viewreport',$context) ? optional_param('action', '', PARAM_ALPHA) : '';
- if ($action) {
- $xml = $DB->get_field('hotpot_details', 'details', array('attempt'=>$attempt->id));
- print ' ';
- switch ($action) {
- case 'showxmltree':
- print '';
- $xml_tree = new hotpot_xml_tree($xml, "['hpjsresult']['#']");
- print_r ($xml_tree->xml_value('fields'));
- print '';
- break;
- case 'showxmlsource':
- print htmlspecialchars($xml);
- break;
- default:
- print "Action '$action' not recognized";
- }
- print ' ';
- } else {
- hotpot_print_attempt_details($hotpot, $attempt);
- }
- hotpot_print_review_buttons($course, $hotpot, $attempt, $context);
- echo $OUTPUT->footer();
-///////////////////////////
-// functions
-///////////////////////////
-function hotpot_print_attempt_summary(&$hotpot, &$attempt) {
- // start table
- global $OUTPUT;
- echo $OUTPUT->box_start("generalbox boxaligncenter boxwidthwide");
- print ''."\n";
- // add attempt properties
- $fields = array('attempt', 'score', 'penalties', 'status', 'timetaken', 'timerecorded');
- foreach ($fields as $field) {
- switch ($field) {
- case 'score':
- $value = hotpot_format_score($attempt);
- break;
- case 'status':
- $value = hotpot_format_status($attempt);
- break;
- case 'timerecorded':
- $value = empty($attempt->timefinish) ? '-' : userdate($attempt->timefinish);
- break;
- case 'timetaken':
- $value = empty($attempt->timefinish) ? '-' : format_time($attempt->timefinish - $attempt->timestart);
- break;
- default:
- $value = isset($attempt->$field) ? $attempt->$field : NULL;
- }
- if (isset($value)) {
- switch ($field) {
- case 'status':
- case 'timerecorded':
- $name = get_string('report'.$field, 'hotpot');
- break;
- case 'penalties':
- $name = get_string('penalties', 'hotpot');
- break;
- default:
- $name = get_string($field, 'quiz');
- }
- print '| '.$value.' | ';
- }
- }
- // finish table
- print ' ';
- echo $OUTPUT->box_end();
-}
-function hotpot_print_review_buttons(&$course, &$hotpot, &$attempt, $context) {
- global $DB, $OUTPUT;
-
- print "\n".'';
- print "\n\n".'| ';
- echo $OUTPUT->single_button(new moodle_url("report.php", array('hp'=>$hotpot->id)), get_string('continue'));
- if (has_capability('mod/hotpot:viewreport',$context) && $DB->record_exists('hotpot_details', array('attempt'=>$attempt->id))) {
- print " | \n".'';
- echo $OUTPUT->single_button(new moodle_url("review.php", array('hp'=>$hotpot->id, 'attempt'=>$attempt->id, 'action'=>'showxmlsource')), get_string('showxmlsource', 'hotpot'));
- print " | \n".'';
- echo $OUTPUT->single_button(new moodle_url("review.php", array('hp'=>$hotpot->id,'attempt'=>$attempt->id, 'action'=>'showxmltree')), get_string('showxmltree', 'hotpot'));
- $colspan = 3;
- } else {
- $colspan = 1;
- }
- print " | \n \n";
- print '| ';
- echo $OUTPUT->spacer(array('height'=>4, 'width'=>1)); // should be done with CSS instead
- print " | \n";
- print " \n";
-}
-function hotpot_print_attempt_details(&$hotpot, &$attempt) {
- global $DB, $OUTPUT;
-
- // define fields to print
- $textfields = array('correct', 'ignored', 'wrong');
- $numfields = array('score', 'weighting', 'hints', 'clues', 'checks');
- $fields = array_merge($textfields, $numfields);
- $q = array(); // questions
- $f = array(); // fields
- foreach ($fields as $field) {
- $name = get_string($field, 'hotpot');
- $f[$field] = array('count'=>0, 'name'=>$name);
- }
- // get questions and responses for this attempt
- $questions = $DB->get_records('hotpot_questions', array('hotpot'=>$hotpot->id), 'id');
- $responses = $DB->get_records('hotpot_responses', array('attempt'=>$attempt->id), 'id');
- if ($questions && $responses) {
- foreach ($responses as $response) {
- $id = $response->question;
- foreach ($fields as $field) {
- if (!isset($f[$field])) {
- $name = get_string($field, 'hotpot');
- $f[$field] = array('count'=>0, 'name'=>$name);
- }
- if (isset($response->$field)) {
- $f[$field]['count']++;
- if (!isset($q[$id])) {
- $name = hotpot_get_question_name($questions[$id]);
- $q[$id] = array('name'=>$name);
- }
- $q[$id][$field] = $response->$field;
- }
- }
- }
- }
- // count the number of columns required in the table
- $colspan = 0;
- foreach ($numfields as $field) {
- if ($f[$field]['count']) {
- $colspan += 2;
- }
- }
- $colspan = max(2, $colspan);
- // start table of questions and responses
- echo $OUTPUT->box_start("generalbox boxaligncenter boxwidthwide");
- print ''."\n";
- if (empty($q)) {
- print '| '.get_string("noresponses", "hotpot")." | \n";
- } else {
- // flag to ensure separators are only printed before the 2nd and subsequent questions
- $printseparator = false;
- foreach ($q as $i=>$question) {
- // flag to ensure questions are only printed when there is at least one response
- $printedquestion = false;
- // add rows of text fields
- foreach ($textfields as $field) {
- if (isset($question[$field])) {
- $text = hotpot_strings($question[$field]);
- if (trim($text)) {
- // print question if necessary
- if (!$printedquestion) {
- if ($printseparator) {
- print ' | '."\n";
- }
- $printseparator = true;
- print '| '.$question['name'].' | '."\n";
- $printedquestion = true;
- }
- // print response
- print '| '.$text.' | '."\n";
- }
- }
- }
- // add row of numeric fields
- print '';
- foreach ($numfields as $field) {
- if ($f[$field]['count']) {
- // print question if necessary
- if (!$printedquestion) {
- print '| '.$question['name']." | \n";
- $printedquestion = true;
- }
- // print numeric response
- $value = isset($question[$field]) ? $question[$field] : '-';
- print '| '.$value.' | ';
- }
- }
- print " \n";
- } // foreach $q
- }
- // finish table
- print " \n";
- echo $OUTPUT->box_end();
-}
-
diff --git a/mod/hotpot/settings.php b/mod/hotpot/settings.php
deleted file mode 100644
index 85fde9d2274..00000000000
--- a/mod/hotpot/settings.php
+++ /dev/null
@@ -1,11 +0,0 @@
-fulltree) {
- $settings->add(new admin_setting_configcheckbox('hotpot_showtimes', get_string('showtimes', 'hotpot'),
- get_string('configshowtimes', 'hotpot'), 0) );
-
- $settings->add(new admin_setting_configtext('hotpot_excelencodings', get_string('excelencodings', 'hotpot'),
- get_string('configexcelencodings', 'hotpot'), '') );
-}
diff --git a/mod/hotpot/show.php b/mod/hotpot/show.php
deleted file mode 100644
index ebadb2ca1c3..00000000000
--- a/mod/hotpot/show.php
+++ /dev/null
@@ -1,75 +0,0 @@
-action = required_param('action', PARAM_ALPHA);
- $params->course = required_param('course', PARAM_INT);
- $params->reference = required_param('reference', PARAM_PATH);
-
- $PAGE->set_url('/mod/hotpot/show.php', array('action'=>$params->action, 'course'=>$params->course, 'reference'=>$params->reference));
-
- require_login($params->course);
-
- if (!has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $params->course))) {
- print_error('nopermissiontoviewpage');
- }
- if (has_capability('mod/hotpot:viewreport', get_context_instance(CONTEXT_SYSTEM))) {
- $params->location = optional_param('location', HOTPOT_LOCATION_COURSEFILES, PARAM_INT);
- } else {
- $params->location = HOTPOT_LOCATION_COURSEFILES;
- }
- $title = get_string($params->action, 'hotpot').': '.$params->reference;
- $PAGE->set_title($title);
- $PAGE->set_heading($title);
- echo $OUTPUT->header();
- hotpot_print_show_links($params->course, $params->location, $params->reference);
-?>
-
-box_start("generalbox boxaligncenter boxwidthwide");
- if($hp = new hotpot_xml_quiz($params)) {
- print '';
- switch ($params->action) {
- case 'showxmlsource':
- print htmlspecialchars($hp->source);
- break;
- case 'showxmltree':
- if (isset($hp->xml)) {
- print_r($hp->xml);
- }
- break;
- case 'showhtmlsource':
- print htmlspecialchars($hp->html);
- break;
- case 'showhtmlquiz':
- print $hp->html;
- break;
- }
- print '';
- } else {
- echo $OUTPUT->box("Could not open Hot Potatoes XML file", "errorboxcontent generalbox");
- }
- echo $OUTPUT->box_end();
- print ' ';
- echo $OUTPUT->close_window_button();
-?>
diff --git a/mod/hotpot/template/default.php b/mod/hotpot/template/default.php
deleted file mode 100644
index b2cc108b955..00000000000
--- a/mod/hotpot/template/default.php
+++ /dev/null
@@ -1,111 +0,0 @@
-parent->template_dirpath.DIRECTORY_SEPARATOR.$filename;
- // try and open the template file
- if (!file_exists($filepath) || !is_readable($filepath)) {
- print_error('cannotopentemplate', '', $this->parent->course_homeurl, $filepath);
- }
- // read in the template and close the file
- $this->$tag = file_get_contents($filepath);
- // expand the blocks and strings in the template
- $this->expand_blocks($tag);
- $this->expand_strings($tag);
- if ($tag=='temporary') {
- $template = $this->$tag;
- $this->$tag = '';
- return $template;
- }
- }
- function expand_blocks($tag) {
- // get block $names
- // [1] the full block name (including optional leading 'str' or 'incl')
- // [2] leading 'incl' or 'str', if any
- // [3] the real block name ([1] without [2])
- $search = '/\[\/((incl|str)?((?:\w|\.)+))\]/';
- preg_match_all($search, $this->$tag, $names);
- $i_max = count($names[0]);
- for ($i=0; $i<$i_max; $i++) {
- $method = $this->parent->template_dir.'_expand_'.str_replace('.', '', $names[3][$i]);
- if (method_exists($this, $method)) {
- eval('$value=$this->'.$method.'();');
- $search = '/\['.$names[1][$i].'\](.*?)\[\/'.$names[1][$i].'\]/s';
- preg_match_all($search, $this->$tag, $blocks);
- $ii_max = count($blocks[0]);
- for ($ii=0; $ii<$ii_max; $ii++) {
- $replace = empty($value) ? '' : $blocks[1][$ii];
- $this->$tag = str_replace($blocks[0][$ii], $replace, $this->$tag);
- }
- } else {
- print_error('cannotfindmethod', 'hotpot', $this->parent->course_homeurl, $method);
- }
- }
- }
- function expand_strings($tag, $search='') {
- if (empty($search)) {
- // default $search $pattern
- $search = '/\[(?:bool|int|str)(\\w+)\]/';
- }
- preg_match_all($search, $this->$tag, $matches);
- $i_max = count($matches[0]);
- for ($i=0; $i<$i_max; $i++) {
- $method = $this->parent->template_dir.'_expand_'.$matches[1][$i];
- if (method_exists($this, $method)) {
- eval('$replace=$this->'.$method.'();');
- $this->$tag = str_replace($matches[0][$i], $replace, $this->$tag);
- }
- }
- }
- function bool_value($tags, $more_tags="[0]['#']") {
- $value = $this->parent->xml_value($tags, $more_tags);
- return empty($value) ? 'false' : 'true';
- }
- function int_value($tags, $more_tags="[0]['#']") {
- return intval($this->parent->xml_value($tags, $more_tags));
- }
- function js_value($tags, $more_tags="[0]['#']", $convert_to_unicode=false) {
- return $this->js_safe($this->parent->xml_value($tags, $more_tags), $convert_to_unicode);
- }
- function js_safe($str, $convert_to_unicode=false) {
- // encode a string for javascript
- // decode "<" and ">" - not necesary as it was done by xml_value()
- // $str = strtr($str, array('<' => '<', '>' => '>'));
- // escape single quotes and backslashes
- $str = strtr($str, array("'"=>"\\'", '\\'=>'\\\\'));
- // convert newlines (win = "\r\n", mac="\r", linix/unix="\n")
- $nl = '\\n'; // javascript newline
- $str = strtr($str, array("\r\n"=>$nl, "\r"=>$nl, "\n"=>$nl));
- // convert (hex and decimal) html entities to unicode, if required
- if ($convert_to_unicode) {
- $str = preg_replace('/([0-9A-F]+);/i', '\\u\\1', $str);
- $str = preg_replace_callback('/(\d+);/', array(&$this, 'js_safe_callback'), $str);
- }
- return $str;
- }
- function js_safe_callback(&$matches) {
- return '\\u'.sprintf('%04X', $matches[1]);
- }
- function get_halfway_color($x, $y) {
- // returns the $color that is half way between $x and $y
- $color = $x; // default
- $rgb = '/^\#?([0-9a-f])([0-9a-f])([0-9a-f])$/i';
- $rrggbb = '/^\#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i';
- if ((
- preg_match($rgb, $x, $x_matches) ||
- preg_match($rrggbb, $x, $x_matches)
- ) && (
- preg_match($rgb, $y, $y_matches) ||
- preg_match($rrggbb, $y, $y_matches)
- )) {
- $color = '#';
- for ($i=1; $i<=3; $i++) {
- $x_dec = hexdec($x_matches[$i]);
- $y_dec = hexdec($y_matches[$i]);
- $color .= sprintf('%02x', min($x_dec, $y_dec) + abs($x_dec-$y_dec)/2);
- }
- }
- return $color;
- }
-}
-
diff --git a/mod/hotpot/template/v6.php b/mod/hotpot/template/v6.php
deleted file mode 100644
index ad7e63a64da..00000000000
--- a/mod/hotpot/template/v6.php
+++ /dev/null
@@ -1,1515 +0,0 @@
-parent = &$parent;
-
- $get_js = optional_param('js', false);
- $get_css = optional_param('css', false);
-
- if (!empty($get_css)) {
- // set $this->css
- $this->v6_expand_StyleSheet();
-
- } else if (!empty($get_js)) {
- // set $this->js
- $this->read_template($this->parent->draganddrop.$this->parent->quiztype.'6.js_', 'js');
-
- } else {
- // set $this->html
- $this->read_template($this->parent->draganddrop.$this->parent->quiztype.'6.ht_', 'html');
- }
-
- // expand special strings, if any
- $pattern = '';
- switch ($this->parent->quiztype) {
- case 'jcloze':
- $pattern = '/\[(PreloadImageList)\]/';
- break;
- case 'jcross':
- $pattern = '/\[(PreloadImageList|ShowHideClueList)\]/';
- break;
- case 'jmatch':
- $pattern = '/\[(PreloadImageList|QsToShow|FixedArray|DragArray)\]/';
- break;
- case 'jmix':
- $pattern = '/\[(PreloadImageList|SegmentArray|AnswerArray)\]/';
- break;
- case 'jquiz':
- $pattern = '/\[(PreloadImageList|QsToShow)\]/';
- break;
- }
- if (!empty($pattern)) {
- $this->expand_strings('html', $pattern);
- }
- // fix doctype (convert short dtd to long dtd)
- $this->html = preg_replace(
- '/]*>/',
- '',
- $this->html, 1
- );
- }
-
- // captions and messages
-
- function v6_expand_AlsoCorrect() {
- return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',also-correct');
- }
- function v6_expand_CapitalizeFirst() {
- return $this->bool_value('hotpot-config-file,'.$this->parent->quiztype.',capitalize-first-letter');
- }
- function v6_expand_CheckCaption() {
- return $this->parent->xml_value('hotpot-config-file,global,check-caption');
- }
- function v6_expand_CorrectIndicator() {
- return $this->js_value('hotpot-config-file,global,correct-indicator');
- }
- function v6_expand_Back() {
- return $this->int_value('hotpot-config-file,global,include-back');
- }
- function v6_expand_BackCaption() {
- return str_replace('<=', '<=', $this->parent->xml_value('hotpot-config-file,global,back-caption'));
- }
- function v6_expand_ClickToAdd() {
- return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',click-to-add');
- }
- function v6_expand_ClueCaption() {
- return $this->parent->xml_value('hotpot-config-file,global,clue-caption');
- }
- function v6_expand_Clues() {
- return $this->int_value('hotpot-config-file,'.$this->parent->quiztype.',include-clues');
- }
- function v6_expand_Contents() {
- return $this->int_value('hotpot-config-file,global,include-contents');
- }
- function v6_expand_ContentsCaption() {
- return $this->parent->xml_value('hotpot-config-file,global,contents-caption');
- }
- function v6_expand_GuessCorrect() {
- return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',guess-correct');
- }
- function v6_expand_GuessIncorrect() {
- return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',guess-incorrect');
- }
- function v6_expand_Hint() {
- return $this->int_value('hotpot-config-file,'.$this->parent->quiztype.',include-hint');
- }
- function v6_expand_HintCaption() {
- return $this->parent->xml_value('hotpot-config-file,global,hint-caption');
- }
- function v6_expand_IncorrectIndicator() {
- return $this->js_value('hotpot-config-file,global,incorrect-indicator');
- }
- function v6_expand_LastQCaption() {
- $caption = $this->parent->xml_value('hotpot-config-file,global,last-q-caption');
- return ($caption=='<=' ? '<=' : $caption);
- }
- function v6_expand_NextCorrect() {
- $value = $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',next-correct-part');
- if (empty($value)) { // jquiz
- $value = $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',next-correct-letter');
- }
- return $value;
- }
- function v6_expand_NextEx() {
- return $this->int_value('hotpot-config-file,global,include-next-ex');
- }
- function v6_expand_NextExCaption() {
- return str_replace('=>', '=>', $this->parent->xml_value('hotpot-config-file,global,next-ex-caption'));
- }
- function v6_expand_NextQCaption() {
- return $this->parent->xml_value('hotpot-config-file,global,next-q-caption');
- }
- function v6_expand_OKCaption() {
- return $this->parent->xml_value('hotpot-config-file,global,ok-caption');
- }
- function v6_expand_Restart() {
- return $this->int_value('hotpot-config-file,'.$this->parent->quiztype.',include-restart');
- }
- function v6_expand_RestartCaption() {
- return $this->parent->xml_value('hotpot-config-file,global,restart-caption');
- }
- function v6_expand_ShowAllQuestionsCaption() {
- return $this->js_value('hotpot-config-file,global,show-all-questions-caption');
- }
- function v6_expand_ShowOneByOneCaption() {
- return $this->js_value('hotpot-config-file,global,show-one-by-one-caption');
- }
- function v6_expand_TheseAnswersToo() {
- return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',also-correct');
- }
- function v6_expand_ThisMuch() {
- return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',this-much-correct');
- }
- function v6_expand_Undo() {
- return $this->int_value('hotpot-config-file,'.$this->parent->quiztype.',include-undo');
- }
- function v6_expand_UndoCaption() {
- return $this->parent->xml_value('hotpot-config-file,global,undo-caption');
- }
- function v6_expand_YourScoreIs() {
- return $this->js_value('hotpot-config-file,global,your-score-is');
- }
-
- // reading
-
- function v6_expand_Reading() {
- return $this->int_value('data,reading,include-reading');
- }
- function v6_expand_ReadingText() {
- $title = $this->v6_expand_ReadingTitle();
- $value = $this->parent->xml_value('data,reading,reading-text');
- $value = empty($value) ? '' : (''.$value.' ');
- return $title.$value;
- }
- function v6_expand_ReadingTitle() {
- $value = $this->parent->xml_value('data,reading,reading-title');
- return empty($value) ? '' : (''.$value.'');
- }
-
- // timer
-
- function v6_expand_Timer() {
- return $this->int_value('data,timer,include-timer');
- }
- function v6_expand_JSTimer() {
- return $this->read_template('hp6timer.js_');
- }
- function v6_expand_Seconds() {
- return $this->parent->xml_value('data,timer,seconds');
- }
-
- // send results
-
- function v6_expand_SendResults() {
- return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',send-email');
- }
- function v6_expand_JSSendResults() {
- return $this->read_template('hp6sendresults.js_');
- }
- function v6_expand_FormMailURL() {
- return $this->parent->xml_value('hotpot-config-file,global,formmail-url');
- }
- function v6_expand_EMail() {
- return $this->parent->xml_value('hotpot-config-file,global,email');
- }
- function v6_expand_NamePlease() {
- return $this->js_value('hotpot-config-file,global,name-please');
- }
-
- // preload images
-
- function v6_expand_PreloadImages() {
- $value = $this->v6_expand_PreloadImageList();
- return empty($value) ? false : true;
- }
- function v6_expand_PreloadImageList() {
-
- // check it has not been set already
- if (!isset($this->PreloadImageList)) {
-
- // the list of image urls
- $list = array();
-
- // extract tags
- $img_tag = htmlspecialchars('|<img.*?src="(.*?)".*?>|is');
- if (preg_match_all($img_tag, $this->parent->source, $matches)) {
- $list = $matches[1];
-
- // remove duplicates
- $list = array_unique($list);
- }
-
- // convert to comma delimited string
- $this->PreloadImageList = empty($list) ? '' : "'".implode(',', $list)."'";
- }
- return $this->PreloadImageList;
- }
-
- // html files (all quiz types)
-
- function v6_expand_PlainTitle() {
- return $this->parent->xml_value('data,title');
- }
- function v6_expand_ExerciseSubtitle() {
- return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',exercise-subtitle');
- }
- function v6_expand_Instructions() {
- return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',instructions');
- }
- function v6_expand_DublinCoreMetadata() {
- $dc = ''."\n";
- if (is_string($this->parent->xml_value('rdf:RDF,rdf:Description'))) {
- // do nothing (there is no more dc info)
- } else {
- $dc .= ''."\n";
- $dc .= ''."\n";
- }
- return $dc;
- }
- function v6_expand_FullVersionInfo() {
- global $CFG;
- require_once($CFG->hotpotroot.DIRECTORY_SEPARATOR.'version.php'); // set $module
- return $this->parent->xml_value('version').'.x (Moodle '.$CFG->release.', hotpot-module '.$this->parent->obj_value($module, 'release').')';
- }
- function v6_expand_HeaderCode() {
- return $this->parent->xml_value('hotpot-config-file,global,header-code');
- }
- function v6_expand_StyleSheet() {
- $this->read_template('hp6.cs_', 'css');
- $this->css = hotpot_convert_stylesheets_urls($this->parent->get_baseurl(), $this->parent->reference, $this->css);
- return $this->css;
- }
-
- // stylesheet (hp6.cs_)
-
- function v6_expand_PageBGColor() {
- return $this->parent->xml_value('hotpot-config-file,global,page-bg-color');
- }
- function v6_expand_GraphicURL() {
- return $this->parent->xml_value('hotpot-config-file,global,graphic-url');
- }
- function v6_expand_ExBGColor() {
- return $this->parent->xml_value('hotpot-config-file,global,ex-bg-color');
- }
-
- function v6_expand_FontFace() {
- return $this->parent->xml_value('hotpot-config-file,global,font-face');
- }
- function v6_expand_FontSize() {
- $value = $this->parent->xml_value('hotpot-config-file,global,font-size');
- return (empty($value) ? 'small' : $value);
- }
- function v6_expand_TextColor() {
- return $this->parent->xml_value('hotpot-config-file,global,text-color');
- }
- function v6_expand_TitleColor() {
- return $this->parent->xml_value('hotpot-config-file,global,title-color');
- }
- function v6_expand_LinkColor() {
- return $this->parent->xml_value('hotpot-config-file,global,link-color');
- }
- function v6_expand_VLinkColor() {
- return $this->parent->xml_value('hotpot-config-file,global,vlink-color');
- }
-
- function v6_expand_NavTextColor() {
- return $this->parent->xml_value('hotpot-config-file,global,page-bg-color');
- }
- function v6_expand_NavBarColor() {
- return $this->parent->xml_value('hotpot-config-file,global,nav-bar-color');
- }
- function v6_expand_NavLightColor() {
- $color = $this->parent->xml_value('hotpot-config-file,global,nav-bar-color');
- return $this->get_halfway_color($color, '#ffffff');
- }
- function v6_expand_NavShadeColor() {
- $color = $this->parent->xml_value('hotpot-config-file,global,nav-bar-color');
- return $this->get_halfway_color($color, '#000000');
- }
-
- function v6_expand_FuncLightColor() { // top-left of buttons
- $color = $this->parent->xml_value('hotpot-config-file,global,ex-bg-color');
- return $this->get_halfway_color($color, '#ffffff');
- }
- function v6_expand_FuncShadeColor() { // bottom right of buttons
- $color = $this->parent->xml_value('hotpot-config-file,global,ex-bg-color');
- return $this->get_halfway_color($color, '#000000');
- }
-
- // navigation buttons
-
- function v6_expand_NavButtons() {
- $back = $this->v6_expand_Back();
- $next_ex = $this->v6_expand_NextEx();
- $contents = $this->v6_expand_Contents();
- return (empty($back) && empty($next_ex) && empty($contents) ? false : true);
- }
- function v6_expand_NavBarJS() {
- return $this->v6_expand_NavButtons();
- }
-
- // switch off scorm
- function v6_expand_Scorm12() {
- return false;
- }
-
- // js files (all quiz types)
-
- function v6_expand_JSBrowserCheck() {
- return $this->read_template('hp6browsercheck.js_');
- }
- function v6_expand_JSButtons() {
- return $this->read_template('hp6buttons.js_');
- }
- function v6_expand_JSCard() {
- return $this->read_template('hp6card.js_');
- }
- function v6_expand_JSCheckShortAnswer() {
- return $this->read_template('hp6checkshortanswer.js_');
- }
- function v6_expand_JSHotPotNet() {
- return $this->read_template('hp6hotpotnet.js_');
- }
- function v6_expand_JSShowMessage() {
- return $this->read_template('hp6showmessage.js_');
- }
- function v6_expand_JSUtilities() {
- return $this->read_template('hp6utilities.js_');
- }
-
- // js files
-
- function v6_expand_JSJCloze6() {
- return $this->read_template('jcloze6.js_');
- }
- function v6_expand_JSJCross6() {
- return $this->read_template('jcross6.js_');
- }
- function v6_expand_JSJMatch6() {
- return $this->read_template('jmatch6.js_');
- }
- function v6_expand_JSJMix6() {
- return $this->read_template('jmix6.js_');
- }
- function v6_expand_JSJQuiz6() {
- return $this->read_template('jquiz6.js_');
- }
-
- // drag and drop
-
- function v6_expand_JSDJMatch6() {
- return $this->read_template('djmatch6.js_');
- }
- function v6_expand_JSDJMix6() {
- return $this->read_template('djmix6.js_');
- }
-
- // what are these for?
-
- function v6_expand_JSFJMatch6() {
- return $this->read_template('fjmatch6.js_');
- }
- function v6_expand_JSFJMix6() {
- return $this->read_template('fjmix6.js_');
- }
-
- // jmatch6.js_
-
- function v6_expand_ShuffleQs() {
- return $this->bool_value('hotpot-config-file,'.$this->parent->quiztype.',shuffle-questions');
- }
- function v6_expand_QsToShow() {
- $i = $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',show-limited-questions');
- if ($i) {
- $i = $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',questions-to-show');
- }
- if (empty($i)) {
- $i = 0;
- switch ($this->parent->quiztype) {
- case 'jmatch':
- $values = $this->parent->xml_values('data,matching-exercise,pair');
- $i = count($values);
- break;
- case 'jquiz':
- $tags = 'data,questions,question-record';
- while (($question="[$i]['#']") && $this->parent->xml_value($tags, $question)) {
- $i++;
- }
- break;
- } // end switch
- }
- return $i;
- }
- function v6_expand_MatchDivItems() {
- $this->set_jmatch_items();
-
- $l_keys = $this->shuffle_jmatch_items($this->l_items);
- $r_keys = $this->shuffle_jmatch_items($this->r_items);
-
- $options = '';
- foreach ($r_keys as $key) {
- if (! $this->r_items[$key]['fixed']) {
- $options .= ''."\n";
- }
- }
-
- $str = '';
- foreach ($l_keys as $key) {
- $str .= '| '.$this->l_items[$key]['text'].' | ';
- $str .= '';
- if ($this->r_items[$key]['fixed']) {
- $str .= $this->r_items[$key]['text'];
- } else {
- $str .= '';
- }
- $str .= ' | | ';
- }
- return $str;
- }
-
- // jmix6.js_
-
- function v6_expand_Punctuation() {
- $tags = 'data,jumbled-order-exercise';
- $chars = array_merge(
- $this->jmix_Punctuation("$tags,main-order,segment"),
- $this->jmix_Punctuation("$tags,alternate")
- );
- $chars = array_unique($chars);
- $chars = implode('', $chars);
- $chars = $this->js_safe($chars, true);
- return $chars;
- }
- function jmix_Punctuation($tags) {
- $chars = array();
-
- // all punctutation except '' (because they are used in html entities)
- $ENTITIES = $this->jmix_encode_punctuation('!"$%'."'".'()*+,-./:<=>?@[\]^_`{|}~');
- $pattern = "/([0-9A-F]+);/i";
- $i = 0;
-
- // get next segment (or alternate answer)
- while ($value = $this->parent->xml_value($tags, "[$i]['#']")) {
-
- // convert low-ascii punctuation to entities
- $value = strtr($value, $ENTITIES);
-
- // extract all hex HTML entities
- if (preg_match_all($pattern, $value, $matches)) {
-
- // loop through hex entities
- $m_max = count($matches[0]);
- for ($m=0; $m<$m_max; $m++) {
-
- // convert to hex number
- eval('$hex=0x'.$matches[1][$m].';');
-
- // is this a punctuation character?
- if (
- ($hex>=0x0020 && $hex<=0x00BF) || // ascii punctuation
- ($hex>=0x2000 && $hex<=0x206F) || // general punctuation
- ($hex>=0x3000 && $hex<=0x303F) || // CJK punctuation
- ($hex>=0xFE30 && $hex<=0xFE4F) || // CJK compatability
- ($hex>=0xFE50 && $hex<=0xFE6F) || // small form variants
- ($hex>=0xFF00 && $hex<=0xFF40) || // halfwidth and fullwidth forms (1)
- ($hex>=0xFF5B && $hex<=0xFF65) || // halfwidth and fullwidth forms (2)
- ($hex>=0xFFE0 && $hex<=0xFFEE) // halfwidth and fullwidth forms (3)
- ) {
- // add this character
- $chars[] = $matches[0][$m];
- }
- }
- }
- $i++;
- }
-
- return $chars;
- }
- function v6_expand_OpenPunctuation() {
- $tags = 'data,jumbled-order-exercise';
- $chars = array_merge(
- $this->jmix_OpenPunctuation("$tags,main-order,segment"),
- $this->jmix_OpenPunctuation("$tags,alternate")
- );
- $chars = array_unique($chars);
- $chars = implode('', $chars);
- $chars = $this->js_safe($chars, true);
- return $chars;
- }
- function jmix_OpenPunctuation($tags) {
- $chars = array();
-
- // unicode punctuation designations (pi="initial quote", ps="open")
- // http://www.sql-und-xml.de/unicode-database/pi.html
- // http://www.sql-und-xml.de/unicode-database/ps.html
- $pi = '0022|0027|00AB|2018|201B|201C|201F|2039';
- $ps = '0028|005B|007B|0F3A|0F3C|169B|201A|201E|2045|207D|208D|2329|23B4|2768|276A|276C|276E|2770|2772|2774|27E6|27E8|27EA|2983|2985|2987|2989|298B|298D|298F|2991|2993|2995|2997|29D8|29DA|29FC|3008|300A|300C|300E|3010|3014|3016|3018|301A|301D|FD3E|FE35|FE37|FE39|FE3B|FE3D|FE3F|FE41|FE43|FE47|FE59|FE5B|FE5D|FF08|FF3B|FF5B|FF5F|FF62';
- $pattern = "/(($pi|$ps);)/i";
-
- $ENTITIES = $this->jmix_encode_punctuation('"'."'".'(<[{');
-
- $i = 0;
- while ($value = $this->parent->xml_value($tags, "[$i]['#']")) {
- $value = strtr($value, $ENTITIES);
- if (preg_match_all($pattern, $value, $matches)) {
- $chars = array_merge($chars, $matches[0]);
- }
- $i++;
- }
-
- return $chars;
- }
- function jmix_encode_punctuation($str) {
- $ENTITIES = array();
- $i_max = strlen($str);
- for ($i=0; $i<$i_max; $i++) {
- $ENTITIES[$str{$i}] = ''.sprintf('%04X', ord($str{$i})).';';
- }
- return $ENTITIES;
- }
- function v6_expand_ExerciseTitle() {
- return $this->parent->xml_value('data,title');
- }
-
- // Jmix specials
-
- function v6_expand_SegmentArray() {
-
- $segments = array();
- $values = array();
- $VALUES = array();
-
- // XML tags to the start of a segment
- $tags = 'data,jumbled-order-exercise,main-order,segment';
-
- $i = 0;
- while ($value = $this->parent->xml_value($tags, "[$i]['#']")) {
- $VALUE = strtoupper($value);
- $key = array_search($VALUE, $VALUES);
- if (is_numeric($key)) {
- $segments[] = $key;
- } else {
- $segments[] = $i;
- $values[$i] = $value;
- $VALUES[$i] = $VALUE;
- }
- $i++;
- }
-
- $this->seed_random_number_generator();
- $keys = array_keys($segments);
- shuffle($keys);
-
- $str = '';
- for($i=0; $ijs_safe($values[$key], true)."';\n";
- $str .= "Segments[$i][1] = ".($key+1).";\n";
- $str .= "Segments[$i][2] = 0;\n";
- }
- return $str;
- }
- function v6_expand_AnswerArray() {
-
- $segments = array();
- $values = array();
- $VALUES = array();
- $escapedvalues = array();
-
- // XML tags to the start of a segment
- $tags = 'data,jumbled-order-exercise,main-order,segment';
-
- $i = 0;
- while ($value = $this->parent->xml_value($tags, "[$i]['#']")) {
- $VALUE = strtoupper($value);
- $key = array_search($VALUE, $VALUES);
- if (is_numeric($key)) {
- $segments[] = $key+1;
- } else {
- $segments[] = $i+1;
- $values[$i] = $value;
- $VALUES[$i] = $VALUE;
- $escapedvalues[] = preg_quote($value, '/');
- }
- $i++;
- }
-
- // start the answers array
- $a = 0;
- $str = 'Answers['.($a++).'] = new Array('.implode(',', $segments).");\n";
-
- // pattern to match the next part of an alternate answer
- $pattern = '/^('.implode('|', $escapedvalues).')\\s*/i';
-
- // XML tags to the start of an alternate answer
- $tags = 'data,jumbled-order-exercise,alternate';
-
- $i = 0;
- while ($value = $this->parent->xml_value($tags, "[$i]['#']")) {
- $segments = array();
- while (strlen($value) && preg_match($pattern, $value, $matches)) {
- $key = array_search($matches[1], $values);
- if (is_numeric($key)) {
- $segments[] = $key+1;
- $value = substr($value, strlen($matches[0]));
- } else {
- // invalid alternate sequence
- $segments = array();
- break;
- }
- }
- if (count($segments)) {
- $str .= 'Answers['.($a++).'] = new Array('.implode(',', $segments).");\n";
- }
- $i++;
- }
- return $str;
- }
-
- // ===============================================================
-
- // JMix (jmix6.js_)
-
- function v6_expand_RemainingWords() {
- return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',remaining-words');
- }
- function v6_expand_TimesUp() {
- return $this->js_safe($this->parent->xml_value('hotpot-config-file,global,times-up'));
- }
-
- // nav bar
-
- function v6_expand_NavBar($navbarid='') {
- $this->navbarid = $navbarid;
-
- $tag = 'navbar';
- $this->read_template('hp6navbar.ht_', $tag);
-
- unset($this->navbarid);
-
- return $this->$tag;
- }
- function v6_expand_TopNavBar() {
- return $this->v6_expand_NavBar('TopNavBar');
- }
- function v6_expand_BottomNavBar() {
- return $this->v6_expand_NavBar('BottomNavBar');
- }
-
- // hp6navbar.ht_
-
- function v6_expand_NavBarID() {
- // $this->navbarid is set in "$this->v6_expand_NavBar"
- return empty($this->navbarid) ? '' : $this->navbarid;
- }
- function v6_expand_ContentsURL() {
- $url = $this->parent->xml_value('hotpot-config-file,global,contents-url');
- if ($url) {
- $url = hotpot_convert_navbutton_url($this->parent->get_baseurl(), $this->parent->reference, $url, $this->parent->course);
- }
- return $url;
- }
- function v6_expand_NextExURL() {
- $url = $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',next-ex-url');
- if ($url) {
- $url = hotpot_convert_navbutton_url($this->parent->get_baseurl(), $this->parent->reference, $url, $this->parent->course);
- }
- return $url;
- }
-
- // conditional blocks
-
- function v6_expand_ShowAnswer() {
- return $this->int_value('hotpot-config-file,'.$this->parent->quiztype.',include-show-answer');
- }
- function v6_expand_Slide() {
- return true; // whats's this (JMatch drag and drop)
- }
-
- // specials (JMatch)
-
- function v6_expand_FixedArray() {
- $this->set_jmatch_items();
- $str = '';
- foreach ($this->l_items as $i=>$item) {
- for ($ii=0; $ii<$i; $ii++) {
- if ($this->r_items[$ii]['text']==$this->r_items[$i]['text']) {
- break;
- }
- }
- $str .= "F[$i] = new Array();\n";
- $str .= "F[$i][0] = '".$this->js_safe($item['text'], true)."';\n";
- $str .= "F[$i][1] = ".($ii+1).";\n";
- }
- return $str;
- }
- function v6_expand_DragArray() {
- $this->set_jmatch_items();
- $str = '';
- foreach ($this->r_items as $i=>$item) {
- for ($ii=0; $ii<$i; $ii++) {
- if ($this->r_items[$ii]['text']==$this->r_items[$i]['text']) {
- break;
- }
- }
- $str .= "D[$i] = new Array();\n";
- $str .= "D[$i][0] = '".$this->js_safe($item['text'], true)."';\n";
- $str .= "D[$i][1] = ".($ii+1).";\n";
- $str .= "D[$i][2] = ".$item['fixed'].";\n";
- }
- return $str;
- }
-
- function set_jmatch_items() {
- if (count($this->l_items)) {
- return;
- }
- $tags = 'data,matching-exercise,pair';
- $i = 0;
- while (($item = "[$i]['#']") && $this->parent->xml_value($tags, $item)) {
- $leftitem = $item."['left-item'][0]['#']";
- $lefttext = $this->parent->xml_value($tags, $leftitem."['text'][0]['#']");
-
- $rightitem = $item."['right-item'][0]['#']";
- $righttext = $this->parent->xml_value($tags, $rightitem."['text'][0]['#']");
-
- if (strlen($righttext)) {
- $addright = true;
- } else {
- $addright = false;
- }
- if (strlen($lefttext)) {
- $this->l_items[] = array(
- 'text' => $lefttext,
- 'fixed' => $this->int_value($tags, $leftitem."['fixed'][0]['#']")
- );
- $addright = true; // force right item to be added
- }
- if ($addright) {
- $this->r_items[] = array(
- 'text' => $righttext,
- 'fixed' => $this->int_value($tags, $rightitem."['fixed'][0]['#']")
- );
- }
- $i++;
- }
- }
- function shuffle_jmatch_items(&$items) {
- // get moveable items
- $moveable_keys = array();
- for($i=0; $iseed_random_number_generator();
- shuffle($moveable_keys);
-
- $keys = array();
- for($i=0, $ii=0; $iparent->quiztype) {
- case 'jcloze':
- $tags = 'data,gap-fill,question-record';
- while (($question="[$q]['#']") && $this->parent->xml_value($tags, $question)) {
- $a = 0;
- $aa = 0;
- while (($answer=$question."['answer'][$a]['#']") && $this->parent->xml_value($tags, $answer)) {
- $text = $this->js_value($tags, $answer."['text'][0]['#']", true);
- if (strlen($text)) {
- if ($aa==0) { // first time only
- $str .= "\n";
- $str .= "I[$q] = new Array();\n";
- $str .= "I[$q][1] = new Array();\n";
- }
- $str .= "I[$q][1][$aa] = new Array();\n";
- $str .= "I[$q][1][$aa][0] = '$text';\n";
- $aa++;
- }
- $a++;
- }
- // add clue, if any answers were found
- if ($aa) {
- $clue = $this->js_value($tags, $question."['clue'][0]['#']", true);
- $str .= "I[$q][2] = '$clue';\n";
- }
- $q++;
- }
- break;
- case 'jquiz':
- $str .= "I=new Array();\n";
- $tags = 'data,questions,question-record';
- while (($question="[$q]['#']") && $this->parent->xml_value($tags, $question)) {
-
- $question_type = $this->int_value($tags, $question."['question-type'][0]['#']");
- $weighting = $this->int_value($tags, $question."['weighting'][0]['#']");
- $clue = $this->js_value($tags, $question."['clue'][0]['#']", true);
-
- $answers = $question."['answers'][0]['#']";
-
- $a = 0;
- $aa = 0;
- while (($answer = $answers."['answer'][$a]['#']") && $this->parent->xml_value($tags, $answer)) {
- $text = $this->js_value($tags, $answer."['text'][0]['#']", true);
- $feedback = $this->js_value($tags, $answer."['feedback'][0]['#']", true);
- $correct = $this->int_value($tags, $answer."['correct'][0]['#']");
- $percent = $this->int_value($tags, $answer."['percent-correct'][0]['#']");
- $include = $this->int_value($tags, $answer."['include-in-mc-options'][0]['#']");
- if (strlen($text)) {
- if ($aa==0) { // first time only
- $str .= "\n";
- $str .= "I[$q] = new Array();\n";
- $str .= "I[$q][0] = $weighting;\n";
- $str .= "I[$q][1] = '$clue';\n";
- $str .= "I[$q][2] = '".($question_type-1)."';\n";
- $str .= "I[$q][3] = new Array();\n";
- }
- $str .= "I[$q][3][$aa] = new Array('$text','$feedback',$correct,$percent,$include);\n";
- $aa++;
- }
- $a++;
- }
- $q++;
- }
- break;
- }
- return $str;
- }
-
- function v6_expand_ClozeBody() {
- $str = '';
-
- // get drop down list of words, if required
- $dropdownlist = '';
- if ($this->v6_use_DropDownList()) {
- $this->v6_set_WordList();
- foreach ($this->wordlist as $word) {
- $dropdownlist .= '';
- }
- }
-
- // cache clues flag and caption
- $includeclues = $this->v6_expand_Clues();
- $cluecaption = $this->v6_expand_ClueCaption();
-
- // detect if cloze starts with gap
- $strpos = strpos($this->parent->source, '');
- if (is_numeric($strpos)) {
- $startwithgap = true;
- } else {
- $startwithgap = false;
- }
-
- // initialize loop values
- $q = 0;
- $tags = 'data,gap-fill';
- $question_record = "$tags,question-record";
-
- // loop through text and gaps
- do {
- $text = $this->parent->xml_value($tags, "[0]['#'][$q]");
- $gap = '';
- if (($question="[$q]['#']") && $this->parent->xml_value($question_record, $question)) {
- $gap .= '';
- if ($this->v6_use_DropDownList()) {
- $gap .= '';
- } else {
- // minimum gap size
- if (! $gapsize = $this->int_value('hotpot-config-file,'.$this->parent->quiztype.',minimum-gap-size')) {
- $gapsize = 6;
- }
-
- // increase gap size to length of longest answer for this gap
- $a = 0;
- while (($answer=$question."['answer'][$a]['#']") && $this->parent->xml_value($question_record, $answer)) {
- $answertext = $this->parent->xml_value($question_record, $answer."['text'][0]['#']");
- $answertext = preg_replace('|&[#a-zA-Z0-9]+;|', 'x', $answertext);
- $gapsize = max($gapsize, strlen($answertext));
- $a++;
- }
-
- $gap .= '';
- }
- if ($includeclues) {
- $clue = $this->parent->xml_value($question_record, $question."['clue'][0]['#']");
- if (strlen($clue)) {
- $gap .= '';
- }
- }
- $gap .= '';
- }
- if ($startwithgap) {
- $str .= "$gap$text";
- } else {
- $str .= "$text$gap";
- }
- $q++;
- } while (strlen($text) || strlen($gap));
-
- return $str;
- }
-
- // JCloze quiztype
-
- function v6_expand_WordList() {
- $str = '';
- if ($this->v6_include_WordList()) {
- $this->v6_set_WordList();
- $str = implode(' ', $this->wordlist);
- }
- return $str;
- }
- function v6_include_WordList() {
- return $this->int_value('hotpot-config-file,'.$this->parent->quiztype.',include-word-list');
- }
- function v6_use_DropDownList() {
- return $this->int_value('hotpot-config-file,'.$this->parent->quiztype.',use-drop-down-list');
- }
- function v6_set_WordList() {
-
- if (isset($this->wordlist)) {
- // do nothing
- } else {
- $this->wordlist = array();
-
- // is the wordlist required
- if ($this->v6_include_WordList() || $this->v6_use_DropDownList()) {
-
- $q = 0;
- $tags = 'data,gap-fill,question-record';
- while (($question="[$q]['#']") && $this->parent->xml_value($tags, $question)) {
- $a = 0;
- $aa = 0;
- while (($answer=$question."['answer'][$a]['#']") && $this->parent->xml_value($tags, $answer)) {
- $text = $this->parent->xml_value($tags, $answer."['text'][0]['#']");
- $correct = $this->int_value($tags, $answer."['correct'][0]['#']");
- if ($text && $correct) { // $correct is always true
- $this->wordlist[] = $text;
- $aa++;
- }
- $a++;
- }
- $q++;
- }
- $this->wordlist = array_unique($this->wordlist);
- sort($this->wordlist);
- }
- }
- }
- function v6_expand_Keypad() {
- $str = '';
- if ($this->int_value('hotpot-config-file,'.$this->parent->quiztype.',include-keypad')) {
-
- // these characters must always be in the keypad
- $chars = array();
- $this->add_keypad_chars($chars, $this->parent->xml_value('hotpot-config-file,global,keypad-characters'));
-
- // append other characters used in the answers
- $tags = '';
- switch ($this->parent->quiztype) {
- case 'jcloze':
- $tags = 'data,gap-fill,question-record';
- break;
- case 'jquiz':
- $tags = 'data,questions,question-record';
- break;
- }
- if ($tags) {
- $q = 0;
- while (($question="[$q]['#']") && $this->parent->xml_value($tags, $question)) {
-
- if ($this->parent->quiztype=='jquiz') {
- $answers = $question."['answers'][0]['#']";
- } else {
- $answers = $question;
- }
-
- $a = 0;
- while (($answer=$answers."['answer'][$a]['#']") && $this->parent->xml_value($tags, $answer)) {
- $this->add_keypad_chars($chars, $this->parent->xml_value($tags, $answer."['text'][0]['#']"));
- $a++;
- }
- $q++;
- }
- }
-
- // remove duplicate characters and sort
- $chars = array_unique($chars);
- usort($chars, "hotpot_sort_keypad_chars");
-
- // create keypad buttons for each character
- foreach ($chars as $char) {
- $str .= "";
- }
- }
- return $str;
- }
- function add_keypad_chars(&$chars, $text) {
- if (preg_match_all('|&[^;]+;|i', $text, $more_chars)) {
- $chars = array_merge($chars, $more_chars[0]);
- }
- }
- function v6_expand_Correct() {
- if ($this->parent->quiztype=='jcloze') {
- $tag = 'guesses-correct';
- } else {
- $tag = 'guess-correct';
- }
- return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.','.$tag);
- }
- function v6_expand_Incorrect() {
- if ($this->parent->quiztype=='jcloze') {
- $tag = 'guesses-incorrect';
- } else {
- $tag = 'guess-incorrect';
- }
- return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.','.$tag);
- }
- function v6_expand_GiveHint() {
- return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',next-correct-letter');
- }
- function v6_expand_CaseSensitive() {
- return $this->bool_value('hotpot-config-file,'.$this->parent->quiztype.',case-sensitive');
- }
-
- // JCross quiztype
-
- function v6_expand_CluesAcrossLabel() {
- return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',clues-across');
- }
- function v6_expand_CluesDownLabel() {
- return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',clues-down');
- }
- function v6_expand_EnterCaption() {
- return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',enter-caption');
- }
- function v6_expand_ShowHideClueList() {
- $value = $this->int_value('hotpot-config-file,'.$this->parent->quiztype.',include-clue-list');
- return empty($value) ? ' style="display: none;"' : '';
- }
-
- // JCross specials
-
- function v6_expand_CluesDown() {
- return $this->v6_expand_jcross_clues('D');
- }
- function v6_expand_CluesAcross() {
- return $this->v6_expand_jcross_clues('A');
- }
- function v6_expand_jcross_clues($direction) {
- // $direction: A(cross) or D(own)
- $row = NULL;
- $r_max = 0;
- $c_max = 0;
- $this->v6_get_jcross_grid($row, $r_max, $c_max);
-
- $i = 0; // clue index;
- $str = '';
- for($r=0; $r<=$r_max; $r++) {
- for($c=0; $c<=$c_max; $c++) {
- $aword = $this->get_jcross_aword($row, $r, $r_max, $c, $c_max);
- $dword = $this->get_jcross_dword($row, $r, $r_max, $c, $c_max);
- if ($aword || $dword) {
- $i++; // increment clue index
-
- // get the definition for this word
- $def = '';
- $word = ($direction=='A') ? $aword : $dword;
- $clues = $this->parent->xml_values('data,crossword,clues,item');
- foreach ($clues as $clue) {
- if ($clue['word'][0]['#']==$word) {
- $def = $clue['def'][0]['#'];
- $def = strtr($def, array('<'=>'<', '>'=>'>', "\n"=>' '));
- break;
- }
- }
-
- if (!empty($def)) {
- $str .= '| '.$i.'. | '.$def.' | ';
- }
- }
- }
- }
- return $str;
- }
-
- // jcross6.js_
-
- function v6_expand_LetterArray() {
- $row = NULL;
- $r_max = 0;
- $c_max = 0;
- $this->v6_get_jcross_grid($row, $r_max, $c_max);
-
- $str = '';
- for($r=0; $r<=$r_max; $r++) {
- $str .= "L[$r] = new Array(";
- for($c=0; $c<=$c_max; $c++) {
- $str .= ($c>0 ? ',' : '')."'".$this->js_safe($row[$r]['cell'][$c]['#'], true)."'";
- }
- $str .= ");\n";
- }
- return $str;
- }
- function v6_expand_GuessArray() {
- $row = NULL;
- $r_max = 0;
- $c_max = 0;
- $this->v6_get_jcross_grid($row, $r_max, $c_max);
-
- $str = '';
- for($r=0; $r<=$r_max; $r++) {
- $str .= "G[$r] = new Array('".str_repeat("','", $c_max)."');\n";
- }
- return $str;
- }
- function v6_expand_ClueNumArray() {
- $row = NULL;
- $r_max = 0;
- $c_max = 0;
- $this->v6_get_jcross_grid($row, $r_max, $c_max);
-
- $i = 0; // clue index
- $str = '';
- for($r=0; $r<=$r_max; $r++) {
- $str .= "CL[$r] = new Array(";
- for($c=0; $c<=$c_max; $c++) {
- if ($c>0) {
- $str .= ',';
- }
- $aword = $this->get_jcross_aword($row, $r, $r_max, $c, $c_max);
- $dword = $this->get_jcross_dword($row, $r, $r_max, $c, $c_max);
- if (empty($aword) && empty($dword)) {
- $str .= 0;
- } else {
- $i++; // increment the clue index
- $str .= $i;
- }
- }
- $str .= ");\n";
- }
- return $str;
- }
- function v6_expand_GridBody() {
- $row = NULL;
- $r_max = 0;
- $c_max = 0;
- $this->v6_get_jcross_grid($row, $r_max, $c_max);
-
- $i = 0; // clue index;
- $str = '';
- for($r=0; $r<=$r_max; $r++) {
- $str .= '';
- for($c=0; $c<=$c_max; $c++) {
- if (empty($row[$r]['cell'][$c]['#'])) {
- $str .= '| | ';
- } else {
- $aword = $this->get_jcross_aword($row, $r, $r_max, $c, $c_max);
- $dword = $this->get_jcross_dword($row, $r, $r_max, $c, $c_max);
- if (empty($aword) && empty($dword)) {
- $str .= ' | ';
- } else {
- $i++; // increment clue index
- $str .= ''.$i.' | ';
- }
- }
- }
- $str .= ' ';
- }
- return $str;
- }
- function v6_get_jcross_grid(&$row, &$r_max, &$c_max) {
- $row = $this->parent->xml_values('data,crossword,grid,row');
- $r_max = 0;
- $c_max = 0;
- if (isset($row) && is_array($row)) {
- for($r=0; $rget_jcross_word($row, $r, $r_max, $c, $c_max, true);
- }
- return $str;
- }
- function get_jcross_aword(&$row, $r, $r_max, $c, $c_max) {
- $str = '';
- if (($c==0 || empty($row[$r]['cell'][$c-1]['#'])) && $c<$c_max && !empty($row[$r]['cell'][$c+1]['#'])) {
- $str = $this->get_jcross_word($row, $r, $r_max, $c, $c_max, false);
- }
- return $str;
- }
- function get_jcross_word(&$row, $r, $r_max, $c, $c_max, $go_down=false) {
- $str = '';
- while ($r<=$r_max && $c<=$c_max && !empty($row[$r]['cell'][$c]['#'])) {
- $str .= $row[$r]['cell'][$c]['#'];
- if ($go_down) {
- $r++;
- } else {
- $c++;
- }
- }
- return $str;
- }
-
- // specials (JQuiz)
-
- function v6_expand_QuestionOutput() {
- $str = '';
- $str .= ''."\n";
-
- $q = 0;
- $tags = 'data,questions,question-record';
- while (($question="[$q]['#']") && $this->parent->xml_value($tags, $question)) {
-
- // get question
- $question_text = $this->parent->xml_value($tags, $question."['question'][0]['#']");
- $question_type = $this->parent->xml_value($tags, $question."['question-type'][0]['#']");
-
- $first_answer_text = $this->parent->xml_value($tags, $question."['answers'][0]['#']['answer'][0]['#']['text'][0]['#']");
-
- // check we have a question (or at least one answer)
- if (($question_text || $first_answer_text) && $question_type) {
-
- $str .= '- ';
- $str .= '
'.$question_text.' ';
-
- if (
- $question_type==HOTPOT_JQUIZ_SHORTANSWER ||
- $question_type==HOTPOT_JQUIZ_HYBRID
- ) {
- $size = 9; // default size
- $a = 0;
- $answers = $question."['answers'][0]['#']";
- while (($answer = $answers."['answer'][$a]['#']") && $this->parent->xml_value($tags, $answer)) {
- $text = $this->parent->xml_value($tags, $answer."['text'][0]['#']");
- $text = preg_replace('/&[#a-zA-Z0-9]+;/', 'x', $text);
- $size = max($size, strlen($text));
- $a++;
- }
-
- $str .= '';
- }
-
- if (
- $question_type==HOTPOT_JQUIZ_MULTICHOICE ||
- $question_type==HOTPOT_JQUIZ_HYBRID ||
- $question_type==HOTPOT_JQUIZ_MULTISELECT
- ) {
-
- switch ($question_type) {
- case HOTPOT_JQUIZ_MULTICHOICE:
- $str .= ''."\n";
- break;
- case HOTPOT_JQUIZ_HYBRID:
- $str .= ''."\n";
- break;
- case HOTPOT_JQUIZ_MULTISELECT:
- $str .= ''."\n";
- break;
- }
-
- $a = 0;
- $aa = 0;
- $answers = $question."['answers'][0]['#']";
- while (($answer = $answers."['answer'][$a]['#']") && $this->parent->xml_value($tags, $answer)) {
- $text = $this->parent->xml_value($tags, $answer."['text'][0]['#']");
- if ($text) {
- switch ($question_type) {
- case HOTPOT_JQUIZ_MULTICHOICE:
- case HOTPOT_JQUIZ_HYBRID:
- $include = $this->int_value($tags, $answer."['include-in-mc-options'][0]['#']");
- if ($include) {
- $str .= '- '.$text.'
'."\n";
- }
- break;
- case HOTPOT_JQUIZ_MULTISELECT:
- $str .= ''."\n";
- break;
- }
- $aa++;
- }
- $a++;
- }
-
- $str .= ' ';
-
- if ($question_type==HOTPOT_JQUIZ_MULTISELECT) {
- $caption = $this->v6_expand_CheckCaption();
- $str .= $this->v6_expand_jquiz_button($caption, "CheckMultiSelAnswer($q)");
- }
- }
-
- $str .= " \n";
- }
- $q++;
-
- } // end while $question
-
- $str .= " \n";
- return $str;
- }
-
- function v6_expand_jquiz_button($caption, $onclick) {
- return '';
- }
-
- // jquiz.js_
-
- function v6_expand_MultiChoice() {
- return $this->v6_jquiz_question_type(HOTPOT_JQUIZ_MULTICHOICE);
- }
- function v6_expand_ShortAnswer() {
- return $this->v6_jquiz_question_type(HOTPOT_JQUIZ_SHORTANSWER);
- }
- function v6_expand_MultiSelect() {
- return $this->v6_jquiz_question_type(HOTPOT_JQUIZ_MULTISELECT);
- }
- function v6_jquiz_question_type($type) {
- // does this quiz have any questions of the given $type?
- $flag = false;
-
- $q = 0;
- $tags = 'data,questions,question-record';
- while (($question = "[$q]['#']") && $this->parent->xml_value($tags, $question)) {
- $question_type = $this->parent->xml_value($tags, $question."['question-type'][0]['#']");
- if ($question_type==$type || ($question_type==HOTPOT_JQUIZ_HYBRID && ($type==HOTPOT_JQUIZ_MULTICHOICE || $type==HOTPOT_JQUIZ_SHORTANSWER))) {
- $flag = true;
- break;
- }
- $q++;
- }
- return $flag;
- }
- function v6_expand_CorrectFirstTime() {
- return $this->js_value('hotpot-config-file,global,correct-first-time');
- }
- function v6_expand_ContinuousScoring() {
- return $this->bool_value('hotpot-config-file,'.$this->parent->quiztype.',continuous-scoring');
- }
- function v6_expand_ShowCorrectFirstTime() {
- return $this->bool_value('hotpot-config-file,'.$this->parent->quiztype.',show-correct-first-time');
- }
- function v6_expand_ShuffleAs() {
- return $this->bool_value('hotpot-config-file,'.$this->parent->quiztype.',shuffle-answers');
- }
-
- function v6_expand_DefaultRight() {
- return $this->v6_expand_GuessCorrect();
- }
- function v6_expand_DefaultWrong() {
- return $this->v6_expand_GuessIncorrect();
- }
- function v6_expand_ShowAllQuestionsCaptionJS() {
- return $this->v6_expand_ShowAllQuestionsCaption();
- }
- function v6_expand_ShowOneByOneCaptionJS() {
- return $this->v6_expand_ShowOneByOneCaption();
- }
-
- // hp6checkshortanswers.js_ (JQuiz)
-
- function v6_expand_CorrectList() {
- return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',correct-answers');
- }
- function v6_expand_HybridTries() {
- return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',short-answer-tries-on-hybrid-q');
- }
- function v6_expand_PleaseEnter() {
- return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',enter-a-guess');
- }
- function v6_expand_PartlyIncorrect() {
- return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',partly-incorrect');
- }
- function v6_expand_ShowAnswerCaption() {
- return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',show-answer-caption');
- }
- function v6_expand_ShowAlsoCorrect() {
- return $this->bool_value('hotpot-config-file,global,show-also-correct');
- }
-
-} // end class
-function hotpot_sort_keypad_chars($a, $b) {
- $a = hotpot_keypad_sort_value($a);
- $b = hotpot_keypad_sort_value($b);
- return ($a<$b) ? -1 : ($a==$b ? 0 : 1);
-}
-function hotpot_keypad_sort_value($char) {
-
- // hexadecimal
- if (preg_match('/([0-9A-F]+);/i', $char, $matches)) {
- $ord = hexdec($matches[1]);
-
- // decimal
- } else if (preg_match('/(\d+);/i', $char, $matches)) {
- $ord = intval($matches[1]);
-
- // other html entity
- } else if (preg_match('/&[^;]+;/', $char, $matches)) {
- $char = html_entity_decode($matches[0]);
- $ord = empty($char) ? 0 : ord($char);
-
- // not an html entity
- } else {
- $char = trim($char);
- $ord = empty($char) ? 0 : ord($char);
- }
-
- // lowercase letters (plain or accented)
- if (($ord>=97 && $ord<=122) || ($ord>=224 && $ord<=255)) {
- $sort_value = ($ord-31).'.'.sprintf('%04d', $ord);
-
- // all other characters
- } else {
- $sort_value = $ord;
- }
-
- return $sort_value;
-}
-
-
diff --git a/mod/hotpot/template/v6/djmatch6.ht_ b/mod/hotpot/template/v6/djmatch6.ht_
deleted file mode 100644
index 8b31025b55e..00000000000
--- a/mod/hotpot/template/v6/djmatch6.ht_
+++ /dev/null
@@ -1,128 +0,0 @@
-
-
-
-
-[strDublinCoreMetadata]
-
-
-
-
-[strPlainTitle]
-
-
-
-
-
-
-[strHeaderCode]
-
-
-
-
-
-
-
-
-
-
-[inclNavButtons]
-[strTopNavBar]
-[/inclNavButtons]
-
-
-
-
- [strExerciseTitle]
-[inclExerciseSubtitle]
- [strExerciseSubtitle]
-[/inclExerciseSubtitle]
-[inclTimer]
-
-[/inclTimer]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/mod/hotpot/template/v6/djmatch6.js_ b/mod/hotpot/template/v6/djmatch6.js_
deleted file mode 100644
index b0294a0454e..00000000000
--- a/mod/hotpot/template/v6/djmatch6.js_
+++ /dev/null
@@ -1,369 +0,0 @@
-
-[inclScorm1.2]
-//JMATCH-SPECIFIC SCORM-RELATED JAVASCRIPT CODE
-
-function SetScormScore(){
-//Reports the current score and any other information back to the LMS
- if (API != null){
- API.LMSSetValue('cmi.core.score.raw', Score);
-
-
-//Now send a detailed reports on the item
- var ItemLabel = 'Matching';
- API.LMSSetValue('cmi.objectives.0.id', 'obj'+ItemLabel);
- API.LMSSetValue('cmi.interactions.0.id', 'int'+ItemLabel);
- API.LMSSetValue('cmi.objectives.0.status', API.LMSGetValue('cmi.core.lesson_status'));
- API.LMSSetValue('cmi.objectives.0.score.min', '0');
- API.LMSSetValue('cmi.objectives.0.score.max', '100');
- API.LMSSetValue('cmi.objectives.0.score.raw', Score);
-//We can only use the performance type, because we're storing multiple responses of various types.
- API.LMSSetValue('cmi.interactions.0.type', 'performance');
- API.LMSSetValue('cmi.interactions.0.student_response', AnswersTried);
-
- API.LMSCommit('');
- }
-}
-[/inclScorm1.2]
-
-//JMATCH-SPECIFIC CORE JAVASCRIPT CODE
-
-var CorrectResponse = '[strGuessCorrect]';
-var IncorrectResponse = '[strGuessIncorrect]';
-var YourScoreIs = '[strYourScoreIs]';
-var DivWidth = 600; //default value
-var FeedbackWidth = 200; //default
-var ExBGColor = '[strExBGColor]';
-var PageBGColor = '[strPageBGColor]';
-var TextColor = '[strTextColor]';
-var TitleColor = '[strTitleColor]';
-var Penalties = 0;
-var Score = 0;
-var TimeOver = false;
-var Locked = false;
-var ShuffleQs = [boolShuffleQs];
-var QsToShow = [QsToShow];
-
-var DragWidth = 200;
-var LeftColPos = 100;
-var RightColPos = 500;
-var DragTop = 120;
-var Finished = false;
-var AnswersTried = '';
-
-//Fixed and draggable card arrays
-FC = new Array();
-DC = new Array();
-
-function onEndDrag(){
-//Is it dropped on any of the fixed cards?
- var Docked = false;
- var DropTarget = DroppedOnFixed(CurrDrag);
- if (DropTarget > -1){
-//If so, send home any card that is currently docked there
- for (var i=0; i OverlapArea){
- OverlapArea = Temp;
- Result = i;
- }
- }
- return Result;
-}
-
-
-function StartUp(){
-
-[inclScorm1.2]
- ScormStartUp();
-[/inclScorm1.2]
-
-[inclSendResults]
- GetUserName();
-[/inclSendResults]
-
-[inclPreloadImages]
- PreloadImages([PreloadImageList]);
-[/inclPreloadImages]
-
-//Calculate page dimensions and positions
- pg = new PageDim();
- DivWidth = Math.floor((pg.W*4)/5);
- DragWidth = Math.floor((DivWidth*3)/10);
- LeftColPos = Math.floor(pg.W/15);
- RightColPos = pg.W - (DragWidth + LeftColPos);
- DragTop = parseInt(document.getElementById('CheckButtonDiv').offsetHeight) + parseInt(document.getElementById('CheckButtonDiv').offsetTop) + 10;
-
- if (C.ie){
- DragTop += 15;
- }
-
-//Reduce array if required
- if (QsToShow < F.length){
- ReduceItems2();
- }
-
-//Shuffle the left items if required
- if (ShuffleQs == true){
- F = Shuffle(F);
- }
-
-//Shuffle the items on the right
- D = Shuffle(D);
-
- var CurrTop = DragTop;
- var TempInt = 0;
- var DropHome = 0;
- var Widest = 0;
- var CardContent = '';
- for (var i=0; i Widest){
- Widest = FC[i].GetW();
- }
- }
-
- if (Widest > DragWidth){Widest = DragWidth;}
-
- CurrTop = DragTop;
-
- DragWidth = Math.floor((DivWidth-Widest)/2) - 24;
- RightColPos = DivWidth + LeftColPos - (DragWidth + 14);
- var Highest = 0;
- var WidestRight = 0;
-
- for (i=0; i -1){CardContent += ' ';} //used to be required for Navigator rendering bug with images
- DC[i].elm.innerHTML = CardContent;
- if (DC[i].GetW() > DragWidth){DC[i].SetW(DragWidth);}
- DC[i].css.cursor = 'move';
- DC[i].css.backgroundColor = '[strExBGColor]';
- DC[i].css.color = '[strTextColor]';
- TempInt = DC[i].GetH();
- if (TempInt > Highest){Highest = TempInt;}
- TempInt = DC[i].GetW();
- if (TempInt > WidestRight){WidestRight = TempInt;}
- }
-
-//Fix for 6.2: the reduction by 12 seems to be required -- no idea why!
- var HeightToSet = Highest-12;
- var WidthToSet = WidestRight-12;
-
- for (i=0; i 0){
- DC[i].tag = D[i][1];
- D[i][2] = D[i][1];
- var TopChange = 0;
-//Find the right target element
- var TargItem = -1;
- for (var j=0; j DC[i].GetT()){
- TopChange = 1;
- }
- }
- Slide(i, TargetLeft, TargetTop, TopChange);
- D[i][2] = F[TargItem][1];
- DC[i].tag = TargItem+1;
- }
- }
-[/inclSlide]
-[inclTimer]
- StartTimer();
-[/inclTimer]
-}
-
-[inclSlide]
-function Slide(MoverNum, TargL, TargT, TopChange){
- var TempInt = DC[MoverNum].GetL();
- if (TempInt > TargL){
- DC[MoverNum].SetL(TempInt - 5);
- }
- TempInt = DC[MoverNum].GetT();
- if (TempInt != TargT){
- DC[MoverNum].SetT(TempInt + TopChange);
- }
- if ((DC[MoverNum].GetL() > TargL)||(DC[MoverNum].GetT() != TargT)){
- setTimeout('Slide('+MoverNum+','+TargL+','+TargT+','+TopChange+')', 1);
- }
- else{
- DC[MoverNum].SetL(TargL);
- }
-}
-[/inclSlide]
-
-F = new Array();
-[FixedArray]
-
-D = new Array();
-[DragArray]
-
-function ReduceItems2(){
- var ItemToDump=0;
- var j=0;
- while (F.length > QsToShow){
- ItemToDump = Math.floor(F.length*Math.random());
- for (j=ItemToDump; j<(F.length-1); j++){
- F[j] = F[j+1];
- }
- for (j=ItemToDump; j<(D.length-1); j++){
- D[j] = D[j+1];
- }
- F.length = F.length-1;
- D.length = D.length-1;
- }
-}
-
-function TimerStartUp(){
- setTimeout('StartUp()', 300);
-}
-
-function CheckAnswers(){
- if (Locked == true){return;}
-//Set the default score and response
- var TotalCorrect = 0;
- Score = 0;
- var Feedback = '';
-
-//for each fixed, check to see if the tag value for the draggable is the same as the fixed
- if (AnswersTried.length > 0){AnswersTried += ' | ';}
- var i, j;
- for (i=0; i0){AnswersTried += ',';}
- AnswersTried += D[i][1] + '.' + D[i][2] + '';
- if ((D[i][2] == D[i][1])&&(D[i][2] > 0)){
- TotalCorrect++;
- }
- else{
-//Change made for version 6.0.3.41: don't send wrong items home,
-//show them in a more conspicuous way.
-// DC[i].GoHome();
- DC[i].SetL(DC[i].GetL() + 10);
- DC[i].Highlight();
- }
- }
-
- Score = Math.floor((100*(TotalCorrect-Penalties))/F.length);
-
- var AllDone = false;
-
- if (TotalCorrect == F.length) {
- AllDone = true;
- }
-
- if (AllDone == true){
- Feedback = YourScoreIs + ' ' + Score + '%.';
- ShowMessage(Feedback + ' ' + CorrectResponse);
- }
- else {
- Feedback = IncorrectResponse + ' ' + YourScoreIs + ' ' + Score + '%.';
- ShowMessage(Feedback);
- Penalties++; // Penalty for inaccurate check
- }
-//If the exercise is over, deal with that
- if ((AllDone == true)||(TimeOver == true)){
-[inclSendResults]
- setTimeout('SendResults(' + Score + ')', 50);
-[/inclSendResults]
-[inclTimer]
- window.clearInterval(Interval);
-[/inclTimer]
- TimeOver = true;
- Locked = true;
- Finished = true;
- setTimeout('Finish()', SubmissionTimeout);
- WriteToInstructions(Feedback);
- }
-[inclScorm1.2]
- if (AllDone == true){
- SetScormComplete();
- }
- else{
- SetScormIncomplete();
- }
-[/inclScorm1.2]
-}
-
-[inclTimer]
-function TimesUp() {
- document.getElementById('Timer').innerHTML = '[strTimesUp]';
-[inclPreloadImages]
- RefreshImages();
-[/inclPreloadImages]
- TimeOver = true;
- CheckAnswers();
- Locked = true;
-[inclScorm1.2]
- SetScormTimedOut();
-[/inclScorm1.2]
-}
-[/inclTimer]
-
diff --git a/mod/hotpot/template/v6/djmix6.ht_ b/mod/hotpot/template/v6/djmix6.ht_
deleted file mode 100644
index c8bbc6b91f5..00000000000
--- a/mod/hotpot/template/v6/djmix6.ht_
+++ /dev/null
@@ -1,136 +0,0 @@
-
-
-
-
-[strDublinCoreMetadata]
-
-
-
-
-[strPlainTitle]
-
-
-
-
-
-
-[strHeaderCode]
-
-
-
-
-
-
-
-
-
-
-[inclNavButtons]
-[strTopNavBar]
-[/inclNavButtons]
-
-
-
-
- [strExerciseTitle]
-[inclExerciseSubtitle]
- [strExerciseSubtitle]
-[/inclExerciseSubtitle]
-[inclTimer]
-
-[/inclTimer]
-
-
-
-
-
-
-
-
-[inclRestart]
-
-[/inclRestart]
-
-[inclHint]
-
-[/inclHint]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/mod/hotpot/template/v6/djmix6.js_ b/mod/hotpot/template/v6/djmix6.js_
deleted file mode 100644
index 53610d3009b..00000000000
--- a/mod/hotpot/template/v6/djmix6.js_
+++ /dev/null
@@ -1,576 +0,0 @@
-[inclScorm1.2]
-//JMMIX-SPECIFIC SCORM-RELATED JAVASCRIPT CODE
-
-function SetScormScore(){
-//Reports the current score and any other information back to the LMS
- if (API != null){
- API.LMSSetValue('cmi.core.score.raw', Score);
-
-//Now send a detailed reports on the item
- var ItemLabel = 'Item_1';
- API.LMSSetValue('cmi.objectives.0.id', 'obj'+ItemLabel);
- API.LMSSetValue('cmi.interactions.0.id', 'int'+ItemLabel);
- if (Finished == true){
- API.LMSSetValue('cmi.objectives.0.status', 'completed');
- }
- else{
- API.LMSSetValue('cmi.objectives.0.status', 'incomplete');
- }
-
- API.LMSSetValue('cmi.objectives.0.score.min', '0');
- API.LMSSetValue('cmi.objectives.0.score.max', '100');
- API.LMSSetValue('cmi.objectives.0.score.raw', Score);
-//We can only use the performance type, because we're storing multiple responses of various types.
- API.LMSSetValue('cmi.interactions.0.type', 'performance');
- API.LMSSetValue('cmi.interactions.0.student_response', AnswersTried);
-
-
- API.LMSCommit('');
- }
-}
-[/inclScorm1.2]
-
-//JMIX DRAG-DROP OUTPUT FORMAT CODE
-
-var Punctuation = '[strPunctuation]';
-
-var Openers = '[strOpenPunctuation]';
-var CorrectResponse = '[strGuessCorrect]';
-var IncorrectResponse = '[strGuessIncorrect]';
-var ThisMuchCorrect = '[strThisMuch]';
-var TheseAnswersToo = '[strTheseAnswersToo]';
-var YourScoreIs = '[strYourScoreIs]';
-var NextCorrect = '[strNextCorrect]';
-var FeedbackWidth = 200; //default
-var ExBGColor = '[strExBGColor]';
-var PageBGColor = '[strPageBGColor]';
-var TextColor = '[strTextColor]';
-var TitleColor = '[strTitleColor]';
-var DropTotal = 3; // number of lines that will be available for dropping on
-var Gap = 4; //Gap between two segments when they're next to each other on a line
-var DropHeight = 30;
-var CapitalizeFirst = [boolCapitalizeFirst];
-var CompiledOutput = '';
-var TempSegment = '';
-var FirstSegment = -1;
-var FirstDiv = -1;
-var Penalties = 0;
-var Score = 0;
-var TimeOver = false;
-
-var CurrDrag = -1;
-var topZ = 100;
-var Cds = new Array();
-var L = new Array();
-var Finished = false;
-
-var Locked = false;
-var DivWidth = 600;
-var LeftColPos = 100;
-var DragTop = 120;
-var DragNumber = -1;
-var AnswersTried = '';
-
-Lines = new Array();
-
-function CapFirst(InString){
- var i = 0;
- if ((Openers.indexOf(InString.charAt(i))>-1)||(InString.charAt(i) == ' ')){
- i++;
- }
- if ((Openers.indexOf(InString.charAt(i))>-1)||(InString.charAt(i) == ' ')){
- i++;
- }
- var Temp = InString.charAt(i);
- Temp = Temp.toUpperCase();
- InString = InString.substring(0, i) + Temp + InString.substring(i+1, InString.length);
- return InString;
-}
-
-function CheckResults(ChkType){
-//Get sequence student has chosen
- GetGuessSequence();
-
-//Compile the answer
- CompiledOutput = CompileString(GuessSequence);
-
-//Check the answer
- CheckAnswer(ChkType);
-}
-
-function GetGuessSequence(){
-//Put pointers to draggables in arrays based on the lines they're sitting on
- var Drops = new Array();
- for (var i=0; i -4)){
- Drops[j][Drops[j].length] = Cds[i];
- }
- }
- }
-
-//Sort the drop arrays based on the Left of each div
- for (i=0; i 0){
- NewFirstDiv = Drops[i][0].index;
- break;
- }
- }
- return NewFirstDiv;
-}
-
-function CompDrags(a,b){
- return a.GetL() - b.GetL();
-}
-
-function FindSegment(SegID){
- var Seg = '';
- for (var i=0; i 0){
- OutString = OutArray[0];
- }
- else{
- OutString = '';
- }
- var Spacer = '';
-
- for (i=1; i -1)||(Punctuation.indexOf(OutArray[i].charAt(0)) > -1)){
- Spacer = '';
- }
- OutString = OutString + Spacer + OutArray[i];
- }
-
-//Capitalize the first letter if necessary
- if (CapitalizeFirst == true){
- OutString = CapFirst(OutString);
- }
- return OutString;
-}
-
-function CheckAnswer(CheckType){
- if (Locked == true){return;}
- if (GuessSequence.length < 1){
- if (CheckType == 1){
- Penalties++;
- ShowMessage(NextCorrect + '
' + FindSegment(Answers[0][0]));
- }
- return;
- }
- var i = 0;
- var j = 0;
- var k = 0;
- var WellDone = '';
- var WhichCorrect = -1;
- var TryAgain = '';
- var LongestCorrectBit = '';
- TempCorrect = new Array();
- LongestCorrect = new Array();
- var TempHint = '';
- var HintToReturn = 1;
- var OtherAnswers = '';
- var AllDone = false;
-
- for (i=0; i LongestCorrect.length){
- LongestCorrect.length = 0;
- for (k=0; k -1){
- AllDone = true;
- for (i=0; i' + CompileString(Answers[i]);
- }
- }
- WellDone = '' + CompiledOutput + '
' + CorrectResponse + ' ';
-
- if (AnswersTried.length > 0){AnswersTried += ' | ';}
- AnswersTried += CompiledOutput;
-
-//Do score calculation here
- Score = Math.floor(((Segments.length-Penalties) * 100)/Segments.length);
- WellDone += YourScoreIs + ' ' + Score + '%. ';
-
-[inclAlsoCorrect]
- if (OtherAnswers.length > 0){
- WellDone += TheseAnswersToo + '' + OtherAnswers + '';
- }
-[/inclAlsoCorrect]
-
- ShowMessage(WellDone);
- WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
- }
-
- else{
- var WrongGuess = CompileString(GuessSequence);
- if (AnswersTried.length > 0){AnswersTried += ' | ';}
- AnswersTried += WrongGuess;
- TryAgain = '' + WrongGuess + '
';
- if ((CheckType == 0)||(LongestCorrect.length==0)){
- TryAgain += IncorrectResponse + ' ';
- }
-
- if (LongestCorrect.length > 0){
- LongestCorrectBit = CompileString(LongestCorrect);
- GuessSequence.length = LongestCorrect.length;
- TryAgain += ' ' + ThisMuchCorrect + ' ' + LongestCorrectBit + ' ';
- }
-
- if (CheckType == 1){
- TryAgain += ' ' + NextCorrect + ' ' + FindSegment(HintToReturn);
- }
-
-[inclTimer]
- if (TimeOver == true){
- Score = Math.floor(((LongestCorrect.length-Penalties) * 100)/Segments.length);
- if (Score < 0){Score = 0;}
- TryAgain += YourScoreIs + ' ' + Score + '%. ';
- }
-[/inclTimer]
- Penalties++; //Penalty for inaccurate check
- ShowMessage(TryAgain);
- }
-
-//If the exercise is over, deal with that
- if ((AllDone == true)||(TimeOver == true)){
-[inclSendResults]
- setTimeout('SendResults(' + Score + ')', 50);
-[/inclSendResults]
-[inclTimer]
- window.clearInterval(Interval);
-[/inclTimer]
- TimeOver = true;
- Locked = true;
- Finished = true;
- setTimeout('Finish()', SubmissionTimeout);
- WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
- }
-
-[inclScorm1.2]
- if (AllDone == true){
- SetScormComplete();
- }
- else{
- SetScormIncomplete();
- }
-[/inclScorm1.2]
-}
-
-
-var Segments = new Array();
-[SegmentArray]
-
-var GuessSequence = new Array();
-
-var Answers = new Array();
-[AnswerArray]
-
-function doDrag(e) {
- if (CurrDrag == -1) {return};
- if (C.ie){var Ev = window.event}else{var Ev = e}
- var difX = Ev.clientX-window.lastX;
- var difY = Ev.clientY-window.lastY;
- var newX = Cds[CurrDrag].GetL()+difX;
- var newY = Cds[CurrDrag].GetT()+difY;
- Cds[CurrDrag].SetL(newX);
- Cds[CurrDrag].SetT(newY);
- window.lastX = Ev.clientX;
- window.lastY = Ev.clientY;
- return false;
-}
-
-function beginDrag(e, DragNum) {
- CurrDrag = DragNum;
- if (C.ie){
- var Ev = window.event;
- document.onmousemove=doDrag;
- document.onmouseup=endDrag;
- }
- else{
- var Ev = e;
- window.onmousemove=doDrag;
- window.onmouseup=endDrag;
- }
- Cds[CurrDrag].SwapColours();
- topZ++;
- Cds[CurrDrag].css.zIndex = topZ;
- window.lastX=Ev.clientX;
- window.lastY=Ev.clientY;
- return true;
-}
-
-function endDrag(e) {
- if (CurrDrag == -1) {return};
- Cds[CurrDrag].SwapColours();
- if (C.ie){document.onmousemove=null}else{window.onmousemove=null;}
- onEndDrag();
- CurrDrag = -1;
- return true;
-}
-
-function onEndDrag(){
-//Snap to lines
- var i = 0;
- var SnapLine = Cds[CurrDrag].GetT();
- var BiggestOverlap = -1;
- var OverlapRect = 0;
- for (i=0; i OverlapRect){
- OverlapRect = Cds[CurrDrag].Overlap(L[i]);
- BiggestOverlap = i;
- }
- }
- if (BiggestOverlap > -1){
- SnapLine = L[BiggestOverlap].GetB() - (Cds[CurrDrag].GetH() + 2);
- Cds[CurrDrag].SetT(SnapLine);
- CheckOver(-1);
- }
- if (CapitalizeFirst==true){
- setTimeout('DoCapitalization()', 50);
- }
-}
-
-function DoCapitalization(){
-//Capitalize first segment if necessary
- var FD = GetGuessSequence();
- if ((FD == -1)&&(FirstDiv > -1)){
- Cds[FirstDiv].elm.innerHTML = Segments[FirstDiv][0];
- }
- if (((FD != FirstDiv)&&(CapitalizeFirst == true))&&(FD > -1)){
- if (FirstDiv > -1){
- Cds[FirstDiv].elm.innerHTML = Segments[FirstDiv][0];
- }
- }
- if ((FD > -1)&&(CapitalizeFirst == true)){
- var Temp = CapFirst(Segments[FD][0]);
- Cds[FD].elm.innerHTML = Temp;
- FirstDiv = FD;
- }
-}
-
-function CheckOver(NoMove){
-//This recursive function spreads out the Cards on a line if two of them are overlapping;
-//if the spread operation moves one beyond the end of a line, it wraps it to the next line.
- for (var i=0; i 0){
- if ((i==NoMove)||(Cds[i].GetL() < Cds[j].GetL())){
- Cds[j].DockToR(Cds[i]);
- if (Cds[j].GetR() > (LeftColPos + DivWidth)){
- Cds[j].SetL(LeftColPos);
- Cds[j].SetT(Cds[j].GetT() + DropHeight);
- }
- CheckOver(j);
- }
- else{
- Cds[i].DockToR(Cds[j]);
- if (Cds[i].GetR() > (LeftColPos + DivWidth)){
- Cds[i].SetL(LeftColPos);
- Cds[i].SetT(Cds[i].GetT() + DropHeight);
- }
- CheckOver(i);
- }
- }
- }
- }
- }
-}
-
-function StartUp(){
-
-[inclSendResults]
- GetUserName();
-[/inclSendResults]
-
-[inclScorm1.2]
- ScormStartUp();
-[/inclScorm1.2]
-
-[inclPreloadImages]
- PreloadImages([PreloadImageList]);
-[/inclPreloadImages]
-
- Segments = Shuffle(Segments);
-
-//Calculate page dimensions and positions
- pg = new PageDim();
- DivWidth = Math.floor((pg.W*4)/5);
- LeftColPos = Math.floor(pg.W/10);
- DragTop = parseInt(document.getElementById('CheckButtonDiv').offsetHeight) + parseInt(document.getElementById('CheckButtonDiv').offsetTop) + 10;
-
- var CurrTop = DragTop + 10;
-
-//Position the drop divs
- for (var i=0; i
-
-
-
-[strDublinCoreMetadata]
-
-
-
-
-[strPlainTitle]
-
-
-
-
-
-
-[strHeaderCode]
-
-
-
-
-
-
-
-
-
-
-
-
-
-[inclNavButtons]
-[strTopNavBar]
-[/inclNavButtons]
-
-
-
-
- [strExerciseTitle]
-[inclExerciseSubtitle]
- [strExerciseSubtitle]
-[/inclExerciseSubtitle]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-[inclNavButtons]
-[strBottomNavBar]
-[/inclNavButtons]
-
-
-
-
-
-
-
-
-
-
diff --git a/mod/hotpot/template/v6/fjmatch6.js_ b/mod/hotpot/template/v6/fjmatch6.js_
deleted file mode 100644
index c2aedfa99fa..00000000000
--- a/mod/hotpot/template/v6/fjmatch6.js_
+++ /dev/null
@@ -1,131 +0,0 @@
-
-[inclScorm1.2]
-//JMATCH-SPECIFIC SCORM-RELATED JAVASCRIPT CODE
-
-function SetScormBrowseTime(){
-if (API != null){
- API.LMSSetValue('cmi.core.session_time', MillisecondsToTime((new Date()).getTime() - ScormStartTime));
- API.LMSCommit('');
- }
-}
-[/inclScorm1.2]
-
-//JMATCH-SPECIFIC CORE JAVASCRIPT CODE
-
-var CurrItem = null;
-var Stage = 2;
-var QList = new Array();
-var ShuffleQs = [boolShuffleQs];
-
-function SetUpItems(){
-
- var i;
- var Row = null;
-
-//Remove all the table rows and put them in an array for processing
- var Qs = document.getElementById('Questions');
-
-//Remove the table rows to an array
- while (Qs.getElementsByTagName('tr').length > 0){
- Row = Qs.getElementsByTagName('tr')[0];
- Row.getElementsByTagName('td')[0].className = 'Hidden';
- Row.getElementsByTagName('td')[1].className = 'Hidden';
- QList.push(Qs.removeChild(Row));
- }
-
-//Shuffle the rows
- if (ShuffleQs == true){
- QList = Shuffle(QList);
- }
-
-//Write the rows back to the table body
- for (i=0; i[strReadingTitle]
-[/inclReadingTitle]
-
-[strReadingText]
-
-
diff --git a/mod/hotpot/template/v6/hp6.cs_ b/mod/hotpot/template/v6/hp6.cs_
deleted file mode 100644
index f69f10615c4..00000000000
--- a/mod/hotpot/template/v6/hp6.cs_
+++ /dev/null
@@ -1,605 +0,0 @@
-
-/* This is the CSS stylesheet used in the exercise. */
-/* Elements in square brackets are replaced by data based on configuration settings when the exercise is built. */
-
-/* BeginCorePageCSS */
-
-/* Made with executable version [strFullVersionInfo] */
-
-
-/* Hack to hide a nested Quicktime player from IE, which can't handle it. */
-* html object.MediaPlayerNotForIE {
- display: none;
-}
-
-body{
- font-family: [strFontFace];
-[inclPageBGColor] background-color: [strPageBGColor];[/inclPageBGColor]
- color: [strTextColor];
-[inclGraphicURL] background-image: url([strGraphicURL]);[/inclGraphicURL]
- margin-right: 5%;
- margin-left: 5%;
- font-size: [strFontSize];
-}
-
-p{
- text-align: left;
- margin: 0px;
- font-size: 100%;
-}
-
-table,div,span,td{
- font-size: 100%;
- color: [strTextColor];
-}
-
-div.Titles{
- padding: 0.5em;;
- text-align: center;
- color: [strTitleColor];
-}
-
-button{
- font-family: [strFontFace];
- font-size: 100%;
- display: inline;
-}
-
-.ExerciseTitle{
- font-size: 140%;
- color: [strTitleColor];
-}
-
-.ExerciseSubtitle{
- font-size: 120%;
- color: [strTitleColor];
-}
-
-div.StdDiv{
-[inclExBGColor] background-color: [strExBGColor];[/inclExBGColor]
- text-align: center;
- font-size: 100%;
- color: [strTextColor];
- padding: 0.5em;
- border-style: solid;
- border-width: 1px 1px 1px 1px;
- border-color: [strTextColor];
- margin-bottom: 1px;
-}
-
-/* EndCorePageCSS */
-
-.RTLText{
- text-align: right;
- font-size: 150%;
- direction: rtl;
- font-family: "Simplified Arabic", "Traditional Arabic", "Times New Roman", [strFontFace];
-}
-
-.CentredRTLText{
- text-align: center;
- font-size: 150%;
- direction: rtl;
- font-family: "Simplified Arabic", "Traditional Arabic", "Times New Roman", [strFontFace];
-}
-
-button p.RTLText{
- text-align: center;
-}
-
-.RTLGapBox{
- text-align: right;
- font-size: 150%;
- direction: rtl;
- font-family: "Times New Roman", [strFontFace];
-}
-
-.Guess{
- font-weight: bold;
-}
-
-.CorrectAnswer{
- font-weight: bold;
-}
-
-div#Timer{
- padding: 0.25em;
- margin-left: auto;
- margin-right: auto;
- text-align: center;
- color: [strTitleColor];
-}
-
-span#TimerText{
- padding: 0.25em;
- border-width: 1px;
- border-style: solid;
- font-weight: bold;
- display: none;
- color: [strTitleColor];
-}
-
-span.Instructions{
-
-}
-
-div.ExerciseText{
-
-}
-
-.FeedbackText, .FeedbackText span.CorrectAnswer, .FeedbackText span.Guess, .FeedbackText span.Answer{
- color: [strTitleColor];
-}
-
-.LeftItem{
- font-size: 100%;
- color: [strTextColor];
- text-align: left;
-}
-
-.RightItem{
- font-weight: bold;
- font-size: 100%;
- color: [strTextColor];
-}
-
-span.CorrectMark{
-
-}
-
-input, textarea{
- font-family: [strFontFace];
- font-size: 120%;
-}
-
-select{
- font-size: 100%;
-}
-
-div.Feedback {
-[inclPageBGColor] background-color: [strPageBGColor];[/inclPageBGColor]
- left: 33%;
- width: 34%;
- top: 33%;
- z-index: 1;
- border-style: solid;
- border-width: 1px;
- padding: 5px;
- text-align: center;
- color: [strTitleColor];
- position: absolute;
- display: none;
- font-size: 100%;
-}
-
-
-[inclReading]
-div.LeftContainer{
- border-style: none;
- padding: 2px 0px 2px 0px;
- float: left;
- width: 49.8%;
- margin-bottom: 0px;
-}
-
-div.RightContainer{
- border-style: none;
- padding: 2px 0px 2px 0px;
- float: right;
- width: 49.8%;
- margin-bottom: 0px;
-}
-
-.ReadingText{
- text-align: left;
-}
-
-#ReadingDiv h3.ExerciseSubtitle{
- color: [strTextColor];
-}
-
-[/inclReading]
-
-div.ExerciseDiv{
- color: [strTextColor];
-}
-
-/* JMatch flashcard styles */
-table.FlashcardTable{
- background-color: transparent;
- color: [strTextColor];
- border-color: [strTextColor];
- margin-left: 5%;
- margin-right: 5%;
- margin-top: 2em;
- margin-bottom: 2em;
- width: 90%;
- position: relative;
- text-align: center;
- padding: 0px;
-}
-
-table.FlashcardTable tr{
- border-style: none;
- margin: 0px;
- padding: 0px;
-[inclExBGColor] background-color: [strExBGColor];[/inclExBGColor]
-}
-
-table.FlashcardTable td.Showing{
- font-size: 140%;
- text-align: center;
- width: 50%;
- display: table-cell;
- padding: 2em;
- margin: 0px;
- border-style: solid;
- border-width: 1px;
- color: [strTextColor];
-[inclExBGColor] background-color: [strExBGColor];[/inclExBGColor]
-}
-
-table.FlashcardTable td.Hidden{
- display: none;
-}
-
-/* JMix styles */
-div#SegmentDiv{
- margin-top: 2em;
- margin-bottom: 2em;
- text-align: center;
-}
-
-a.ExSegment{
- font-size: 120%;
- font-weight: bold;
- text-decoration: none;
- color: [strTextColor];
-}
-
-span.RemainingWordList{
- font-style: italic;
-}
-
-div.DropLine {
- position: absolute;
- text-align: center;
- border-bottom-style: solid;
- border-bottom-width: 1px;
- border-bottom-color: [strTitleColor];
- width: 80%;
-}
-
-/* JCloze styles */
-
-.ClozeWordList{
- text-align: center;
- font-weight: bold;
-}
-
-div.ClozeBody{
- text-align: left;
- margin-top: 2em;
- margin-bottom: 2em;
- line-height: 2.0
-}
-
-span.GapSpan{
- font-weight: bold;
-}
-
-/* JCross styles */
-
-table.CrosswordGrid{
- margin: auto auto 1em auto;
- border-collapse: collapse;
- padding: 0px;
- background-color: #000000;
-}
-
-table.CrosswordGrid tbody tr td{
- width: 1.5em;
- height: 1.5em;
- text-align: center;
- vertical-align: middle;
- font-size: 140%;
- padding: 1px;
- margin: 0px;
- border-style: solid;
- border-width: 1px;
- border-color: #000000;
- color: #000000;
-}
-
-table.CrosswordGrid span{
- color: #000000;
-}
-
-table.CrosswordGrid td.BlankCell{
- background-color: #000000;
- color: #000000;
-}
-
-table.CrosswordGrid td.LetterOnlyCell{
- text-align: center;
- vertical-align: middle;
- background-color: #ffffff;
- color: #000000;
- font-weight: bold;
-}
-
-table.CrosswordGrid td.NumLetterCell{
- text-align: left;
- vertical-align: top;
- background-color: #ffffff;
- color: #000000;
- padding: 1px;
- font-weight: bold;
-}
-
-.NumLetterCellText{
- cursor: pointer;
- color: #000000;
-}
-
-.GridNum{
- vertical-align: super;
- font-size: 66%;
- font-weight: bold;
- text-decoration: none;
- color: #000000;
-}
-
-.GridNum:hover, .GridNum:visited{
- color: #000000;
-}
-
-table#Clues{
- margin: auto;
- vertical-align: top;
-}
-
-table#Clues td{
- vertical-align: top;
-}
-
-table.ClueList{
- margin: auto;
-}
-
-td.ClueNum{
- text-align: right;
- font-weight: bold;
- vertical-align: top;
-}
-
-td.Clue{
- text-align: left;
-}
-
-div#ClueEntry{
- text-align: left;
- margin-bottom: 1em;
-}
-
-/* Keypad styles */
-
-div.Keypad{
- text-align: center;
- display: none; /* initially hidden, shown if needed */
- margin-bottom: 0.5em;
-}
-
-div.Keypad button{
- font-family: [strFontFace];
- font-size: 120%;
- background-color: #ffffff;
- color: #000000;
- width: 2em;
-}
-
-/* JQuiz styles */
-
-div.QuestionNavigation{
- text-align: center;
-}
-
-.QNum{
- margin: 0em 1em 0.5em 1em;
- font-weight: bold;
- vertical-align: middle;
-}
-
-textarea{
- font-family: [strFontFace];
-}
-
-.QuestionText{
- text-align: left;
- margin: 0px;
- font-size: 100%;
-}
-
-.Answer{
- font-size: 120%;
- letter-spacing: 0.1em;
-}
-
-.PartialAnswer{
- font-size: 120%;
- letter-spacing: 0.1em;
- color: [strTitleColor];
-}
-
-.Highlight{
- color: #000000;
- background-color: #ffff00;
- font-weight: bold;
- font-size: 120%;
-}
-
-ol.QuizQuestions{
- text-align: left;
- list-style-type: none;
-}
-
-li.QuizQuestion{
- padding: 1em;
- border-style: solid;
- border-width: 0px 0px 1px 0px;
-}
-
-ol.MCAnswers{
- text-align: left;
- list-style-type: upper-alpha;
- padding: 1em;
-}
-
-ol.MCAnswers li{
- margin-bottom: 1em;
-}
-
-ol.MSelAnswers{
- text-align: left;
- list-style-type: lower-alpha;
- padding: 1em;
-}
-
-div.ShortAnswer{
- padding: 1em;
-}
-
-.FuncButton {
- text-align: center;
- border-style: solid;
-[inclExBGColor]
- border-left-color: [strFuncLightColor];
- border-top-color: [strFuncLightColor];
- border-right-color: [strFuncShadeColor];
- border-bottom-color: [strFuncShadeColor];
- color: [strTextColor];
- background-color: [strExBGColor];
-[/inclExBGColor]
- border-width: 2px;
- padding: 3px 6px 3px 6px;
- cursor: pointer;
-}
-
-.FuncButtonUp {
- color: [strExBGColor];
- text-align: center;
- border-style: solid;
-[inclExBGColor]
- border-left-color: [strFuncLightColor];
- border-top-color: [strFuncLightColor];
- border-right-color: [strFuncShadeColor];
- border-bottom-color: [strFuncShadeColor];
-[/inclExBGColor]
- background-color: [strTextColor];
- color: [strExBGColor];
- border-width: 2px;
- padding: 3px 6px 3px 6px;
- cursor: pointer;
-}
-
-.FuncButtonDown {
- color: [strExBGColor];
- text-align: center;
- border-style: solid;
-[inclExBGColor]
- border-left-color: [strFuncShadeColor];
- border-top-color: [strFuncShadeColor];
- border-right-color: [strFuncLightColor];
- border-bottom-color: [strFuncLightColor];
- background-color: [strTextColor];
- color: [strExBGColor];
-[/inclExBGColor]
- border-width: 2px;
- padding: 3px 6px 3px 6px;
- cursor: pointer;
-}
-
-/*BeginNavBarStyle*/
-
-div.NavButtonBar{
-[inclNavBarColor] background-color: [strNavBarColor];[/inclNavBarColor]
- text-align: center;
- margin: 2px 0px 2px 0px;
- clear: both;
- font-size: 100%;
-}
-
-.NavButton {
- border-style: solid;
-[inclNavBarColor]
- border-left-color: [strNavLightColor];
- border-top-color: [strNavLightColor];
- border-right-color: [strNavShadeColor];
- border-bottom-color: [strNavShadeColor];
- background-color: [strNavBarColor];
- color: [strNavTextColor];
-[/inclNavBarColor]
- border-width: 2px;
- cursor: pointer;
-}
-
-.NavButtonUp {
- border-style: solid;
-[inclNavBarColor]
- border-left-color: [strNavLightColor];
- border-top-color: [strNavLightColor];
- border-right-color: [strNavShadeColor];
- border-bottom-color: [strNavShadeColor];
- color: [strNavBarColor];
- background-color: [strNavTextColor];
-[/inclNavBarColor]
- border-width: 2px;
- cursor: pointer;
-}
-
-.NavButtonDown {
- border-style: solid;
-[inclNavBarColor]
- border-left-color: [strNavShadeColor];
- border-top-color: [strNavShadeColor];
- border-right-color: [strNavLightColor];
- border-bottom-color: [strNavLightColor];
- color: [strNavBarColor];
- background-color: [strNavTextColor];
-[/inclNavBarColor]
- border-width: 2px;
- cursor: pointer;
-}
-
-/*EndNavBarStyle*/
-
-a{
- color: [strLinkColor];
-}
-
-a:visited{
- color: [strVLinkColor];
-}
-
-a:hover{
- color: [strLinkColor];
-}
-
-div.CardStyle {
- position: absolute;
- font-family: [strFontFace];
- font-size: 100%;
- padding: 5px;
- border-style: solid;
- border-width: 1px;
- color: [strTextColor];
-[inclExBGColor] background-color: [strExBGColor];[/inclExBGColor]
- left: -50px;
- top: -50px;
- overflow: visible;
-}
-
-.rtl{
- text-align: right;
- font-size: 140%;
-}
diff --git a/mod/hotpot/template/v6/hp6browsercheck.js_ b/mod/hotpot/template/v6/hp6browsercheck.js_
deleted file mode 100644
index 406eb509378..00000000000
--- a/mod/hotpot/template/v6/hp6browsercheck.js_
+++ /dev/null
@@ -1,55 +0,0 @@
-
-function Client(){
-//if not a DOM browser, hopeless
- this.min = false; if (document.getElementById){this.min = true;};
-
- this.ua = navigator.userAgent;
- this.name = navigator.appName;
- this.ver = navigator.appVersion;
-
-//Get data about the browser
- this.mac = (this.ver.indexOf('Mac') != -1);
- this.win = (this.ver.indexOf('Windows') != -1);
-
-//Look for Gecko
- this.gecko = (this.ua.indexOf('Gecko') > 1);
- if (this.gecko){
- this.geckoVer = parseInt(this.ua.substring(this.ua.indexOf('Gecko')+6, this.ua.length));
- if (this.geckoVer < 20020000){this.min = false;}
- }
-
-//Look for Firebird
- this.firebird = (this.ua.indexOf('Firebird') > 1);
-
-//Look for Safari
- this.safari = (this.ua.indexOf('Safari') > 1);
- if (this.safari){
- this.gecko = false;
- }
-
-//Look for IE
- this.ie = (this.ua.indexOf('MSIE') > 0);
- if (this.ie){
- this.ieVer = parseFloat(this.ua.substring(this.ua.indexOf('MSIE')+5, this.ua.length));
- if (this.ieVer < 5.5){this.min = false;}
- }
-
-//Look for Opera
- this.opera = (this.ua.indexOf('Opera') > 0);
- if (this.opera){
- this.operaVer = parseFloat(this.ua.substring(this.ua.indexOf('Opera')+6, this.ua.length));
- if (this.operaVer < 7.04){this.min = false;}
- }
- if (this.min == false){
- alert('Your browser may not be able to handle this page.');
- }
-
-//Special case for the horrible ie5mac
- this.ie5mac = (this.ie&&this.mac&&(this.ieVer<6));
-}
-
-var C = new Client();
-
-//for (prop in C){
-// alert(prop + ': ' + C[prop]);
-//}
diff --git a/mod/hotpot/template/v6/hp6buttons.js_ b/mod/hotpot/template/v6/hp6buttons.js_
deleted file mode 100644
index 5732bb80a1d..00000000000
--- a/mod/hotpot/template/v6/hp6buttons.js_
+++ /dev/null
@@ -1,42 +0,0 @@
-
-//CODE FOR HANDLING NAV BUTTONS AND FUNCTION BUTTONS
-
-//[strNavBarJS]
-function NavBtnOver(Btn){
- if (Btn.className != 'NavButtonDown'){Btn.className = 'NavButtonUp';}
-}
-
-function NavBtnOut(Btn){
- Btn.className = 'NavButton';
-}
-
-function NavBtnDown(Btn){
- Btn.className = 'NavButtonDown';
-}
-//[/strNavBarJS]
-
-function FuncBtnOver(Btn){
- if (Btn.className != 'FuncButtonDown'){Btn.className = 'FuncButtonUp';}
-}
-
-function FuncBtnOut(Btn){
- Btn.className = 'FuncButton';
-}
-
-function FuncBtnDown(Btn){
- Btn.className = 'FuncButtonDown';
-}
-
-function FocusAButton(){
- if (document.getElementById('CheckButton1') != null){
- document.getElementById('CheckButton1').focus();
- }
- else{
- if (document.getElementById('CheckButton2') != null){
- document.getElementById('CheckButton2').focus();
- }
- else{
- document.getElementsByTagName('button')[0].focus();
- }
- }
-}
diff --git a/mod/hotpot/template/v6/hp6card.js_ b/mod/hotpot/template/v6/hp6card.js_
deleted file mode 100644
index 6fc15b86170..00000000000
--- a/mod/hotpot/template/v6/hp6card.js_
+++ /dev/null
@@ -1,152 +0,0 @@
-
-function Card(ID, OverlapTolerance){
- this.elm=document.getElementById(ID);
- this.name=ID;
- this.css=this.elm.style;
- this.elm.style.left = 0 +'px';
- this.elm.style.top = 0 +'px';
- this.HomeL = 0;
- this.HomeT = 0;
- this.tag=-1;
- this.index=-1;
- this.OverlapTolerance = OverlapTolerance;
-}
-
-function CardGetL(){return parseInt(this.css.left)}
-Card.prototype.GetL=CardGetL;
-
-function CardGetT(){return parseInt(this.css.top)}
-Card.prototype.GetT=CardGetT;
-
-function CardGetW(){return parseInt(this.elm.offsetWidth)}
-Card.prototype.GetW=CardGetW;
-
-function CardGetH(){return parseInt(this.elm.offsetHeight)}
-Card.prototype.GetH=CardGetH;
-
-function CardGetB(){return this.GetT()+this.GetH()}
-Card.prototype.GetB=CardGetB;
-
-function CardGetR(){return this.GetL()+this.GetW()}
-Card.prototype.GetR=CardGetR;
-
-function CardSetL(NewL){this.css.left = NewL+'px'}
-Card.prototype.SetL=CardSetL;
-
-function CardSetT(NewT){this.css.top = NewT+'px'}
-Card.prototype.SetT=CardSetT;
-
-function CardSetW(NewW){this.css.width = NewW+'px'}
-Card.prototype.SetW=CardSetW;
-
-function CardSetH(NewH){this.css.height = NewH+'px'}
-Card.prototype.SetH=CardSetH;
-
-function CardInside(X,Y){
- var Result=false;
- if(X>=this.GetL()){if(X<=this.GetR()){if(Y>=this.GetT()){if(Y<=this.GetB()){Result=true;}}}}
- return Result;
-}
-Card.prototype.Inside=CardInside;
-
-function CardSwapColours(){
- var c=this.css.backgroundColor;
- this.css.backgroundColor=this.css.color;
- this.css.color=c;
-}
-Card.prototype.SwapColours=CardSwapColours;
-
-function CardHighlight(){
- this.css.backgroundColor='[strTextColor]';
- this.css.color='[strExBGColor]';
-}
-Card.prototype.Highlight=CardHighlight;
-
-function CardUnhighlight(){
- this.css.backgroundColor='[strExBGColor]';
- this.css.color='[strTextColor]';
-}
-Card.prototype.Unhighlight=CardUnhighlight;
-
-function CardOverlap(OtherCard){
- var smR=(this.GetR()<(OtherCard.GetR()+this.OverlapTolerance))? this.GetR(): (OtherCard.GetR()+this.OverlapTolerance);
- var lgL=(this.GetL()>OtherCard.GetL())? this.GetL(): OtherCard.GetL();
- var HDim=smR-lgL;
- if (HDim<1){return 0;}
- var smB=(this.GetB()OtherCard.GetT())? this.GetT(): OtherCard.GetT();
- var VDim=smB-lgT;
- if (VDim<1){return 0;}
- return (HDim*VDim);
-}
-Card.prototype.Overlap=CardOverlap;
-
-function CardDockToR(OtherCard){
- this.SetL(OtherCard.GetR() + 5);
- this.SetT(OtherCard.GetT());
-}
-
-Card.prototype.DockToR=CardDockToR;
-
-function CardSetHome(){
- this.HomeL=this.GetL();
- this.HomeT=this.GetT();
-}
-Card.prototype.SetHome=CardSetHome;
-
-function CardGoHome(){
- this.SetL(this.HomeL);
- this.SetT(this.HomeT);
-}
-
-Card.prototype.GoHome=CardGoHome;
-
-
-function doDrag(e) {
- if (CurrDrag == -1) {return};
- if (C.ie){var Ev = window.event}else{var Ev = e}
- var difX = Ev.clientX-window.lastX;
- var difY = Ev.clientY-window.lastY;
- var newX = DC[CurrDrag].GetL()+difX;
- var newY = DC[CurrDrag].GetT()+difY;
- DC[CurrDrag].SetL(newX);
- DC[CurrDrag].SetT(newY);
- window.lastX = Ev.clientX;
- window.lastY = Ev.clientY;
- return false;
-}
-
-function beginDrag(e, DragNum) {
- CurrDrag = DragNum;
- if (C.ie){
- var Ev = window.event;
- document.onmousemove=doDrag;
- document.onmouseup=endDrag;
- }
- else{
- var Ev = e;
- window.onmousemove=doDrag;
- window.onmouseup=endDrag;
- }
- DC[CurrDrag].Highlight();
- topZ++;
- DC[CurrDrag].css.zIndex = topZ;
- window.lastX=Ev.clientX;
- window.lastY=Ev.clientY;
- return false;
-}
-
-function endDrag(e) {
- if (CurrDrag == -1) {return};
- DC[CurrDrag].Unhighlight();
- if (C.ie){document.onmousemove=null}else{window.onmousemove=null;}
- onEndDrag();
- CurrDrag = -1;
-//Need a bugfix for Opera focus problem here
- if (C.opera){FocusAButton();}
- return true;
-}
-
-var CurrDrag = -1;
-var topZ = 100;
-
diff --git a/mod/hotpot/template/v6/hp6checkshortanswer.js_ b/mod/hotpot/template/v6/hp6checkshortanswer.js_
deleted file mode 100644
index 6792ef19810..00000000000
--- a/mod/hotpot/template/v6/hp6checkshortanswer.js_
+++ /dev/null
@@ -1,405 +0,0 @@
-//CORE CODE FOR CHECKING SHORT ANSWER GUESSES AGAINST ANSWER ARRAYS
-
-var CaseSensitive = [boolCaseSensitive];
-var ShowAlsoCorrect = [boolShowAlsoCorrect];
-var PleaseEnter = '[strPleaseEnter]';
-var HybridTries = [intHybridTries];
-var PartlyIncorrect = '[strPartlyIncorrect]';
-var CorrectList = '[strCorrectList]';
-var NextCorrect = '[strNextCorrect]';
-var CurrBox = null;
-
-function TrackFocus(BoxID){
- InTextBox = true;
- CurrBox = document.getElementById(BoxID);
-}
-
-function LeaveGap(){
- InTextBox = false;
-}
-
-function TypeChars(Chars){
- if (CurrBox != null){
-//Following check added for 6.0.4.4 to avoid error message in IE6
- if (CurrBox.style.display != 'none'){
- CurrBox.value += Chars;
- CurrBox.focus();
- }
- }
-}
-
-function CheckGuess(Guess, Answer, CaseSensitive, PercentCorrect, Feedback){
- this.Guess = Guess;
- this.Answer = Answer;
- this.PercentCorrect = PercentCorrect;
- this.Feedback = Feedback;
- if (CaseSensitive == false){
- this.WorkingGuess = Guess.toLowerCase();
- this.WorkingAnswer = Answer.toLowerCase();
- }
- else{
- this.WorkingGuess = Guess;
- this.WorkingAnswer = Answer;
- }
- this.Hint = '';
- this.HintPenalty = 1/Answer.length;
- this.CorrectStart = '';
- this.WrongMiddle = '';
- this.CorrectEnd = '';
- this.PercentMatch = 0;
- this.DoCheck();
-}
-
-function CheckGuess_DoCheck(){
-//Check if it's an exact match
- if (this.WorkingAnswer == this.WorkingGuess){
- this.PercentMatch = 100;
- this.CorrectStart = this.Guess;
- return;
- }
-//Figure out how much of the beginning is correct
- var i = 0;
- var CorrectChars = 0;
- while (this.WorkingAnswer.charAt(i) == this.WorkingGuess.charAt(i)){
- i++;
- CorrectChars++;
- }
-//Stash the hint
- this.Hint = this.Answer.charAt(i);
-
- this.CorrectStart = this.Guess.substring(0, i);
-
-//If there's more to the answer, look at the rest of it
- if (i=i)&&((this.WorkingAnswer.charAt(k) == this.WorkingGuess.charAt(j))&&(CorrectChars < this.Answer.length))){
- CorrectChars++;
- j--;
- k--;
- }
- this.CorrectEnd = this.Guess.substring(j+1, this.Guess.length);
- this.WrongMiddle = this.Guess.substring(i, j+1);
- }
- if (TrimString(this.WrongMiddle).length < 1){this.WrongMiddle = '_';}
-//Calculate match score based on how much of the guess is correct
- if (CorrectChars < this.Answer.length){
- this.PercentMatch = Math.floor(100*CorrectChars)/this.Answer.length;
- }
- else{
- this.PercentMatch = Math.floor((100 * CorrectChars)/this.Guess.length);
- }
-}
-
-CheckGuess.prototype.DoCheck = CheckGuess_DoCheck;
-
-function CheckAnswerArray(CaseSensitive){
- this.CaseSensitive = CaseSensitive;
- this.Answers = new Array();
- this.Score = 0;
- this.Feedback = '';
- this.Hint = '';
- this.HintPenalty = 0;
- this.MatchedAnswerLength = 1;
- this.CompleteMatch = false;
- this.MatchNum = -1;
-}
-
-function CheckAnswerArray_AddAnswer(Guess, Answer, PercentCorrect, Feedback){
- this.Answers.push(new CheckGuess(Guess, Answer, this.CaseSensitive, PercentCorrect, Feedback));
-}
-
-CheckAnswerArray.prototype.AddAnswer = CheckAnswerArray_AddAnswer;
-
-function CheckAnswerArray_ClearAll(){
- this.Answers.length = 0;
-}
-
-CheckAnswerArray.prototype.ClearAll = CheckAnswerArray_ClearAll;
-
-function CheckAnswerArray_GetBestMatch(){
-//First check for a 100% match
- for (var i=0; i PercentMatch)&&(this.Answers[i].PercentCorrect == 100)){
- BestMatch = i;
- PercentMatch = this.Answers[i].PercentMatch;
- }
- }
- if (BestMatch > -1){
- this.Score = this.Answers[BestMatch].PercentMatch;
- this.Feedback = PartlyIncorrect + ' ';
- this.Feedback += '' + this.Answers[BestMatch].CorrectStart;
- this.Feedback += '' + this.Answers[BestMatch].WrongMiddle + '';
- this.Feedback += this.Answers[BestMatch].CorrectEnd + '';
- this.Hint = '' + this.Answers[BestMatch].CorrectStart;
- this.Hint += '' + this.Answers[BestMatch].Hint + '';
- this.HintPenalty = this.Answers[BestMatch].HintPenalty;
- }
- else{
- this.Score = 0;
- this.Feedback = '';
- }
-}
-
-CheckAnswerArray.prototype.GetBestMatch = CheckAnswerArray_GetBestMatch;
-
-function CheckShortAnswer(QNum){
-//bail if question doesn't exist or exercise finished
- if ((State[QNum].length < 1)||(Finished == true)){return;}
-
-//bail if question already complete
- if (State[QNum][0] > -1){return;}
-
-//Get the guess (TrimString added to fix bug for 6.0.4.3)
- var G = TrimString(document.getElementById('Q_' + QNum + '_Guess').value);
-
-//If no guess, bail with message; no penalty
- if (G.length < 1){
- ShowMessage(PleaseEnter);
- return;
- }
-
-//Increment tries
- State[QNum][2]++;
-
-//Create a check object
- var CA = new CheckAnswerArray(CaseSensitive);
-
- CA.ClearAll();
- for (var ANum=0; ANum 0){State[QNum][5] += ' | ';}
- if (CA.MatchNum > -1){
- State[QNum][5] += String.fromCharCode(65+CA.MatchNum);
- }
-//Else store the student's answer
- else{
- State[QNum][5] += G;
- }
-
-//Add the percent correct value for this answer to the Q State (works for all
-//situations, wrong or right)
- State[QNum][3] += CA.Score;
-
-//Now branch, based on the nature of the match
-//Is it a complete match?
- if (CA.CompleteMatch == true){
-
-//Is it with a wrong answer, or a right answer?
- if (CA.Score == 100){
-//It's right
- CalculateShortAnsQuestionScore(QNum);
-//Get correct answer list if required, assuming there are any other correct alternatives
- if (ShowAlsoCorrect == true){
- var AlsoCorrectList = GetCorrectList(QNum, G, false);
- if (AlsoCorrectList.length > 0){
- CA.Feedback += ' ' + CorrectList + ' ' + AlsoCorrectList;
- }
- }
-
-//Get the overall score and add it to the feedback
- if (ContinuousScoring == true){
- CalculateOverallScore();
- CA.Feedback += ' ' + YourScoreIs + ' ' + Score + '%.';
- WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
- }
- ShowMessage(CA.Feedback);
-//Put the answer in
- ReplaceGuessBox(QNum, G);
- CheckFinished();
- return;
- }
- }
-
-//Otherwise, it's a match to a predicted wrong/partially correct, or a partial
-//match to a right answer
- if (CA.Feedback.length < 1){CA.Feedback = DefaultWrong;}
-//Remove any previous score unless exercise is finished (6.0.3.8+)
- if (Finished == false){
- WriteToInstructions(strInstructions);
- }
- ShowMessage(CA.Feedback);
-
-//If necessary, switch a hybrid question to m/c
- if (State[QNum][2] >= HybridTries){
- SwitchHybridDisplay(QNum);
- }
-}
-
-function CalculateShortAnsQuestionScore(QNum){
- var Tries = State[QNum][2] + State[QNum][4]; //include tries and hint penalties;
- var PercentCorrect = State[QNum][3];
- var HintPenalties = State[QNum][4];
-
-//Make sure it's not already complete
- if (State[QNum][0] < 0){
- if (HintPenalties >= 1){
- State[QNum][0] = 0;
- }
- else{
- State[QNum][0] = (PercentCorrect/(100*Tries));
- }
- if (State[QNum][0] < 0){
- State[QNum][0] = 0;
- }
- }
-}
-
-function SwitchHybridDisplay(QNum){
- if (document.getElementById('Q_' + QNum + '_Hybrid_MC') != null){
- document.getElementById('Q_' + QNum + '_Hybrid_MC').style.display = '';
- if (document.getElementById('Q_' + QNum + '_SA') != null){
- document.getElementById('Q_' + QNum + '_SA').style.display = 'none';
- }
- }
-}
-
-function GetCorrectArray(QNum){
- var Result = new Array();
- for (var ANum=0; ANum';
- }
- }
- return Result;
-}
-
-function GetFirstCorrectAnswer(QNum){
- var As = GetCorrectArray(QNum);
- if (As.length > 0){
- return As[0];
- }
- else{
- return '';
- }
-}
-
-function ReplaceGuessBox(QNum, Ans){
- if (document.getElementById('Q_' + QNum + '_SA') != null){
- var El = document.getElementById('Q_' + QNum + '_SA');
- while (El.childNodes.length > 0){
- El.removeChild(El.childNodes[0]);
- }
- var A = document.createElement('span');
- A.setAttribute('class', 'Answer');
- var T = document.createTextNode(Ans);
- A.appendChild(T);
- El.appendChild(A);
- }
-}
-
-[inclShowAnswer]
-
-function ShowAnswers(QNum){
-//bail if question doesn't exist or exercise finished
- if ((State[QNum].length < 1)||(Finished == true)){return;}
-
-//Get the answer list to display
- var Ans = GetCorrectList(QNum, '', false);
- Ans = CorrectList + ' ' + Ans;
-
-//Display feedback
- ShowMessage(Ans);
-
-//Set the score for this question to 0 if no
- if (State[QNum][0] < 1){
- State[QNum][0] = 0;
- }
-
-//Get the first correct answer
- var FirstAns = GetFirstCorrectAnswer(QNum);
-
-//Replace the textbox
- ReplaceGuessBox(QNum, FirstAns);
-
-//Remove any current score
- WriteToInstructions(strInstructions);
-
-//This may be the last, so check finished status
- CheckFinished();
-}
-
-[/inclShowAnswer]
-
-[inclHint]
-
-function ShowHint(QNum){
-//bail if question doesn't exist or exercise finished
- if ((State[QNum].length < 1)||(Finished == true)){return;}
-
-//bail if question already complete
- if (State[QNum][0] > -1){return;}
-
-//Get the guess
- var G = document.getElementById('Q_' + QNum + '_Guess').value;
-
-//If no guess, give the first correct bit
- if (G.length < 1){
- var Ans = GetFirstCorrectAnswer(QNum);
- var Hint = Ans.charAt(0);
- ShowMessage(NextCorrect + ' ' + Hint);
-//Penalty for hint
- State[QNum][4] += (1/Ans.length);
- return;
- }
-
-//Increment tries
- State[QNum][2]++;
-
-//Create a check object
- var CA = new CheckAnswerArray(CaseSensitive);
-
- CA.ClearAll();
- for (var ANum=0; ANum 0){
- ShowMessage(NextCorrect + ' ' + CA.Hint);
- State[QNum][4] += CA.HintPenalty;
- }
- else{
- ShowMessage(DefaultWrong + ' ' + NextCorrect + ' ' + GetFirstCorrectAnswer(QNum).charAt(0));
- }
- }
-}
-
-[/inclHint]
\ No newline at end of file
diff --git a/mod/hotpot/template/v6/hp6hotpotnet.js_ b/mod/hotpot/template/v6/hp6hotpotnet.js_
deleted file mode 100644
index 1ed71f37aa6..00000000000
--- a/mod/hotpot/template/v6/hp6hotpotnet.js_
+++ /dev/null
@@ -1,18 +0,0 @@
-
-//HOTPOTNET-RELATED CODE
-
-var HPNStartTime = (new Date()).getTime();
-var SubmissionTimeout = 30000;
-var Detail = ''; //Global that is used to submit tracking data
-
-function Finish(){
-//If there's a form, fill it out and submit it
- if (document.store != null){
- Frm = document.store;
- Frm.starttime.value = HPNStartTime;
- Frm.endtime.value = (new Date()).getTime();
- Frm.mark.value = Score;
- Frm.detail.value = Detail;
- Frm.submit();
- }
-}
diff --git a/mod/hotpot/template/v6/hp6navbar.ht_ b/mod/hotpot/template/v6/hp6navbar.ht_
deleted file mode 100644
index 359fbea4c1a..00000000000
--- a/mod/hotpot/template/v6/hp6navbar.ht_
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-[inclBack]
-
-[/inclBack]
-
-[inclContents]
-
-[/inclContents]
-
-[inclNextEx]
-
-[/inclNextEx]
-
-
diff --git a/mod/hotpot/template/v6/hp6objecttags.ht_ b/mod/hotpot/template/v6/hp6objecttags.ht_
deleted file mode 100644
index b26a448037d..00000000000
--- a/mod/hotpot/template/v6/hp6objecttags.ht_
+++ /dev/null
@@ -1,18 +0,0 @@
-
-[QuickTime Player][/QuickTime Player]
-
-[Windows Media Player]
-
-
-[strContent]
-[/Windows Media Player]
-
-[Real Player]
-
-
-
-
-
-[strContent][/Real Player]
-
-[Flash Player] [strContent][/Flash Player]
diff --git a/mod/hotpot/template/v6/hp6plainpage.ht_ b/mod/hotpot/template/v6/hp6plainpage.ht_
deleted file mode 100644
index ced728ad20f..00000000000
--- a/mod/hotpot/template/v6/hp6plainpage.ht_
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-Page Title
-
-
-
-
-
-
-[strHeaderCode]
-
-
-
-
-
-
-
-
- Page Title
- Page Subtitle
-
-
-
-
-
-
-
-
diff --git a/mod/hotpot/template/v6/hp6sendresults.js_ b/mod/hotpot/template/v6/hp6sendresults.js_
deleted file mode 100644
index b860ec8f052..00000000000
--- a/mod/hotpot/template/v6/hp6sendresults.js_
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-//CODE FOR HANDLING SENDING OF RESULTS
-
-var UserName = '';
-var StartTime = (new Date()).toLocaleString();
-
-var ResultForm = '';
-
-function GetUserName(){
- UserName = prompt('[strNamePlease]','');
- UserName += '';
- if ((UserName.substring(0,4) == 'null')||(UserName.length < 1)){
- UserName = prompt('[strNamePlease]','');
- UserName += '';
- if ((UserName.substring(0,4) == 'null')||(UserName.length < 1)){
- history.back();
- }
- }
-}
-
-function SendResults(Score){
- var today = new Date;
- var NewName = '' + today.getTime();
- var NewWin = window.open('', NewName, 'toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=no,,width=400,height=300');
-
-//If user has prevented popups, no way to proceed -- exit
- if (NewWin == null){
- return;
- }
-
- NewWin.document.clear();
- NewWin.document.open();
- NewWin.document.write(ResultForm);
- NewWin.document.close();
- NewWin.document.Results.Score.value = Score + '%';
- NewWin.document.Results.realname.value = UserName;
- NewWin.document.Results.End_Time.value = (new Date()).toLocaleString();
- NewWin.document.Results.Start_Time.value = StartTime;
- NewWin.document.Results.submit();
-}
diff --git a/mod/hotpot/template/v6/hp6showmessage.js_ b/mod/hotpot/template/v6/hp6showmessage.js_
deleted file mode 100644
index d013a29904e..00000000000
--- a/mod/hotpot/template/v6/hp6showmessage.js_
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-//CODE FOR HANDLING DISPLAY OF POPUP FEEDBACK BOX
-
-var topZ = 1000;
-
-function ShowMessage(Feedback){
- var Output = Feedback + '
';
- document.getElementById('FeedbackContent').innerHTML = Output;
- var FDiv = document.getElementById('FeedbackDiv');
- topZ++;
- FDiv.style.zIndex = topZ;
- FDiv.style.top = TopSettingWithScrollOffset(30) + 'px';
-
- FDiv.style.display = 'block';
-
- ShowElements(false, 'input');
- ShowElements(false, 'select');
- ShowElements(false, 'object');
- ShowElements(true, 'object', 'FeedbackContent');
-
-//Focus the OK button
- setTimeout("document.getElementById('FeedbackOKButton').focus()", 50);
-
-//[inclPreloadImages]
-// RefreshImages();
-//[/inclPreloadImages]
-}
-
-function ShowElements(Show, TagName, ContainerToReverse){
-// added third argument to allow objects in the feedback box to appear
-//IE bug -- hide all the form elements that will show through the popup
-//FF on Mac bug : doesn't redisplay objects whose visibility is set to visible
-//unless the object's display property is changed
-
- //get container object (by Id passed in, or use document otherwise)
- TopNode = document.getElementById(ContainerToReverse);
- var Els;
- if (TopNode != null) {
- Els = TopNode.getElementsByTagName(TagName);
- } else {
- Els = document.getElementsByTagName(TagName);
- }
-
- for (var i=0; i ReduceToSize){
- ItemToDump = Math.floor(InArray.length*Math.random());
- InArray.splice(ItemToDump, 1);
- }
-}
-
-function Shuffle(InArray){
- var Num;
- var Temp = new Array();
- var Len = InArray.length;
-
- var j = Len;
-
- for (var i=0; i InArray[Longest].length){
- Longest = i;
- }
- }
- return Longest;
-}
-
-//UNICODE CHARACTER FUNCTIONS
-function IsCombiningDiacritic(CharNum){
- var Result = (((CharNum >= 0x0300)&&(CharNum <= 0x370))||((CharNum >= 0x20d0)&&(CharNum <= 0x20ff)));
- Result = Result || (((CharNum >= 0x3099)&&(CharNum <= 0x309a))||((CharNum >= 0xfe20)&&(CharNum <= 0xfe23)));
- return Result;
-}
-
-function IsCJK(CharNum){
- return ((CharNum >= 0x3000)&&(CharNum < 0xd800));
-}
-
-//SETUP FUNCTIONS
-//BROWSER WILL REFILL TEXT BOXES FROM CACHE IF NOT PREVENTED
-function ClearTextBoxes(){
- var NList = document.getElementsByTagName('input');
- for (var i=0; i -1)||(NList[i].id.indexOf('Gap') > -1)){
- NList[i].value = '';
- }
- if (NList[i].id.indexOf('Chk') > -1){
- NList[i].checked = '';
- }
- }
-}
-
-//EXTENSION TO ARRAY OBJECT
-function Array_IndexOf(Input){
- var Result = -1;
- for (var i=0; i
-
-
-
-[strDublinCoreMetadata]
-
-
-
-
-[strPlainTitle]
-
-
-
-
-
-
-[strHeaderCode]
-
-
-
-
-
-
-
-
-
-
-
-
-[inclNavButtons]
-[strTopNavBar]
-[/inclNavButtons]
-
-
-
-
- [strExerciseTitle]
-[inclExerciseSubtitle]
- [strExerciseSubtitle]
-[/inclExerciseSubtitle]
-[inclTimer]
-
-[/inclTimer]
-
-
-
-
-
-[inclReading]
-
-
-
-
-
-[strReadingText]
-
-
-
-
-
-
-
-[/inclReading]
-
-[inclWordList]
-
-[strWordList]
-
-[/inclWordList]
-
-
-
-
-
-
-
-
-
-
-[inclKeypad]
-
-[strKeypad]
-
-[/inclKeypad]
-
-
-
-[inclHint]
-
-[/inclHint]
-
-
-
-[inclReading]
-
-[/inclReading]
-
-
-
-
-
-[inclNavButtons]
-[strBottomNavBar]
-[/inclNavButtons]
-
-
-
-
-
-
-
-
-
-
diff --git a/mod/hotpot/template/v6/jcloze6.js_ b/mod/hotpot/template/v6/jcloze6.js_
deleted file mode 100644
index 1dca255e67f..00000000000
--- a/mod/hotpot/template/v6/jcloze6.js_
+++ /dev/null
@@ -1,390 +0,0 @@
-
-[inclScorm1.2]
-//JCLOZE-SPECIFIC SCORM-RELATED JAVASCRIPT CODE
-
-function SetScormScore(){
-//Reports the current score and any other information back to the LMS
- if (API != null){
- API.LMSSetValue('cmi.core.score.raw', Score);
-//Now send detailed reports about each item
- for (var i=0; i0){ThisItemGuesses += ' | ';}
- ThisItemGuesses += State[i].Guesses[j];
- }
- API.LMSSetValue('cmi.interactions.' + i + '.type', 'fill-in');
- API.LMSSetValue('cmi.interactions.' + i + '.student_response', ThisItemGuesses);
- }
- API.LMSCommit('');
- }
-}
-[/inclScorm1.2]
-
-//JCLOZE CORE JAVASCRIPT CODE
-
-function ItemState(){
- this.ClueGiven = false;
- this.HintsAndChecks = 0;
- this.MatchedAnswerLength = 0;
- this.ItemScore = 0;
- this.AnsweredCorrectly = false;
- this.Guesses = new Array();
- return this;
-}
-
-var Feedback = '';
-var Correct = '[strCorrect]';
-var Incorrect = '[strIncorrect]';
-var GiveHint = '[strGiveHint]';
-var CaseSensitive = [boolCaseSensitive];
-var YourScoreIs = '[strYourScoreIs]';
-var Finished = false;
-var Locked = false;
-var Score = 0;
-var CurrentWord = 0;
-var Guesses = '';
-var TimeOver = false;
-
-I = new Array();
-[strItemArray]
-
-State = new Array();
-
-function StartUp(){
- RemoveBottomNavBarForIE();
-//Show a keypad if there is one (added bugfix for 6.0.4.12)
- if (document.getElementById('CharacterKeypad') != null){
- document.getElementById('CharacterKeypad').style.display = 'block';
- }
-
-[inclScorm1.2]
- ScormStartUp();
-[/inclScorm1.2]
-
-[inclSendResults]
- GetUserName();
-[/inclSendResults]
-
-[inclPreloadImages]
- PreloadImages([PreloadImageList]);
-[/inclPreloadImages]
-
- var i = 0;
-
- State.length = 0;
- for (i=0; i 0)&&(Ans != State[i].Guesses[State[i].Guesses.length-1])){
- State[i].Guesses[State[i].Guesses.length] = Ans;
- }
- }
-}
-
-function CompileGuesses(){
- var F = document.getElementById('store');
- if (F != null){
- var Temp = '';
- var GapLabel = '';
- for (var i=0; i' + GapLabel + '';
- Temp += 'student-responses' + GapLabel + '';
- Temp += 'JClozeStudentResponses';
- for (var j=0; j0){Temp += '| ';}
- Temp += State[i].Guesses[j] + ' ';
- }
- Temp += '';
- }
- Temp += '';
- Detail = Temp;
- }
-}
-
-function CheckAnswers(){
- if (Locked == true){return;}
- SaveCurrentAnswers();
- var AllCorrect = true;
-
-//Check each answer
- for (var i = 0; i -1){
- var TotalChars = GetGapValue(i).length;
- State[i].ItemScore = (TotalChars-State[i].HintsAndChecks)/TotalChars;
- if (State[i].ClueGiven == true){State[i].ItemScore /= 2;}
- if (State[i].ItemScore <0 ){State[i].ItemScore = 0;}
- State[i].AnsweredCorrectly = true;
-//Drop the correct answer into the page, replacing the text box
- SetCorrectAnswer(i, GetGapValue(i));
- }
- else{
-//Otherwise, increment the hints for this item, as a penalty
- State[i].HintsAndChecks++;
-
-//then set the flag
- AllCorrect = false;
- }
- }
- }
-
-//Calculate the total score
- var TotalScore = 0;
- for (i=0; i';
- }
-
- Output += YourScoreIs + ' ' + TotalScore + '%. ';
- if (AllCorrect == false){
- Output += ' ' + Incorrect;
- }
- ShowMessage(Output);
- setTimeout('WriteToInstructions(Output)', 50);
-
- Score = TotalScore;
- CompileGuesses();
-
- if ((AllCorrect == true)||(Finished == true)){
-
-[inclSendResults]
- setTimeout('SendResults(' + TotalScore + ')', 50);
-[/inclSendResults]
-[inclTimer]
- window.clearInterval(Interval);
-[/inclTimer]
- TimeOver = true;
- Locked = true;
- Finished = true;
- setTimeout('Finish()', SubmissionTimeout);
- }
-[inclScorm1.2]
- if (AllCorrect == true){
- SetScormComplete();
- }
- else{
- SetScormIncomplete();
- }
-[/inclScorm1.2]
-}
-
-function TrackFocus(BoxNumber){
- CurrentWord = BoxNumber;
- InTextBox = true;
-}
-
-function LeaveGap(){
- InTextBox = false;
-}
-
-function CheckBeginning(Guess, Answer){
- var OutString = '';
- var i = 0;
- var UpperGuess = '';
- var UpperAnswer = '';
-
- if (CaseSensitive == false) {
- UpperGuess = Guess.toUpperCase();
- UpperAnswer = Answer.toUpperCase();
- }
- else {
- UpperGuess = Guess;
- UpperAnswer = Answer;
- }
-
- while (UpperGuess.charAt(i) == UpperAnswer.charAt(i)) {
- OutString += Guess.charAt(i);
- i++;
- }
- OutString += Answer.charAt(i);
- return OutString;
-}
-
-function GetGapValue(GNum){
- var RetVal = '';
- if ((GNum<0)||(GNum>=I.length)){return RetVal;}
- if (document.getElementById('Gap' + GNum) != null){
- RetVal = document.getElementById('Gap' + GNum).value;
- RetVal = TrimString(RetVal);
- }
- else{
- RetVal = State[GNum].Guesses[State[GNum].Guesses.length-1];
- }
- return RetVal;
-}
-
-function SetGapValue(GNum, Val){
- if ((GNum<0)||(GNum>=I.length)){return;}
- if (document.getElementById('Gap' + GNum) != null){
- document.getElementById('Gap' + GNum).value = Val;
- document.getElementById('Gap' + GNum).focus();
- }
-}
-
-function SetCorrectAnswer(GNum, Val){
- if ((GNum<0)||(GNum>=I.length)){return;}
- if (document.getElementById('GapSpan' + GNum) != null){
- document.getElementById('GapSpan' + GNum).innerHTML = Val;
- }
-}
-
-function FindCurrent() {
- var x = 0;
- FoundCurrent = -1;
-
-//Test the current word:
-//If its state is not set to already correct, check the word.
- if (State[CurrentWord].AnsweredCorrectly == false){
- if (CheckAnswer(CurrentWord, false) < 0){
- return CurrentWord;
- }
- }
-
- x=CurrentWord + 1;
- while (x -1){return ''}
- RightBits = new Array();
- for (var i=0; i 0){
- SetGapValue(CurrGap, HintString);
- State[CurrGap].HintsAndChecks += 1;
- }
- ShowMessage(GiveHint);
-}
-
-function TypeChars(Chars){
- var CurrGap = FindCurrent();
- if (CurrGap < 0){return;}
- if (document.getElementById('Gap' + CurrGap) != null){
- SetGapValue(CurrGap, document.getElementById('Gap' + CurrGap).value + Chars);
- }
-}
-
-[inclTimer]
-function TimesUp() {
- document.getElementById('Timer').innerHTML = '[strTimesUp]';
-[inclPreloadImages]
- RefreshImages();
-[/inclPreloadImages]
- TimeOver = true;
- Finished = true;
- CheckAnswers();
- Locked = true;
-[inclScorm1.2]
- SetScormTimedOut();
-[/inclScorm1.2]
-}
-[/inclTimer]
\ No newline at end of file
diff --git a/mod/hotpot/template/v6/jcross6.ht_ b/mod/hotpot/template/v6/jcross6.ht_
deleted file mode 100644
index 27dc7d0b906..00000000000
--- a/mod/hotpot/template/v6/jcross6.ht_
+++ /dev/null
@@ -1,191 +0,0 @@
-
-
-
-
-[strDublinCoreMetadata]
-
-
-
-
-[strPlainTitle]
-
-
-
-
-
-
-[strHeaderCode]
-
-
-
-
-
-
-
-
-
-
-
-
-[inclNavButtons]
-[strTopNavBar]
-[/inclNavButtons]
-
-
-
-
- [strExerciseTitle]
-[inclExerciseSubtitle]
- [strExerciseSubtitle]
-[/inclExerciseSubtitle]
-[inclTimer]
-
-[/inclTimer]
-
-
-
-
-
-[inclReading]
-
-
-
-
-
-[strReadingText]
-
-
-
-
-
-
-
-[/inclReading]
-
-
-
-[inclKeypad]
-
-[strKeypad]
-
-[/inclKeypad]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-[strCluesAcrossLabel] |
-
-[strCluesAcross]
-
-
-
-
- |
-
-
-
-
-
-[strCluesDownLabel] |
-
-[strCluesDown]
-
-
-
-
- |
-
-
-
-
-
-
-[inclReading]
-
-[/inclReading]
-
-
-
-
-
-[inclNavButtons]
-[strBottomNavBar]
-[/inclNavButtons]
-
-
-
-
-
-
-
-
-
-
diff --git a/mod/hotpot/template/v6/jcross6.js_ b/mod/hotpot/template/v6/jcross6.js_
deleted file mode 100644
index 1a0dc9642d5..00000000000
--- a/mod/hotpot/template/v6/jcross6.js_
+++ /dev/null
@@ -1,373 +0,0 @@
-[inclScorm1.2]
-//JCROSS-SPECIFIC SCORM-RELATED JAVASCRIPT CODE
-
-function SetScormScore(){
-//Reports the current score and any other information back to the LMS
- if (API != null){
- API.LMSSetValue('cmi.core.score.raw', Score);
-
-//Now send a detailed reports on the item
- var ItemLabel = 'Crossword';
- API.LMSSetValue('cmi.objectives.0.id', 'obj'+ItemLabel);
- API.LMSSetValue('cmi.interactions.0.id', 'int'+ItemLabel);
- if (Finished == true){
- API.LMSSetValue('cmi.objectives.0.status', 'completed');
- }
- else{
- API.LMSSetValue('cmi.objectives.0.status', 'incomplete');
- }
- API.LMSSetValue('cmi.objectives.0.score.min', '0');
- API.LMSSetValue('cmi.objectives.0.score.max', '100');
- API.LMSSetValue('cmi.objectives.0.score.raw', Score);
-//We're not sending any student response data, so we can set this to a non-standard value
- API.LMSSetValue('cmi.interactions.0.type', 'crossword');
-
- API.LMSCommit('');
- }
-}
-[/inclScorm1.2]
-
-//JCROSS CORE JAVASCRIPT CODE
-
-var InGap = false;
-var CurrentBox = null;
-var Feedback = '';
-var AcrossCaption = '';
-var DownCaption = '';
-var Correct = '[strCorrect]';
-var Incorrect = '[strIncorrect]';
-var GiveHint = '[strGiveHint]';
-var YourScoreIs = '[strYourScoreIs]';
-var BuiltGrid = '';
-var BuiltExercise = '';
-var Penalties = 0;
-var Score = 0;
-var InTextBox = false;
-var Locked = false;
-var TimeOver = false;
-var CaseSensitive = [boolCaseSensitive];
-
-var InputStuff = '';
-
-var CurrBoxElement = null;
-var Finished = false;
-
-function StartUp(){
- RemoveBottomNavBarForIE();
-//Show a keypad if there is one (added bugfix for 6.0.4.12)
- if (document.getElementById('CharacterKeypad') != null){
- document.getElementById('CharacterKeypad').style.display = 'block';
- }
-[inclScorm1.2]
- ScormStartUp();
-[/inclScorm1.2]
-
- AcrossCaption = document.getElementById('CluesAcrossLabel').innerHTML;
- DownCaption = document.getElementById('CluesDownLabel').innerHTML;
-[inclSendResults]
- GetUserName();
-[/inclSendResults]
-
-[inclPreloadImages]
- PreloadImages([PreloadImageList]);
-[/inclPreloadImages]
-
-[inclTimer]
- StartTimer();
-[/inclTimer]
-
-}
-
-function GetAnswerLength(Across,x,y){
- Result = 0;
- if (Across == false){
- while ((x 0)){
- Result += L[x][y].length;
- x++;
- }
- return Result;
- }
- else{
- while ((y 0)){
- Result += L[x][y].length;
- y++;
- }
- return Result;
- }
-}
-
-function GetEditSize(Across,x,y){
- var Len = GetAnswerLength(Across,x,y);
- if (IsCJK(L[x][y].charCodeAt(0))){
- Len *= 2;
- }
- return Len;
-}
-
-function ShowClue(ClueNum,x,y){
- var Result = '';
- var Temp;
- var strParams;
- var Clue = document.getElementById('Clue_A_' + ClueNum);
- if (Clue != null){
- Temp = InputStuff.replace(/\[ClueNum\]/g, ClueNum);
- Temp = Temp.replace(/\[strClueNum\]/g, AcrossCaption + ' ' + ClueNum);
- strParams = 'true,' + ClueNum + ',' + x + ',' + y + ',\'[strBoxId]\'';
- Temp = Temp.replace(/\[strParams\]/g, strParams);
- Temp = Temp.replace(/\[strBoxId\]/g, 'GA_' + ClueNum + '_' + x + '_' + y);
- Temp = Temp.replace(/\[strEditSize\]/g, GetEditSize(true,x,y));
- Temp = Temp.replace(/\[strMaxLength\]/g, GetAnswerLength(true,x,y));
- Temp = Temp.replace(/\[strClue\]/g, Clue.innerHTML, Temp);
- Result += Temp;
- }
- Clue = document.getElementById('Clue_D_' + ClueNum);
- if (Clue != null){
- Temp = InputStuff.replace(/\[ClueNum\]/g, ClueNum);
- Temp = Temp.replace(/\[strClueNum\]/g, DownCaption + ' ' + ClueNum);
- strParams = 'false,' + ClueNum + ',' + x + ',' + y + ',\'[strBoxId]\'';
- Temp = Temp.replace(/\[strParams\]/g, strParams);
- Temp = Temp.replace(/\[strBoxId\]/g, 'GD_' + ClueNum + '_' + x + '_' + y);
- Temp = Temp.replace(/\[strEditSize\]/g, GetAnswerLength(false,x,y));
- Temp = Temp.replace(/\[strClue\]/g, Clue.innerHTML, Temp);
- Result += Temp;
- }
- document.getElementById('ClueEntry').innerHTML = Result;
-}
-
-function EnterGuess(Across,ClueNum,x,y,BoxId){
- if (document.getElementById(BoxId) != null){
- var Guess = document.getElementById(BoxId).value;
- var AnsLength = GetAnswerLength(Across,x,y);
- EnterAnswer(Guess,Across,AnsLength,x,y);
- }
-}
-
-function SplitStringToPerceivedChars(InString, PC){
- var Temp = InString.charAt(0);
- if (InString.length > 1){
- for (var i=1; i';
- }
-
- Output += YourScoreIs + ' ' + Score + '%. ';
- if (AllCorrect == false){
- Output += Incorrect;
- Penalties++;
- }
-
- ShowMessage(Output);
- WriteToInstructions(Output);
-
- if ((AllCorrect == true)||(TimeOver == true)){
-[inclSendResults]
- setTimeout('SendResults(' + Score + ')', 50);
-[/inclSendResults]
-[inclTimer]
- window.clearInterval(Interval);
-[/inclTimer]
- TimeOver = true;
- Locked = true;
- Finished = true;
- setTimeout('Finish()', SubmissionTimeout);
- }
-[inclScorm1.2]
- if (AllCorrect == true){
- SetScormComplete();
- }
- else{
- SetScormIncomplete();
- }
-[/inclScorm1.2]
-}
-
-function Finish(){
-//If there's a form, fill it out and submit it
- if (document.store != null){
- Frm = document.store;
- Frm.starttime.value = HPNStartTime;
- Frm.endtime.value = (new Date()).getTime();
- Frm.mark.value = Score;
- Frm.submit();
- }
-}
-
-function TypeChars(Chars){
- if (CurrentBox != null){
- CurrentBox.value += Chars;
- }
-}
-
-[inclTimer]
-function TimesUp() {
- document.getElementById('Timer').innerHTML = '[strTimesUp]';
-[inclPreloadImages]
- RefreshImages();
-[/inclPreloadImages]
- TimeOver = true;
- Finished = true;
- CheckAnswers();
- Locked = true;
-[inclScorm1.2]
- SetScormTimedOut();
-[/inclScorm1.2]
-}
-[/inclTimer]
\ No newline at end of file
diff --git a/mod/hotpot/template/v6/jcross6print.ht_ b/mod/hotpot/template/v6/jcross6print.ht_
deleted file mode 100644
index 37d100e747f..00000000000
--- a/mod/hotpot/template/v6/jcross6print.ht_
+++ /dev/null
@@ -1,182 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [strExerciseTitle]
-[inclExerciseSubtitle]
- [strExerciseSubtitle]
-[/inclExerciseSubtitle]
-
-
-
-
-[StartBlankCell]
-| |
-[EndBlankCell]
-
-[StartLetterOnlyCell]
- [Letter] |
-[EndLetterOnlyCell]
-
-[StartNumLetterCell]
-[ClueNum] [Letter] |
-[EndNumLetterCell]
-
-
-
-
-
-
-
-[strCluesAcrossLabel] |
-
-[StartCluesAcrossLoop]
-| [ClueNum] |
-[Clue] |
-[EndCluesAcrossLoop]
-
-
-
- |
-
-
-
-
-[strCluesDownLabel] |
-
-[StartCluesDownLoop]
-| [ClueNum] |
-[Clue] |
-[EndCluesDownLoop]
-
-
- |
-
-
-
diff --git a/mod/hotpot/template/v6/jmatch6.ht_ b/mod/hotpot/template/v6/jmatch6.ht_
deleted file mode 100644
index eb301f45871..00000000000
--- a/mod/hotpot/template/v6/jmatch6.ht_
+++ /dev/null
@@ -1,148 +0,0 @@
-
-
-
-
-[strDublinCoreMetadata]
-
-
-
-
-[strPlainTitle]
-
-
-
-
-
-
-[strHeaderCode]
-
-
-
-
-
-
-
-
-
-
-
-
-[inclNavButtons]
-[strTopNavBar]
-[/inclNavButtons]
-
-
-
-
- [strExerciseTitle]
-[inclExerciseSubtitle]
- [strExerciseSubtitle]
-[/inclExerciseSubtitle]
-[inclTimer]
-
-[/inclTimer]
-
-
-
-
-
-[inclReading]
-
-
-
-
-
-[strReadingText]
-
-
-
-
-
-
-
-[/inclReading]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-[inclReading]
-
-[/inclReading]
-
-
-
-
-
-[inclNavButtons]
-[strBottomNavBar]
-[/inclNavButtons]
-
-
-
-
-
-
-
-
-
-
diff --git a/mod/hotpot/template/v6/jmatch6.js_ b/mod/hotpot/template/v6/jmatch6.js_
deleted file mode 100644
index f9e335cd8e5..00000000000
--- a/mod/hotpot/template/v6/jmatch6.js_
+++ /dev/null
@@ -1,310 +0,0 @@
-
-[inclScorm1.2]
-//JMATCH-SPECIFIC SCORM-RELATED JAVASCRIPT CODE
-
-function SetScormScore(){
-//Reports the current score and any other information back to the LMS
- if (API != null){
- API.LMSSetValue('cmi.core.score.raw', Score);
-
-//Now send a detailed reports on the item
- var ItemLabel = 'Matching';
- API.LMSSetValue('cmi.objectives.0.id', 'obj'+ItemLabel);
- API.LMSSetValue('cmi.interactions.0.id', 'int'+ItemLabel);
- API.LMSSetValue('cmi.objectives.0.status', API.LMSGetValue('cmi.core.lesson_status'));
- API.LMSSetValue('cmi.objectives.0.score.min', '0');
- API.LMSSetValue('cmi.objectives.0.score.max', '100');
- API.LMSSetValue('cmi.objectives.0.score.raw', Score);
-//We can only use the performance type, because we're storing multiple responses of various types.
- API.LMSSetValue('cmi.interactions.0.type', 'performance');
-
- var AnswersTried = '';
- for (var i=0; i0){AnswersTried += ' | ';}
- for (var j=0; j0){AnswersTried += ',';}
- AnswersTried += j + '.' + Status[j][3][i];
- }
- }
- API.LMSSetValue('cmi.interactions.0.student_response', AnswersTried);
- API.LMSCommit('');
- }
-}
-[/inclScorm1.2]
-
-//JMATCH CORE JAVASCRIPT CODE
-
-var CorrectIndicator = '[strCorrectIndicator]';
-var IncorrectIndicator = '[strIncorrectIndicator]';
-var YourScoreIs = '[strYourScoreIs]';
-var CorrectResponse = '[strGuessCorrect]';
-var IncorrectResponse = '[strGuessIncorrect]';
-var TotalUnfixedLeftItems = 0;
-var TotCorrectChoices = 0;
-var Penalties = 0;
-var Finished = false;
-var TimeOver = false;
-
-var Score = 0;
-var Locked = false;
-var ShuffleQs = [boolShuffleQs];
-var QsToShow = [QsToShow];
-
-
-function StartUp(){
- RemoveBottomNavBarForIE();
-
-[inclScorm1.2]
- ScormStartUp();
-[/inclScorm1.2]
-
-[inclSendResults]
- GetUserName();
-[/inclSendResults]
-
-[inclPreloadImages]
- PreloadImages([PreloadImageList]);
-[/inclPreloadImages]
-
- SetUpItems(ShuffleQs,QsToShow);
-
- TotalUnfixedLeftItems = document.getElementById('MatchDiv').getElementsByTagName('select').length;
-
-//Create arrays
- CreateStatusArrays();
-
-[inclTimer]
- StartTimer();
-[/inclTimer]
-}
-
-Status = new Array();
-
-
-function CreateStatusArrays(){
- var Selects = document.getElementById('Questions').getElementsByTagName('select');
- for (var x=0; x 0){
- var Select = Container.getElementsByTagName('select')[0];
- if (Select != null){
- Result = parseInt(Select.id.substring(1, Select.id.length));
- }
- }
- return Result;
-}
-
-function GetKeyFromSelect(Select){
- var Result = -1;
- if (Select != null){
- Result = parseInt(Select.id.substring(1, Select.id.length));
- }
- return Result;
-}
-
-var OriginalKeys = new Array();
-var ReducedKeys = new Array();
-
-function GetUniqueKeys(Container, TargetArray){
- TargetArray.length = 0;
- var x = -1;
- var SList = Container.getElementsByTagName('select');
- if (SList.length > 0){
- for (var i=0; i 0){
- QList.push(Qs.removeChild(Qs.getElementsByTagName('tr')[0]));
- }
-
- var Reducing = (QList.length > ReduceTo);
-
-//If required, select random rows to delete
- if (Reducing == true){
- var DumpItem = 0;
- while (ReduceTo < QList.length){
-
-//Get a number to delete from the array
- DumpItem = Math.floor(QList.length*Math.random());
- for (i=DumpItem; i<(QList.length-1); i++){
- QList[i] = QList[i+1];
- }
- QList.length = QList.length-1;
- }
- }
-//Shuffle the rows if necessary
- if (ShuffleQs == true){
- QList = Shuffle(QList);
- }
-
- TotalUnfixedLeftItems = QList.length;
-
-//Write the rows back to the table body
- for (i=0; i=0; j--){
- if (OptionRequired(Options[j].value) == false){
- Selects[i].removeChild(Options[j]);
- }
- }
- }
- }
-}
-
-function OptionRequired(Key){
- if (ReducedKeys.indexOf(Key) > -1){
- return true;
- }
- else{
- if (OriginalKeys.indexOf(Key) > -1){
- return false;
- }
- else{
- return true;
- }
- }
-}
-
-function CheckAnswers(){
- if (Locked == true){return;}
- var Select = null;
- var Key = -1;
- var Parent = null;
- var Answer = null;
- var AnsText = '';
- var AllDone = true;
- TotCorrectChoices = 0;
-
-//for each item not fixed or a distractor
- for (var i=0; i' + YourScoreIs + Score + '%.';
- }
- else{
- Feedback = IncorrectResponse + ' ' + YourScoreIs + Score + '%.';
-//Penalty for incorrect check
- Penalties++;
- }
-
-//If the exercise is over, deal with that
- if ((AllDone == true)||(TimeOver == true)){
-[inclSendResults]
- setTimeout('SendResults(' + Score + ')', 50);
-[/inclSendResults]
-[inclTimer]
- window.clearInterval(Interval);
-[/inclTimer]
- TimeOver = true;
- Locked = true;
- Finished = true;
- setTimeout('Finish()', SubmissionTimeout);
- WriteToInstructions(Feedback);
- }
-
-//Show the feedback
- ShowMessage(Feedback);
-
-[inclScorm1.2]
- if (AllDone == true){
- SetScormComplete();
- }
- else{
- SetScormIncomplete();
- }
-[/inclScorm1.2]
-}
-
-[inclTimer]
-function TimesUp() {
- document.getElementById('Timer').innerHTML = '[strTimesUp]';
-[inclPreloadImages]
- RefreshImages();
-[/inclPreloadImages]
- TimeOver = true;
- Finished = true;
- CheckAnswers();
- Locked = true;
-[inclScorm1.2]
- SetScormTimedOut();
-[/inclScorm1.2]
-}
-[/inclTimer]
-
diff --git a/mod/hotpot/template/v6/jmix6.ht_ b/mod/hotpot/template/v6/jmix6.ht_
deleted file mode 100644
index 7f9e2997e57..00000000000
--- a/mod/hotpot/template/v6/jmix6.ht_
+++ /dev/null
@@ -1,155 +0,0 @@
-
-
-
-
-[strDublinCoreMetadata]
-
-
-
-
-[strPlainTitle]
-
-
-
-
-
-
-[strHeaderCode]
-
-
-
-
-
-
-
-
-
-
-
-
-[inclNavButtons]
-[strTopNavBar]
-[/inclNavButtons]
-
-
-
-
- [strExerciseTitle]
-[inclExerciseSubtitle]
- [strExerciseSubtitle]
-[/inclExerciseSubtitle]
-[inclTimer]
-
-[/inclTimer]
-
-
-
-
-
-[inclReading]
-
-
-
-
-
-[strReadingText]
-
-
-
-
-
-
-
-[/inclReading]
-
-
-
-
-
-
-
-
-
-[inclUndo]
-
-[/inclUndo]
-
-[inclRestart]
-
-[/inclRestart]
-
-[inclHint]
-
-[/inclHint]
-
-
-
-
-
-
-
-[inclReading]
-
-[/inclReading]
-
-
-
-
-
-[inclNavButtons]
-[strBottomNavBar]
-[/inclNavButtons]
-
-
-
-
-
-
-
-
-
-
diff --git a/mod/hotpot/template/v6/jmix6.js_ b/mod/hotpot/template/v6/jmix6.js_
deleted file mode 100644
index 83b2cd8001c..00000000000
--- a/mod/hotpot/template/v6/jmix6.js_
+++ /dev/null
@@ -1,409 +0,0 @@
-[inclScorm1.2]
-//JMIX-SPECIFIC SCORM-RELATED JAVASCRIPT CODE
-
-function SetScormScore(){
-//Reports the current score and any other information back to the LMS
- if (API != null){
- API.LMSSetValue('cmi.core.score.raw', Score);
-
-//Now send a detailed reports on the item
- var ItemLabel = 'Item_1';
- API.LMSSetValue('cmi.objectives.0.id', 'obj'+ItemLabel);
- API.LMSSetValue('cmi.interactions.0.id', 'int'+ItemLabel);
- if (Finished == true){
- API.LMSSetValue('cmi.objectives.0.status', 'completed');
- }
- else{
- API.LMSSetValue('cmi.objectives.0.status', 'incomplete');
- }
-
- API.LMSSetValue('cmi.objectives.0.score.min', '0');
- API.LMSSetValue('cmi.objectives.0.score.max', '100');
- API.LMSSetValue('cmi.objectives.0.score.raw', Score);
-//We can only use the performance type, because we're storing multiple responses of various types.
- API.LMSSetValue('cmi.interactions.0.type', 'performance');
- API.LMSSetValue('cmi.interactions.0.student_response', AnswersTried);
-
- API.LMSCommit('');
- }
-}
-[/inclScorm1.2]
-
-//JMIX STANDARD OUTPUT FORMAT CODE
-
-var CorrectResponse = '[strGuessCorrect]';
-var IncorrectResponse = '[strGuessIncorrect]';
-var TheseAnswersToo = '[strTheseAnswersToo]';
-var ThisMuchCorrect = '[strThisMuch]';
-var NextCorrect = '[strNextCorrect]';
-var YourScoreIs = '[strYourScoreIs]';
-var CapitalizeFirst = [boolCapitalizeFirst];
-var Penalties = 0;
-var Finished = false;
-var TimeOver = false;
-var Score = 0;
-var strInstructions = '';
-var AnswersTried = '';
-
-
-var SegmentTemplate = ' [CurrentSegment] ';
-
-var Exercise = '';
-
-var Punctuation = '[strPunctuation]';
-
-var Openers = '[strOpenPunctuation]';
-
-var Guesses = new Array();
-var Remaining = new Array();
-var CorrectParts = new Array();
-
-var ClosestMatch = 0;
-
-var LowerString='';
-var UpperString='';
-
-var Output = '';
-
-var Segments = new Array();
-[SegmentArray]
-
-var GuessSequence = new Array();
-
-var Answers = new Array();
-[AnswerArray]
-
-function WriteToGuess(Feedback) {
- document.getElementById('GuessDiv').innerHTML = Feedback;
-[inclPreloadImages]
- RefreshImages();
-[/inclPreloadImages]
-}
-
-function Undo(){
- if (GuessSequence.length < 1){
- return;
- }
- GuessSequence.length = GuessSequence.length - 1;
- BuildCurrGuess();
- BuildExercise();
- DisplayExercise(Exercise);
-//Following line modified for 6.0.4.44 -- "remaining words" message removed, no longer needed
- WriteToGuess('' + Output + '');
-}
-
-function AddSegment(SegNum){
-[inclTimer]
- if (TimeOver == true){return;}
-[/inclTimer]
- GuessSequence[GuessSequence.length] = SegNum;
- BuildCurrGuess();
- WriteToGuess('' + Output + '');
- BuildExercise();
- DisplayExercise(Exercise);
-}
-
-function BuildCurrGuess(){
-
- var i = 0;
- var j = 0;
- var NewSeg = '';
-
-//first, create arrays of all the segments guessed so far and those not yet used
- GuessSegs = new Array();
- GuessSegs.length = 0;
-
-//set the "used" markers all to 0
- for (i=0; i 0){
- OutString = OutArray[0];
- }
- else{
- OutString = '';
- }
- var Spacer = '';
-
- for (i=1; i -1)||(Punctuation.indexOf(OutArray[i].charAt(0)) > -1)){
- Spacer = '';
- }
- OutString = OutString + Spacer + OutArray[i];
- }
-
-//Capitalize the first letter if necessary
- if (CapitalizeFirst == true){
- i = 0;
- if ((Openers.indexOf(OutString.charAt(i))>-1)||(OutString.charAt(i) == ' ')){
- i++;
- }
- if ((Openers.indexOf(OutString.charAt(i))>-1)||(OutString.charAt(i) == ' ')){
- i++;
- }
- var Temp = OutString.charAt(i);
- Temp = Temp.toUpperCase();
- OutString = OutString.substring(0, i) + Temp + OutString.substring(i+1, OutString.length);
- }
- return OutString;
-}
-function CheckAnswer(CheckType){
-
- if (GuessSequence.length < 1){
- if (CheckType == 1){
- ShowMessage(NextCorrect + ' ' + FindSegment(Answers[0][0]) + '');
- Penalties++;
- }
- return;
- }
-
- var i = 0;
- var j = 0;
- var k = 0;
- var WellDone = '';
- var WhichCorrect = -1;
- var TryAgain = '';
- var LongestCorrectBit = '';
- TempCorrect = new Array();
- LongestCorrect = new Array();
- var TempHint = '';
- var HintToReturn = 1;
- var OtherAnswers = '';
- var AllDone = false;
-
- for (i=0; i LongestCorrect.length){
- LongestCorrect.length = 0;
- for (k=0; k -1){
- AllDone = true;
- for (i=0; i' + CompileString(Answers[i]);
- }
- }
-
- WellDone = '' + Output + '
' + CorrectResponse + ' ';
-
- if (AnswersTried.length > 0){AnswersTried += ' | ';}
- AnswersTried += Output;
-
-//Do score calculation here
- Score = Math.floor(((Segments.length-Penalties) * 100)/Segments.length);
- WellDone += YourScoreIs + ' ' + Score + '%. ';
-
-[inclAlsoCorrect]
- if (OtherAnswers.length > 0){
- WellDone += TheseAnswersToo + '' + OtherAnswers + '';
- }
-[/inclAlsoCorrect]
-
- WriteToGuess(WellDone);
- ShowMessage(WellDone);
- }
-
- else{
- var WrongGuess = CompileString(GuessSequence);
- if (AnswersTried.length > 0){AnswersTried += ' | ';}
- AnswersTried += WrongGuess;
- TryAgain = '' + WrongGuess + '
';
- if (CheckType == 0){
- TryAgain += IncorrectResponse + ' ';
- }
-
- if (LongestCorrect.length > 0){
-
- LongestCorrectBit = CompileString(LongestCorrect);
- GuessSequence.length = LongestCorrect.length;
- TryAgain += ThisMuchCorrect + ' ' + LongestCorrectBit + ' ';
-
-//These lines added for 6.0.3.44
- WriteToGuess('' + LongestCorrectBit + '');
- }
- else{
- GuessSequence.length = 0;
- WriteToGuess('');
- }
-
- if (CheckType == 1){
- TryAgain += NextCorrect + ' ' + FindSegment(HintToReturn) + '';
- }
-
- BuildCurrGuess();
- BuildExercise();
- DisplayExercise(Exercise);
- ShowMessage(TryAgain);
- Penalties++; //Penalty for inaccurate check
-
-[inclTimer]
- if (TimeOver == true){
- Score = Math.floor(((LongestCorrect.length-Penalties) * 100)/Segments.length);
- if (Score < 0){Score = 0;}
- ShowMessage(YourScoreIs + ' ' + Score + '%. ');
- }
-[/inclTimer]
-
- }
-//If the exercise is over, deal with that
- if ((AllDone == true)||(TimeOver == true)){
-[inclSendResults]
- setTimeout('SendResults(' + Score + ')', 50);
-[/inclSendResults]
-[inclTimer]
- window.clearInterval(Interval);
-[/inclTimer]
- TimeOver = true;
- Locked = true;
- Finished = true;
- setTimeout('Finish()', SubmissionTimeout);
- WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
- }
-[inclScorm1.2]
- if (AllDone == true){
- SetScormComplete();
- }
- else{
- SetScormIncomplete();
- }
-[/inclScorm1.2]
-}
-
-function FindSegment(SegID){
- var Seg = '';
- for (var i=0; i
-
-
-
-[strDublinCoreMetadata]
-
-
-
-
-[strPlainTitle]
-
-
-
-
-
-
-[strHeaderCode]
-
-
-
-
-
-
-
-
-
-
-
-
-[inclNavButtons]
-[strTopNavBar]
-[/inclNavButtons]
-
-
-
-
- [strExerciseTitle]
-[inclExerciseSubtitle]
- [strExerciseSubtitle]
-[/inclExerciseSubtitle]
-[inclTimer]
-
-[/inclTimer]
-
-
-
-
-
-[inclReading]
-
-
-
-
-
-[strReadingText]
-
-
-
-
-
-
-
-[/inclReading]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-[strQuestionOutput]
-
-[inclKeypad]
-
-[strKeypad]
-
-[/inclKeypad]
-
-
-
-[inclReading]
-
-[/inclReading]
-
-
-
-
-
-[inclNavButtons]
-[strBottomNavBar]
-[/inclNavButtons]
-
-
-
-
-
-
-
-
-
-
diff --git a/mod/hotpot/template/v6/jquiz6.js_ b/mod/hotpot/template/v6/jquiz6.js_
deleted file mode 100644
index 9b1d0ecdb6e..00000000000
--- a/mod/hotpot/template/v6/jquiz6.js_
+++ /dev/null
@@ -1,668 +0,0 @@
-
-[inclScorm1.2]
-//JQUIZ-SPECIFIC SCORM-RELATED JAVASCRIPT CODE
-
-function SetScormScore(){
-//Reports the current score and any other information back to the LMS
- if (API != null){
- API.LMSSetValue('cmi.core.score.raw', Score);
-//Now send detailed reports about each item
- for (var i=0; i 0){
- ThisItemScore = Math.floor(State[i][0] * 100) + '';
- ThisItemStatus = 'completed';
- }
- else{
- ThisItemScore = '0';
- ThisItemStatus = 'incomplete';
- }
- API.LMSSetValue('cmi.objectives.' + i + '.score.raw', ThisItemScore);
- API.LMSSetValue('cmi.objectives.' + i + '.status', ThisItemStatus);
- API.LMSSetValue('cmi.interactions.' + i + '.weighting', I[i][0]);
-//We can only use the performance type, because we're storing multiple responses of various types.
- API.LMSSetValue('cmi.interactions.' + i + '.type', 'performance');
- API.LMSSetValue('cmi.interactions.' + i + '.student_response', State[i][5]);
- }
- }
-
- API.LMSCommit('');
- }
-}
-[/inclScorm1.2]
-
-//JQUIZ CORE JAVASCRIPT CODE
-
-var CurrQNum = 0;
-var CorrectIndicator = '[strCorrectIndicator]';
-var IncorrectIndicator = '[strIncorrectIndicator]';
-var YourScoreIs = '[strYourScoreIs]';
-var ContinuousScoring = [boolContinuousScoring];
-var CorrectFirstTime = '[strCorrectFirstTime]';
-var ShowCorrectFirstTime = [boolShowCorrectFirstTime];
-var ShuffleQs = [boolShuffleQs];
-var ShuffleAs = [boolShuffleAs];
-var DefaultRight = '[strDefaultRight]';
-var DefaultWrong = '[strDefaultWrong]';
-var QsToShow = [QsToShow];
-var Score = 0;
-var Finished = false;
-var Qs = null;
-var QArray = new Array();
-var ShowingAllQuestions = false;
-var ShowAllQuestionsCaption = '[strShowAllQuestionsCaptionJS]';
-var ShowOneByOneCaption = '[strShowOneByOneCaptionJS]';
-var State = new Array();
-var Feedback = '';
-var TimeOver = false;
-var strInstructions = '';
-var Locked = false;
-
-//The following variable can be used to add a message explaining that
-//the question is finished, so no further marking will take place.
-var strQuestionFinished = '';
-
-function CompleteEmptyFeedback(){
- var QNum, ANum;
- for (QNum=0; QNum 0){
- I[QNum][3][ANum][1] = DefaultRight;
- }
- else{
- I[QNum][3][ANum][1] = DefaultWrong;
- }
- }
- }
- }
- }
-}
-
-function SetUpQuestions(){
- var AList = new Array();
- var QList = new Array();
- var i, j;
- Qs = document.getElementById('Questions');
- while (Qs.getElementsByTagName('li').length > 0){
- QList.push(Qs.removeChild(Qs.getElementsByTagName('li')[0]));
- }
- var DumpItem = 0;
- if (QsToShow > QList.length){
- QsToShow = QList.length;
- }
- while (QsToShow < QList.length){
- DumpItem = Math.floor(QList.length*Math.random());
- for (j=DumpItem; j<(QList.length-1); j++){
- QList[j] = QList[j+1];
- }
- QList.length = QList.length-1;
- }
- if (ShuffleQs == true){
- QList = Shuffle(QList);
- }
- if (ShuffleAs == true){
- var As;
- for (var i=0; i 0){
- AList.push(As.removeChild(As.getElementsByTagName('li')[0]));
- }
- AList = Shuffle(AList);
- for (j=0; j= QArray.length)){return;}
- QArray[CurrQNum].style.display = 'none';
- CurrQNum += ChangeBy;
- QArray[CurrQNum].style.display = '';
-//Undocumented function added 10/12/2004
- ShowSpecialReadingForQuestion();
- SetQNumReadout();
- SetFocusToTextbox();
-}
-
-var HiddenReadingShown = false;
-function ShowSpecialReadingForQuestion(){
-//Undocumented function for showing specific reading text elements which change with each question
-//Added on 10/12/2004
- if (document.getElementById('ReadingDiv') != null){
- if (HiddenReadingShown == true){
- document.getElementById('ReadingDiv').innerHTML = '';
- }
- if (QArray[CurrQNum] != null){
-//Fix for 6.0.4.25
- var Children = QArray[CurrQNum].getElementsByTagName('div');
- for (var i=0; i= QArray.length){
- if (document.getElementById('NextQButton') != null){
- document.getElementById('NextQButton').style.visibility = 'hidden';
- }
- }
- else{
- if (document.getElementById('NextQButton') != null){
- document.getElementById('NextQButton').style.visibility = 'visible';
- }
- }
- if (CurrQNum <= 0){
- if (document.getElementById('PrevQButton') != null){
- document.getElementById('PrevQButton').style.visibility = 'hidden';
- }
- }
- else{
- if (document.getElementById('PrevQButton') != null){
- document.getElementById('PrevQButton').style.visibility = 'visible';
- }
- }
-}
-
-[strItemArray]
-
-function StartUp(){
- RemoveBottomNavBarForIE();
-
-//If there's only one question, no need for question navigation controls
- if (QsToShow < 2){
- document.getElementById('QNav').style.display = 'none';
- }
-
-//Stash the instructions so they can be redisplayed
- strInstructions = document.getElementById('InstructionsDiv').innerHTML;
-
-[inclScorm1.2]
- ScormStartUp();
-[/inclScorm1.2]
-
-[inclSendResults]
- GetUserName();
-[/inclSendResults]
-
-[inclPreloadImages]
- PreloadImages([PreloadImageList]);
-[/inclPreloadImages]
-
- CompleteEmptyFeedback();
-
- SetUpQuestions();
- ClearTextBoxes();
- CreateStatusArray();
-
-[inclTimer]
- setTimeout('StartTimer()', 50);
-[/inclTimer]
-
-//Check search string for q parameter
- if (document.location.search.length > 0){
- if (ShuffleQs == false){
- var JumpTo = parseInt(document.location.search.substring(1,document.location.search.length))-1;
- if (JumpTo <= QsToShow){
- ChangeQ(JumpTo);
- }
- }
- }
-//Undocumented function added 10/12/2004
- ShowSpecialReadingForQuestion();
-}
-
-function ShowHideQuestions(){
- FuncBtnOut(document.getElementById('ShowMethodButton'));
- document.getElementById('ShowMethodButton').style.display = 'none';
- if (ShowingAllQuestions == false){
- for (var i=0; i -1){
-//Add an extra message explaining that the question
-// is finished if defined by the user
- if (strQuestionFinished.length > 0){Feedback += ' ' + strQuestionFinished;}
-//Show the feedback
- ShowMessage(Feedback);
- return;
- }
-
-//Hide the button while processing
- Btn.style.display = 'none';
-
-//Increment the number of tries
- State[QNum][2]++;
-
-//Add the percent-correct value of this answer
- State[QNum][3] += I[QNum][3][ANum][3];
-
-//Store the try number in the answer part of the State array, for tracking purposes
- State[QNum][1][ANum] = State[QNum][2];
- if (State[QNum][5].length > 0){State[QNum][5] += ' | ';}
- State[QNum][5] += String.fromCharCode(65+ANum);
-
-//Should this answer be accepted as correct?
- if (I[QNum][3][ANum][2] < 1){
-//It's wrong
-
-//Mark the answer
- Btn.innerHTML = IncorrectIndicator;
-
-//Remove any previous score unless exercise is finished (6.0.3.8+)
- if (Finished == false){
- WriteToInstructions(strInstructions);
- }
-
-//Check whether this leaves just one MC answer unselected, in which case the Q is terminated
- var RemainingAnswer = FinalAnswer(QNum);
- if (RemainingAnswer > -1){
-//Behave as if the last answer had been selected, but give no credit for it
-//Increment the number of tries
- State[QNum][2]++;
-
-//Calculate the score for this question
- CalculateMCQuestionScore(QNum);
-
-//Get the overall score and add it to the feedback
- CalculateOverallScore();
- if ((ContinuousScoring == true)||(Finished == true)){
- Feedback += ' ' + YourScoreIs + ' ' + Score + '%.';
- WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
- }
- }
- }
- else{
-//It's right
-//Mark the answer
- Btn.innerHTML = CorrectIndicator;
-
-//Calculate the score for this question
- CalculateMCQuestionScore(QNum);
-
-//Get the overall score and add it to the feedback
- if (ContinuousScoring == true){
- CalculateOverallScore();
- if ((ContinuousScoring == true)||(Finished == true)){
- Feedback += ' ' + YourScoreIs + ' ' + Score + '%.';
- WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
- }
- }
- }
-
-//Show the button again
- Btn.style.display = 'inline';
-
-//Finally, show the feedback
- ShowMessage(Feedback);
-
-//Check whether all questions are now done
- CheckFinished();
-}
-
-function CalculateMCQuestionScore(QNum){
- var Tries = State[QNum][2] + State[QNum][4]; //include tries and hint penalties
- var PercentCorrect = State[QNum][3];
- var TotAns = GetTotalMCAnswers(QNum);
- var HintPenalties = State[QNum][4];
-
-//Make sure it's not already complete
-
- if (State[QNum][0] < 0){
-//Allow for Hybrids
- if (HintPenalties >= 1){
- State[QNum][0] = 0;
- }
- else{
-//This line calculates the score for this question
- if (TotAns == 1){
- State[QNum][0] = 1;
- }
- else{
- State[QNum][0] = ((TotAns-((Tries*100)/State[QNum][3]))/(TotAns-1));
- }
- }
-//Fix for Safari bug added for version 6.0.3.42 (negative infinity problem)
- if ((State[QNum][0] < 0)||(State[QNum][0] == Number.NEGATIVE_INFINITY)){
- State[QNum][0] = 0;
- }
- }
-}
-
-function GetTotalMCAnswers(QNum){
- var Result = 0;
- for (var ANum=0; ANum 0){State[QNum][5] += ' | ';}
-
-//Check if there are any mismatches
- Feedback = '';
- var CheckBox = null;
- for (var ANum=0; ANum' + Feedback;
- if (Matches == I[QNum][3].length){
-//It's right
- CalculateMultiSelQuestionScore(QNum);
- if (ContinuousScoring == true){
- CalculateOverallScore();
- if ((ContinuousScoring == true)||(Finished == true)){
- Feedback += ' ' + YourScoreIs + ' ' + Score + '%.';
- WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
- }
- }
- }
- else{
-//It's wrong -- Remove any previous score unless exercise is finished (6.0.3.8+)
- if (Finished == false){
- WriteToInstructions(strInstructions);
- }
- }
-
-//Show the feedback
- ShowMessage(Feedback);
-
-//Check whether all questions are now done
- CheckFinished();
-}
-
-function CalculateMultiSelQuestionScore(QNum){
- var Tries = State[QNum][2];
- var TotAns = State[QNum][1].length;
-
-//Make sure it's not already complete
- if (State[QNum][0] < 0){
- State[QNum][0] = (TotAns - (Tries-1)) / TotAns;
- if (State[QNum][0] < 0){
- State[QNum][0] = 0;
- }
- }
-}
-
-[/inclMultiSelect]
-
-function CalculateOverallScore(){
- var TotalWeighting = 0;
- var TotalScore = 0;
-
- for (var QNum=0; QNum -1){
- TotalWeighting += I[QNum][0];
- TotalScore += (I[QNum][0] * State[QNum][0]);
- }
- }
- }
- if (TotalWeighting > 0){
- Score = Math.floor((TotalScore/TotalWeighting)*100);
- }
- else{
-//if TotalWeighting is 0, no questions so far have any value, so
-//no penalty should be shown.
- Score = 100;
- }
-}
-
-function CheckFinished(){
- var FB = '';
- var AllDone = true;
- for (var QNum=0; QNum= 1){
- CFT++;
- }
- }
- }
- FB += ' ' + CorrectFirstTime + ' ' + CFT + '/' + QsToShow;
- }
- WriteToInstructions(FB);
-
- Finished == true;
-[inclTimer]
- window.clearInterval(Interval);
-[/inclTimer]
-
-[inclScorm1.2]
- if (TimeOver == true){
- SetScormTimedOut();
- }
- else{
- SetScormComplete();
- }
-[/inclScorm1.2]
-
- TimeOver = true;
- Locked = true;
-
-[inclSendResults]
- setTimeout('SendResults(' + Score + ')', 50);
-[/inclSendResults]
-
- Finished = true;
- Detail = '';
- for (QNum=0; QNum 0){
- Detail += 'Question #' + (QNum+1) + 'question-trackingQ ' + (QNum+1) + 'QuestionTrackingField' + State[QNum][5] + '';
- }
- }
- }
- Detail += '';
- setTimeout('Finish()', SubmissionTimeout);
- }
-[inclScorm1.2]
- else{
- SetScormIncomplete();
- }
-[/inclScorm1.2]
-}
-
-[inclTimer]
-function TimesUp(){
- document.getElementById('Timer').innerHTML = '[strTimesUp]';
-[inclPreloadImages]
- RefreshImages();
-[/inclPreloadImages]
- TimeOver = true;
- Finished = true;
- ShowMessage('[strTimesUp]');
-
-//Set all remaining scores to 0
- for (var QNum=0; QNum
-
-
-
-
-
-
-[strPlainIndexTitle]
-
-
-
-
-
-
-[strHeaderCode]
-
-
-
-
-
-
- [strIndexTitle]
-
-
-
-
-
\ No newline at end of file
diff --git a/mod/hotpot/template/v6/mashernav.ht_ b/mod/hotpot/template/v6/mashernav.ht_
deleted file mode 100644
index d439ca4fa47..00000000000
--- a/mod/hotpot/template/v6/mashernav.ht_
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-[strTopNavBar]
-
-
-
-
\ No newline at end of file
diff --git a/mod/hotpot/template/v6/testbrowsercheck.htm b/mod/hotpot/template/v6/testbrowsercheck.htm
deleted file mode 100644
index 95b71ae6edb..00000000000
--- a/mod/hotpot/template/v6/testbrowsercheck.htm
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-Testing browser check code
-
-
-
-
-
-
-
-
-
-
-
-
-
-Go
-
-
-
\ No newline at end of file
diff --git a/mod/hotpot/version.php b/mod/hotpot/version.php
deleted file mode 100644
index 2205619f5d8..00000000000
--- a/mod/hotpot/version.php
+++ /dev/null
@@ -1,16 +0,0 @@
-version = 2008011200; // release date of this version (see note below)
-$module->release = 'v2.4.2'; // human-friendly version name (used in mod/hotpot/lib.php)
-$module->requires = 2007101509; // Requires this Moodle version
-$module->cron = 0; // period for cron to check this module (secs)
-// interpretation of YYYYMMDDXY version numbers
-// YYYY : year
-// MM : month
-// DD : day
-// X : point release version 1,2,3 etc
-// Y : increment between point releases
-
diff --git a/mod/hotpot/view.php b/mod/hotpot/view.php
deleted file mode 100644
index ef8a419b2fd..00000000000
--- a/mod/hotpot/view.php
+++ /dev/null
@@ -1,528 +0,0 @@
-set_url('/mod/hotpot/report.php', array('id'=>$id));
- if (! $cm = get_coursemodule_from_id('hotpot', $id)) {
- print_error('invalidcoursemodule');
- }
- if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
- print_error('coursemisconf');
- }
- if (! $hotpot = $DB->get_record("hotpot", array("id"=>$cm->instance))) {
- print_error('invalidcoursemodule');
- }
-
- } else {
- $PAGE->set_url('/mod/hotpot/report.php', array('hp'=>$hp));
- if (! $hotpot = $DB->get_record("hotpot", array("id"=>$hp))) {
- print_error('invalidhotpotid', 'hotpot');
- }
- if (! $course = $DB->get_record("course", array("id"=>$hotpot->course))) {
- print_error('coursemisconf');
- }
- if (! $cm = get_coursemodule_from_instance("hotpot", $hotpot->id, $course->id)) {
- print_error('invalidcoursemodule');
- }
-
- }
- require_login($course, true, $cm);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
- require_capability('mod/hotpot:attempt', $context, $USER->id);
- }
- // set nextpage (for error messages)
- $nextpage = "$CFG->wwwroot/course/view.php?id=$course->id";
- // header strings
- $title = format_string($course->shortname.': '.$hotpot->name, true);
- $heading = $course->fullname;
-
- $button = update_module_button($cm->id, $course->id, get_string("modulename", "hotpot"));
- $button = ''.$button.' ';
-
- $PAGE->set_title($title);
- $PAGE->set_heading($heading);
- $PAGE->set_button($button);
-
- $time = time();
- $hppassword = optional_param('hppassword', '', PARAM_RAW);
- if (HOTPOT_FIRST_ATTEMPT && !has_capability('mod/hotpot:grade', $context)) {
- // check this quiz is available to this student
- // error message, if quiz is unavailable
- $error = '';
- // check quiz is visible
- if (!hotpot_is_visible($cm)) {
- $error = get_string("activityiscurrentlyhidden");
- // check network address
- } else if ($hotpot->subnet && !address_in_subnet(getremoteaddr(), $hotpot->subnet)) {
- $error = get_string("subneterror", "quiz");
- // check number of attempts
- } else if ($hotpot->attempts && $hotpot->attempts <= $DB->count_records_select('hotpot_attempts', 'hotpot=? AND userid=?', array($hotpot->id, $USER->id), 'COUNT(DISTINCT clickreportid)')) {
- $error = get_string("nomoreattempts", "quiz");
- // get password
- } else if ($hotpot->password && empty($hppassword)) {
- echo $OUTPUT->header();
- echo $OUTPUT->heading($hotpot->name);
- $boxalign = 'center';
- $boxwidth = 500;
- if (trim(strip_tags($hotpot->summary))) {
- echo $OUTPUT->box_start("generalbox boxalign$boxalign");
- print ''.format_text($hotpot->summary)." \n";
- echo $OUTPUT->box_end();
- print " \n";
- }
- print '\n";
- echo $OUTPUT->footer();
- exit;
- // check password
- } else if ($hotpot->password && strcmp($hotpot->password, $hppassword)) {
- $error = get_string("passworderror", "quiz");
- $nextpage = "view.php?id=$cm->id";
- // check quiz is open
- } else if ($hotpot->timeopen && $hotpot->timeopen > $time) {
- $error = get_string("quiznotavailable", "quiz", userdate($hotpot->timeopen))." \n";
- // check quiz is not closed
- } else if ($hotpot->timeclose && $hotpot->timeclose < $time) {
- $error = get_string("quizclosed", "quiz", userdate($hotpot->timeclose))." \n";
- }
- if ($error) {
- echo $OUTPUT->header();
- notice($error, $nextpage);
- //
- // script stops here, if quiz is unavailable to student
- //
- }
- }
- $available_msg = '';
- if (!empty($hotpot->timeclose) && $hotpot->timeclose > $time) {
- // quiz is available until 'timeclose'
- $available_msg = get_string("quizavailable", "quiz", userdate($hotpot->timeclose))." \n";
- }
- // open and parse the source file
- if(!$hp = new hotpot_xml_quiz($hotpot)) {
- print_error('quizunavailable', 'hotpot');
- }
- $get_js = optional_param('js', '', PARAM_ALPHA);
- $get_css = optional_param('css', '', PARAM_ALPHA);
- $framename = optional_param('framename', '', PARAM_ALPHA);
- // look for |