/**
  * Return array of rows where each row is an array of tab objects
  * taking into account permissions of current user
  */
 public function get_tabs()
 {
     $toprow = array();
     if ($this->att->perm->can_manage() or $this->att->perm->can_take() or $this->att->perm->can_change()) {
         $toprow[] = new tabobject(self::TAB_SESSIONS, $this->att->url_manage()->out(), get_string('sessions', 'attforblock'));
     }
     if ($this->att->perm->can_manage()) {
         $toprow[] = new tabobject(self::TAB_ADD, $this->att->url_sessions()->out(true, array('action' => att_sessions_page_params::ACTION_ADD)), get_string('add', 'attforblock'));
     }
     if ($this->att->perm->can_view_reports()) {
         $toprow[] = new tabobject(self::TAB_REPORT, $this->att->url_report()->out(), get_string('report', 'attforblock'));
     }
     if ($this->att->perm->can_export()) {
         $toprow[] = new tabobject(self::TAB_EXPORT, $this->att->url_export()->out(), get_string('export', 'quiz'));
     }
     if ($this->att->perm->can_change_preferences()) {
         $toprow[] = new tabobject(self::TAB_PREFERENCES, $this->att->url_preferences()->out(), get_string('settings', 'attforblock'));
     }
     return array($toprow);
 }
 function get_content()
 {
     global $CFG, $USER, $COURSE;
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->footer = '';
     $this->content->text = '';
     $attendances = get_all_instances_in_course('attforblock', $COURSE, NULL, true);
     if (count($attendances) == 0) {
         $this->content->text = get_string('needactivity', 'block_attendance');
         return $this->content;
     }
     require_once $CFG->dirroot . '/mod/attforblock/locallib.php';
     require_once $CFG->dirroot . '/mod/attforblock/renderhelpers.php';
     foreach ($attendances as $attinst) {
         $cmid = $attinst->coursemodule;
         $context = get_context_instance(CONTEXT_MODULE, $cmid, MUST_EXIST);
         $divided = $this->divide_databasetable_and_coursemodule_data($attinst);
         $att = new attforblock($divided->atttable, $divided->cm, $COURSE, $context);
         $this->content->text .= html_writer::link($att->url_view(), html_writer::tag('b', format_string($att->name)));
         $this->content->text .= html_writer::empty_tag('br');
         // link to attendance
         if ($att->perm->can_take() or $att->perm->can_change()) {
             $this->content->text .= html_writer::link($att->url_manage(array('from' => 'block')), get_string('takeattendance', 'attforblock'));
             $this->content->text .= html_writer::empty_tag('br');
         }
         if ($att->perm->can_manage()) {
             $url = $att->url_sessions(array('action' => att_sessions_page_params::ACTION_ADD));
             $this->content->text .= html_writer::link($url, get_string('add', 'attforblock'));
             $this->content->text .= html_writer::empty_tag('br');
         }
         if ($att->perm->can_view_reports()) {
             $this->content->text .= html_writer::link($att->url_report(), get_string('report', 'attforblock'));
             $this->content->text .= html_writer::empty_tag('br');
         }
         if ($att->perm->can_be_listed() && $att->perm->can_view()) {
             $this->content->text .= construct_full_user_stat_html_table($attinst, $COURSE, $USER);
         }
         $this->content->text .= "<br />";
     }
     return $this->content;
 }
Exemple #3
0
 case att_sessions_page_params::ACTION_ADD:
     $url = $att->url_sessions(array('action' => att_sessions_page_params::ACTION_ADD));
     $mform = new mod_attforblock_add_form($url, $formparams);
     if ($formdata = $mform->get_data()) {
         $sessions = construct_sessions_data_for_add($formdata);
         $att->add_sessions($sessions);
         redirect($url, get_string('sessionsgenerated', 'attforblock'));
     }
     break;
 case att_sessions_page_params::ACTION_UPDATE:
     $sessionid = required_param('sessionid', PARAM_INT);
     $url = $att->url_sessions(array('action' => att_sessions_page_params::ACTION_UPDATE, 'sessionid' => $sessionid));
     $formparams['sessionid'] = $sessionid;
     $mform = new mod_attforblock_update_form($url, $formparams);
     if ($mform->is_cancelled()) {
         redirect($att->url_manage());
     }
     if ($formdata = $mform->get_data()) {
         $att->update_session_from_form_data($formdata, $sessionid);
         redirect($att->url_manage(), get_string('sessionupdated', 'attforblock'));
     }
     break;
 case att_sessions_page_params::ACTION_DELETE:
     $sessionid = required_param('sessionid', PARAM_INT);
     $confirm = optional_param('confirm', NULL, PARAM_INT);
     if (isset($confirm)) {
         $att->delete_sessions(array($sessionid));
         att_update_all_users_grades($att->id, $att->course, $att->context);
         redirect($att->url_manage(), get_string('sessiondeleted', 'attforblock'));
     }
     $sessinfo = $att->get_session_info($sessionid);
Exemple #4
0
     $data->tabhead[] = get_string('studentid', 'attforblock');
 }
 if (isset($formdata->ident['uname'])) {
     $data->tabhead[] = get_string('username');
 }
 $data->tabhead[] = get_string('lastname');
 $data->tabhead[] = get_string('firstname');
 if (count($reportdata->sessions) > 0) {
     foreach ($reportdata->sessions as $sess) {
         $text = userdate($sess->sessdate, get_string('strftimedmyhm', 'attforblock'));
         $text .= ' ';
         $text .= $sess->groupid ? $reportdata->groups[$sess->groupid]->name : get_string('commonsession', 'attforblock');
         $data->tabhead[] = $text;
     }
 } else {
     print_error('sessionsnotfound', 'attforblock', $att->url_manage());
 }
 if ($reportdata->gradable) {
     $data->tabhead[] = get_string('grade');
 }
 $i = 0;
 $data->table = array();
 foreach ($reportdata->users as $user) {
     if (isset($formdata->ident['id'])) {
         $data->table[$i][] = $user->id;
     }
     if (isset($formdata->ident['uname'])) {
         $data->table[$i][] = $user->username;
     }
     $data->table[$i][] = $user->lastname;
     $data->table[$i][] = $user->firstname;
Exemple #5
0
    $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);
$filtercontrols = new attforblock_filter_controls($att);
$sesstable = new attforblock_manage_data($att);
/// Output starts here
$sesstable->params = $pageparams;
$sesstable->cm = $cm;
echo $output->header();
echo $output->heading(get_string('attendanceforthecourse', 'attforblock') . ' :: ' . $course->fullname);
echo $output->render($tabs);
Exemple #6
0
$id = required_param('id', PARAM_INT);
$pageparams->studentid = optional_param('studentid', NULL, PARAM_INT);
$pageparams->mode = optional_param('mode', att_view_page_params::MODE_THIS_COURSE, PARAM_INT);
$pageparams->view = optional_param('view', NULL, PARAM_INT);
$pageparams->curdate = optional_param('curdate', 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);
$attforblock = $DB->get_record('attforblock', array('id' => $cm->instance), '*', MUST_EXIST);
require_login($course, true, $cm);
$pageparams->init($cm);
$att = new attforblock($attforblock, $cm, $course, $PAGE->context, $pageparams);
// Not specified studentid for displaying attendance?
// Redirect to appropriate page if can
if (!$pageparams->studentid) {
    if ($att->perm->can_manage() || $att->perm->can_take() || $att->perm->can_change()) {
        redirect($att->url_manage());
    } elseif ($att->perm->can_view_reports()) {
        redirect($att->url_report());
    }
}
$att->perm->require_view_capability();
$PAGE->set_url($att->url_view());
$PAGE->set_title($course->shortname . ": " . $att->name);
$PAGE->set_heading($course->fullname);
$PAGE->set_cacheable(true);
$PAGE->navbar->add(get_string('attendancereport', 'attforblock'));
$output = $PAGE->get_renderer('mod_attforblock');
$userid = isset($pageparams->studentid) ? $pageparams->studentid : $USER->id;
$userdata = new attforblock_user_data($att, $userid);
echo $output->header();
echo $output->render($userdata);