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");
}
}
// make sure this user is enrolled in this course and can access this HotPot
require_login($course);
$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;
$navigation = build_navigation('', $cm);
$button = update_module_button($cm->id, $course->id, get_string("modulename", "hotpot"));
$button = '
'.$button.'
';
$loggedinas = ''.user_login_string($course, $USER).'';
$time = time();
$hppassword = optional_param('hppassword', '');
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 <= count_records_select('hotpot_attempts', 'hotpot='.$hotpot->id.' AND userid='.$USER->id, 'COUNT(DISTINCT clickreportid)')) {
$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', '', PARAM_ALPHA);
$get_css = optional_param('css', '', PARAM_ALPHA);
$framename = optional_param('framename', '', PARAM_ALPHA);
// look for