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");
}
}
require_login($course->id);
}
// set nextpage (for error messages)
$nextpage = "$CFG->wwwroot/course/view.php?id=$course->id";
// header strings
$title = strip_tags($course->shortname.': '.$hotpot->name);
$heading = "$course->fullname";
$target = empty($CFG->framename) ? '' : ' target="'.$CFG->framename.'"';
$navigation = ''.get_string("modulenameplural", "hotpot")." -> $hotpot->name";
if ($course->category) {
$navigation = ''.$course->shortname.' -> '.$navigation;
}
$button = update_module_button($cm->id, $course->id, get_string("modulename", "hotpot").'" style="font-size:0.75em;');
$loggedinas = ''.user_login_string($course, $USER).'';
$time = time();
$hppassword = optional_param('hppassword');
if (HOTPOT_FIRST_ATTEMPT && !isteacher($course->id)) {
// 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($_SERVER['REMOTE_ADDR'], $hotpot->subnet)) {
$error = get_string("subneterror", "quiz");
// check number of attempts
} else if ($hotpot->attempts && $hotpot->attempts <= count_records('hotpot_attempts', 'hotpot', $hotpot->id, 'userid', $USER->id)) {
$error = get_string("nomoreattempts", "quiz");
// get password
} else if ($hotpot->password && empty($hppassword)) {
print_header($title, $heading, $navigation, "", "", true, $button, $loggedinas, false);
print_heading($hotpot->name);
$boxalign = 'center';
$boxwidth = 500;
if (trim(strip_tags($hotpot->summary))) {
print_simple_box_start($boxalign, $boxwidth);
print '
'.format_text($hotpot->summary)."
\n";
print_simple_box_end();
print "
\n";
}
print '\n";
print_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) {
print_header($title, $heading, $navigation, "", "", true, $button, $loggedinas, false);
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)) {
error("Quiz is unavailable at the moment");
}
$get_js = optional_param('js');
$get_css = optional_param('css');
$framename = optional_param('framename');
// look for