示例#1
0
 /**
  * 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;
 }
示例#3
0
 */
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('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);
$att = new attforblock($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, 'attforblock'));
$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_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'));
        }