Ejemplo n.º 1
0
require_login($course, true, $cm);
$pageparams->init($cm);
$att = new attforblock($att, $cm, $course, $PAGE->context, $pageparams);
if (!$att->perm->can_manage() && !$att->perm->can_take() && !$att->perm->can_change()) {
    redirect($att->url_view());
}
// if teacher is coming from block, then check for a session exists for today
if ($from === 'block') {
    $sessions = $att->get_today_sessions();
    $size = count($sessions);
    if ($size == 1) {
        $sess = reset($sessions);
        $nottaken = !$sess->lasttaken && has_capability('mod/attforblock:takeattendances', $PAGE->context);
        $canchange = $sess->lasttaken && has_capability('mod/attforblock:changeattendances', $PAGE->context);
        if ($nottaken || $canchange) {
            redirect($att->url_take(array('sessionid' => $sess->id, 'grouptype' => $sess->groupid)));
        }
    } elseif ($size > 1) {
        $att->curdate = $today;
        //temporally set $view for single access to page from block
        $att->{$view} = ATT_VIEW_DAYS;
    }
}
$PAGE->set_url($att->url_manage());
$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, 'attforblock'));
$PAGE->navbar->add($att->name);
$output = $PAGE->get_renderer('mod_attforblock');
$tabs = new attforblock_tabs($att, attforblock_tabs::TAB_SESSIONS);
Ejemplo n.º 2
0
$pageparams->sessionid = required_param('sessionid', PARAM_INT);
$pageparams->grouptype = required_param('grouptype', PARAM_INT);
$pageparams->group = optional_param('group', null, PARAM_INT);
$pageparams->sort = optional_param('sort', null, PARAM_INT);
$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('attforblock', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$att = $DB->get_record('attforblock', array('id' => $cm->instance), '*', MUST_EXIST);
require_login($course, true, $cm);
$pageparams->init($course->id);
$att = new attforblock($att, $cm, $course, $PAGE->context, $pageparams);
if ($formdata = data_submitted()) {
    $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, 'attforblock'));
$PAGE->navbar->add($att->name);
$output = $PAGE->get_renderer('mod_attforblock');
$tabs = new attforblock_tabs($att);
$sesstable = new attforblock_take_data($att);
/// Output starts here
echo $output->header();
echo $output->heading(get_string('attendanceforthecourse', 'attforblock') . ' :: ' . $course->fullname);
echo $output->render($tabs);
echo $output->render($sesstable);
echo $output->footer();
Ejemplo n.º 3
0
 public function __construct(attforblock $att)
 {
     if ($att->pageparams->grouptype) {
         $this->users = $att->get_users($att->pageparams->grouptype);
     } else {
         $this->users = $att->get_users($att->pageparams->group);
     }
     $this->pageparams = $att->pageparams;
     $this->perm = $att->perm;
     $this->groupmode = $att->get_group_mode();
     $this->cm = $att->cm;
     $this->statuses = $att->get_statuses();
     $this->sessioninfo = $att->get_session_info($att->pageparams->sessionid);
     $this->updatemode = $this->sessioninfo->lasttaken > 0;
     if (isset($att->pageparams->copyfrom)) {
         $this->sessionlog = $att->get_session_log($att->pageparams->copyfrom);
     } elseif ($this->updatemode) {
         $this->sessionlog = $att->get_session_log($att->pageparams->sessionid);
     } else {
         $this->sessionlog = array();
     }
     if (!$this->updatemode) {
         $this->sessions4copy = $att->get_today_sessions_for_copy($this->sessioninfo);
     }
     $this->urlpath = $att->url_take()->out_omit_querystring();
     $params = $att->pageparams->get_significant_params();
     $params['id'] = $att->cm->id;
     $this->urlparams = $params;
     $this->att = $att;
 }