Skip to content

Commit

Permalink
Added multiple instances support.
Browse files Browse the repository at this point in the history
  • Loading branch information
lrlopez committed Jan 19, 2011
1 parent 4101e34 commit b5b3c71
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions block_attendance.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ function get_content() {
$this->content->footer = '';
$this->content->text = '';

if (!$att = array_pop(get_all_instances_in_course('attforblock', $COURSE, NULL, true))) {
$att = get_all_instances_in_course('attforblock', $COURSE, NULL, true);
if (count($att)==0) {
$this->content->text = get_string('needactivity','block_attendance');;
return $this->content;
}
$cmid = $att->coursemodule;
foreach ($att as $attinst) {
$cmid = $attinst->coursemodule;
require_once($CFG->dirroot.'/mod/attforblock/locallib.php');

if (!$context = get_context_instance(CONTEXT_MODULE, $cmid)) {
print_error('badcontext');
}
$this->content->text .= '<b>' . htmlentities($attinst->name) . '</b><br/>';
// link to attendance
if (has_capability('mod/attforblock:takeattendances', $context) or has_capability('mod/attforblock:changeattendances', $context)) {
$this->content->text .= '<a href="'.$CFG->wwwroot.'/mod/attforblock/manage.php?id='.$cmid.'&amp;from=block">'.get_string('takeattendance','attforblock').'</a><br />';
Expand Down Expand Up @@ -57,7 +59,7 @@ function get_content() {
$this->content->text .= $st->description.':&nbsp;'.get_attendance($USER->id,$COURSE,$st->id).'<br />';
}

if ($att->grade) {
if ($attinst->grade) {
$percent = get_percent($USER->id, $COURSE);
$grade = get_grade($USER->id, $COURSE);

Expand All @@ -68,7 +70,7 @@ function get_content() {
$this->content->text .= '<a href="'.$CFG->wwwroot.'/mod/attforblock/view.php?id='.$cmid.'">'.get_string('indetail','attforblock').'</a>';
}
}
}
return $this->content;
}
}
Expand Down

0 comments on commit b5b3c71

Please sign in to comment.