Ejemplo n.º 1
0
$pageparams->copyfrom = optional_param('copyfrom', null, PARAM_INT);
$pageparams->viewmode = optional_param('viewmode', null, PARAM_INT);
$pageparams->gridcols = optional_param('gridcols', null, PARAM_INT);
$cm = get_coursemodule_from_id('attcontrol', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$att = $DB->get_record('attcontrol', array('id' => $cm->instance), '*', MUST_EXIST);
require_login($course, true, $cm);
$pageparams->group = groups_get_activity_group($cm, true);
$pageparams->init($course->id);
$att = new attcontrol($att, $cm, $course, $PAGE->context, $pageparams);
if (!$att->perm->can_take_session($pageparams->grouptype)) {
    $group = groups_get_group($pageparams->grouptype);
    throw new moodle_exception('cannottakeforgroup', 'attcontrol', '', $group->name);
}
if (($formdata = data_submitted()) && confirm_sesskey()) {
    $att->take_from_form_data($formdata);
}
$PAGE->set_url($att->url_take());
$PAGE->set_title($course->shortname . ": " . $att->name);
$PAGE->set_heading($course->fullname);
$PAGE->set_cacheable(true);
$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'attcontrol'));
$PAGE->navbar->add($att->name);
$output = $PAGE->get_renderer('mod_attcontrol');
$tabs = new attcontrol_tabs($att);
$sesstable = new attcontrol_take_data($att);
// Output starts here.
echo $output->header();
echo $output->heading(get_string('attendancecontrol', 'attcontrol'));
echo $output->render($tabs);
echo $output->render($sesstable);