/** * 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(); $context = $this->att->context; $capabilities = array('mod/attendance:manageattendances', 'mod/attendance:takeattendances', 'mod/attendance:changeattendances'); if (has_any_capability($capabilities, $context)) { $toprow[] = new tabobject(self::TAB_SESSIONS, $this->att->url_manage()->out(), get_string('sessions', 'attendance')); } if (has_capability('mod/attendance:manageattendances', $context)) { $toprow[] = new tabobject(self::TAB_ADD, $this->att->url_sessions()->out(true, array('action' => att_sessions_page_params::ACTION_ADD)), get_string('add', 'attendance')); } if (has_capability('mod/attendance:viewreports', $context)) { $toprow[] = new tabobject(self::TAB_REPORT, $this->att->url_report()->out(), get_string('report', 'attendance')); } if (has_capability('mod/attendance:export', $context)) { $toprow[] = new tabobject(self::TAB_EXPORT, $this->att->url_export()->out(), get_string('export', 'attendance')); } if (has_capability('mod/attendance:changepreferences', $context)) { $toprow[] = new tabobject(self::TAB_PREFERENCES, $this->att->url_preferences()->out(), get_string('settings', 'attendance')); } if (has_capability('mod/attendance:managetemporaryusers', $context)) { $toprow[] = new tabobject(self::TAB_TEMPORARYUSERS, $this->att->url_managetemp()->out(), get_string('tempusers', 'attendance')); } return array($toprow); }
/** * 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', 'local_attendance')); } if ($this->att->perm->can_manage()) { $toprow[] = new tabobject(self::TAB_ADD, $this->att->url_sessions()->out(true, array('action' => local_att_sessions_page_params::ACTION_ADD)), get_string('add', 'local_attendance')); } if ($this->att->perm->can_view_reports()) { $toprow[] = new tabobject(self::TAB_REPORT, $this->att->url_report()->out(), get_string('report', 'local_attendance')); } if ($this->att->perm->can_export()) { $toprow[] = new tabobject(self::TAB_EXPORT, $this->att->url_export()->out(), get_string('export', 'local_attendance')); } if ($this->att->perm->can_change_preferences()) { $toprow[] = new tabobject(self::TAB_PREFERENCES, $this->att->url_preferences()->out(), get_string('settings', 'local_attendance')); } return array($toprow); }
/** * Gets the content for this block * * @return object $this->content */ public 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('attendance', $COURSE, null, true); if (count($attendances) == 0) { $this->content->text = get_string('needactivity', 'block_attendance'); return $this->content; } require_once $CFG->dirroot . '/mod/attendance/locallib.php'; require_once $CFG->dirroot . '/mod/attendance/renderhelpers.php'; foreach ($attendances as $attinst) { $cmid = $attinst->coursemodule; $cm = get_coursemodule_from_id('attendance', $cmid, $COURSE->id, false, MUST_EXIST); $context = context_module::instance($cmid, MUST_EXIST); $divided = $this->divide_databasetable_and_coursemodule_data($attinst); $att = new attendance($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', 'attendance')); $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', 'attendance')); $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', 'attendance')); $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, $cm); } $this->content->text .= "<br />"; } return $this->content; }
*/ require_once dirname(__FILE__) . '/../../config.php'; require_once dirname(__FILE__) . '/locallib.php'; require_once dirname(__FILE__) . '/add_form.php'; require_once dirname(__FILE__) . '/update_form.php'; require_once dirname(__FILE__) . '/duration_form.php'; $pageparams = new att_sessions_page_params(); $id = required_param('id', PARAM_INT); $pageparams->action = required_param('action', PARAM_INT); $cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); require_login($course, true, $cm); $att = new attendance($att, $cm, $course, $PAGE->context, $pageparams); $att->perm->require_manage_capability(); $PAGE->set_url($att->url_sessions()); $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, 'attendance')); $PAGE->navbar->add($att->name); $formparams = array('course' => $course, 'cm' => $cm, 'modcontext' => $PAGE->context); switch ($att->pageparams->action) { case att_sessions_page_params::ACTION_ADD: $url = $att->url_sessions(array('action' => att_sessions_page_params::ACTION_ADD)); $mform = new mod_attendance_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', 'attendance')); }
// Check that the required parameters are present. $id = required_param('sessid', PARAM_INT); $attendance_session_id = required_param('sessid', PARAM_INT); $attforsession = $DB->get_record('attendance_sessions', array('id' => $id), '*', MUST_EXIST); $attendance = $DB->get_record('attendance', array('id' => $attforsession->attendanceid), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('attendance', $attendance->id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); // Require the user is logged in. require_login($course, true, $cm); $pageparams->sessionid = $id; $att = new attendance($attendance, $cm, $course, $PAGE->context, $pageparams); // Require that a session key is passed to this page. require_sesskey(); // Create the form. $mform = new mod_attendance_student_attendance_form(null, array('course' => $course, 'cm' => $cm, 'modcontext' => $PAGE->context, 'session' => $attforsession, 'attendance' => $att)); $PAGE->set_url($att->url_sessions()); if ($mform->is_cancelled()) { // The user cancelled the form, so redirect them to the view page. $url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id)); redirect($url); } else { if ($fromform = $mform->get_data()) { if (!empty($fromform->status)) { $success = $att->take_from_student($fromform); $url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id)); if ($success) { // Redirect back to the view page for the block. redirect($url); } else { print_error('attendance_already_submitted', 'mod_attendance', $url); }