/**
  * 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;
 }
Exemplo n.º 2
0
function attendance_user_complete($course, $user, $mod, $attendance)
{
    global $CFG;
    require_once dirname(__FILE__) . '/renderhelpers.php';
    require_once $CFG->libdir . '/gradelib.php';
    if (has_capability('mod/attendance:canbelisted', $mod->context, $user->id)) {
        echo construct_full_user_stat_html_table($attendance, $course, $user, $mod);
    }
}
Exemplo n.º 3
0
function attforblock_user_complete($course, $user, $mod, $attforblock)
{
    /// Print a detailed representation of what a  user has done with
    /// a given particular instance of this module, for user activity reports.
    global $CFG;
    require_once dirname(__FILE__) . '/renderhelpers.php';
    require_once $CFG->libdir . '/gradelib.php';
    if (has_capability('mod/attforblock:canbelisted', $mod->context, $user->id)) {
        echo construct_full_user_stat_html_table($attforblock, $course, $user);
    }
    //return true;
}