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 = '
'.$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