Exemplo n.º 1
0
    $cm = get_coursemodule_from_id('hotpot', $id, 0, false, MUST_EXIST);
    $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
    $hotpot = $DB->get_record('hotpot', array('id' => $cm->instance), '*', MUST_EXIST);
} else {
    $hotpot = $DB->get_record('hotpot', array('id' => $hp), '*', MUST_EXIST);
    $course = $DB->get_record('course', array('id' => $hotpot->course), '*', MUST_EXIST);
    $cm = get_coursemodule_from_instance('hotpot', $hotpot->id, $course->id, false, MUST_EXIST);
}
// check login
require_login($course, true, $cm);
if (!has_capability('mod/hotpot:reviewallattempts', $PAGE->context)) {
    require_capability('mod/hotpot:reviewmyattempts', $PAGE->context);
}
add_to_log($course->id, 'hotpot', 'report', 'report.php?id=' . $cm->id, $hotpot->id, $cm->id);
// Create an object to represent the current HotPot activity
$hotpot = hotpot::create($hotpot, $cm, $course, $PAGE->context);
// delete attempts, if requested
$action = optional_param('action', '', PARAM_ALPHA);
$confirmed = optional_param('confirmed', 0, PARAM_INT);
if (function_exists('optional_param_array')) {
    $selected = optional_param_array('selected', 0, PARAM_INT);
} else {
    $selected = optional_param('selected', 0, PARAM_INT);
}
if ($action == 'deleteselected') {
    require_sesskey();
    if ($confirmed) {
        $hotpot->delete_attempts($selected, false);
    } else {
        // show a confirm button ?
    }
Exemplo n.º 2
0
/**
 * Extends the global navigation tree by adding hotpot nodes if there is a relevant content
 *
 * This can be called by an AJAX request so do not rely on $PAGE as it might not be set up properly.
 *
 * @param navigation_node $navref An object representing the navigation tree node of the hotpot module instance
 * @param stdclass $course
 * @param stdclass $module
 * @param cm_info  $cm
 */
function hotpot_extend_navigation(navigation_node $hotpotnode, stdclass $course, stdclass $module, cm_info $cm)
{
    global $CFG, $DB;
    require_once $CFG->dirroot . '/mod/hotpot/locallib.php';
    $hotpot = $DB->get_record('hotpot', array('id' => $cm->instance), '*', MUST_EXIST);
    $hotpot = hotpot::create($hotpot, $cm, $course);
    if ($hotpot->can_reviewattempts()) {
        $icon = new pix_icon('i/report', '');
        $type = navigation_node::TYPE_SETTING;
        foreach ($hotpot->get_report_modes() as $mode) {
            $url = $hotpot->report_url($mode);
            $label = get_string($mode . 'report', 'hotpot');
            $hotpotnode->add($label, $url, $type, null, null, $icon);
        }
    }
}