/**
  * 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
require_once dirname(__FILE__) . '/locallib.php';
$pageparams = new att_report_page_params();
$id = required_param('id', PARAM_INT);
$from = optional_param('from', NULL, PARAM_ACTION);
$pageparams->view = optional_param('view', NULL, PARAM_INT);
$pageparams->curdate = optional_param('curdate', NULL, PARAM_INT);
$pageparams->group = optional_param('group', null, PARAM_INT);
$pageparams->sort = optional_param('sort', 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($cm);
$att = new attforblock($att, $cm, $course, $PAGE->context, $pageparams);
$att->perm->require_view_reports_capability();
$PAGE->set_url($att->url_report());
$PAGE->set_pagelayout('report');
$PAGE->set_title($course->shortname . ": " . $att->name . ' - ' . get_string('report', 'attforblock'));
$PAGE->set_heading($course->fullname);
$PAGE->set_cacheable(true);
$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'attforblock'));
$PAGE->navbar->add(get_string('report', 'attforblock'));
$output = $PAGE->get_renderer('mod_attforblock');
$tabs = new attforblock_tabs($att, attforblock_tabs::TAB_REPORT);
$filtercontrols = new attforblock_filter_controls($att);
$reportdata = new attforblock_report_data($att);
global $USER;
$att->log('report viewed', null, $USER->firstname . ' ' . $USER->lastname);
/// Output starts here
echo $output->header();
echo $output->heading(get_string('attendanceforthecourse', 'attforblock') . ' :: ' . $course->fullname);
Exemple #4
0
$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);
echo $output->footer();