course)) { error("Course is misconfigured"); } if (! $hotpot = get_record("hotpot", "id", $cm->instance)) { error("Course module is incorrect"); } } else { if (! $hotpot = get_record("hotpot", "id", $hp)) { error("Course module is incorrect"); } if (! $course = get_record("course", "id", $hotpot->course)) { error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("hotpot", $hotpot->id, $course->id)) { error("Course Module ID was incorrect"); } } if (! $attempt = get_record("hotpot_attempts", "id", $attempt)) { error("Attempt ID was incorrect"); } require_login($course); // check user can access this hotpot activity if (!hotpot_is_visible($cm)) { print_error("activityiscurrentlyhidden"); } $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) { error("This is not your attempt!"); } } 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 $title = format_string($course->shortname) . ": $hotpot->name"; $heading = $course->fullname; $navigation = build_navigation('', $cm); $button = update_module_button($cm->id, $course->id, $strmodulename); print_header($title, $heading, $navigation, "", "", true, $button, navmenu($course, $cm)); print ''; // for overlib print_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 = get_field('hotpot_details', 'details', '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); print_footer($course); /////////////////////////// // functions /////////////////////////// function hotpot_print_attempt_summary(&$hotpot, &$attempt) { // start table print_simple_box_start("center", "80%", "#ffffff", 0); 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 ''; } } // finish table print '
'.$name.':'.$value.'
'; print_simple_box_end(); } function hotpot_print_review_buttons(&$course, &$hotpot, &$attempt, $context) { print "\n".''; print "\n\n".'\n".'\n".'\n\n"; print '\n"; print "
'; print_single_button("report.php?hp=$hotpot->id", NULL, get_string('continue'), 'post'); if (has_capability('mod/hotpot:viewreport',$context) && record_exists('hotpot_details', 'attempt', $attempt->id)) { print "'; print_single_button("review.php?hp=$hotpot->id&attempt=$attempt->id&action=showxmlsource", NULL, get_string('showxmlsource', 'hotpot'), 'post'); print "'; print_single_button("review.php?hp=$hotpot->id&attempt=$attempt->id&action=showxmltree", NULL, get_string('showxmltree', 'hotpot'), 'post'); $colspan = 3; } else { $colspan = 1; } print "
'; print_spacer(4, 1, false); // height=4, width=1, no
print "
\n"; } function hotpot_print_attempt_details(&$hotpot, &$attempt) { // 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 = get_records_select('hotpot_questions', "hotpot='$hotpot->id'", 'id'); $responses = get_records_select('hotpot_responses', "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 print_simple_box_start("center", "80%", "#ffffff", 0); print ''."\n"; if (empty($q)) { print '\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 ''."\n"; $printedquestion = true; } // print response print ''."\n"; } } } // add row of numeric fields print ''; foreach ($numfields as $field) { if ($f[$field]['count']) { // print question if necessary if (!$printedquestion) { print '\n"; $printedquestion = true; } // print numeric response $value = isset($question[$field]) ? $question[$field] : '-'; print ''; } } print "\n"; } // foreach $q } // finish table print "
'.get_string("noresponses", "hotpot")."
'.$question['name'].'
'.$f[$field]['name'].':'.$text.'
'.$question['name']."
'.$f[$field]['name'].':'.$value.'
\n"; print_simple_box_end(); } ?>