';
if (completion_can_view_data($user->id, $course)) {
$userurl = new moodle_url('/blocks/completionstatus/details.php', array('course' => $course->id, 'user' => $user->id));
} else {
$userurl = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $course->id));
}
print ''.fullname($user).' | ';
foreach ($extrafields as $field) {
echo ''.s($user->{$field}).' | ';
}
}
// Progress for each course completion criteria
foreach ($criteria as $criterion) {
$criteria_completion = $completion->get_user_completion($user->id, $criterion);
$is_complete = $criteria_completion->is_complete();
// Handle activity completion differently
if ($criterion->criteriatype == COMPLETION_CRITERIA_TYPE_ACTIVITY) {
// Load activity
$activity = $modinfo->cms[$criterion->moduleinstance];
// Get progress information and state
if (array_key_exists($activity->id, $user->progress)) {
$state = $user->progress[$activity->id]->completionstate;
} else if ($is_complete) {
$state = COMPLETION_COMPLETE;
} else {
$state = COMPLETION_INCOMPLETE;
}
if ($is_complete) {
$date = userdate($criteria_completion->timecompleted, get_string('strftimedatetimeshort', 'langconfig'));
} else {
$date = '';
}
// Work out how it corresponds to an icon
switch($state) {
case COMPLETION_INCOMPLETE : $completiontype = 'n'; break;
case COMPLETION_COMPLETE : $completiontype = 'y'; break;
case COMPLETION_COMPLETE_PASS : $completiontype = 'pass'; break;
case COMPLETION_COMPLETE_FAIL : $completiontype = 'fail'; break;
}
$auto = $activity->completion == COMPLETION_TRACKING_AUTOMATIC;
$completionicon = 'completion-'.($auto ? 'auto' : 'manual').'-'.$completiontype;
$describe = get_string('completion-'.$completiontype, 'completion');
$a = new StdClass();
$a->state = $describe;
$a->date = $date;
$a->user = fullname($user);
$a->activity = $activity->get_formatted_name();
$fulldescribe = get_string('progress-title', 'completion', $a);
if ($csv) {
$row[] = $describe;
$row[] = $date;
} else {
print '';
print $OUTPUT->pix_icon('i/' . $completionicon, $fulldescribe);
print ' | ';
}
continue;
}
// Handle all other criteria
$completiontype = $is_complete ? 'y' : 'n';
$completionicon = 'completion-auto-'.$completiontype;
$describe = get_string('completion-'.$completiontype, 'completion');
$a = new stdClass();
$a->state = $describe;
if ($is_complete) {
$a->date = userdate($criteria_completion->timecompleted, get_string('strftimedatetimeshort', 'langconfig'));
} else {
$a->date = '';
}
$a->user = fullname($user);
$a->activity = strip_tags($criterion->get_title());
$fulldescribe = get_string('progress-title', 'completion', $a);
if ($csv) {
$row[] = $a->date;
} else {
print '';
if ($allow_marking_criteria === $criterion->id) {
$describe = get_string('completion-'.$completiontype, 'completion');
$toggleurl = new moodle_url(
'/course/togglecompletion.php',
array(
'user' => $user->id,
'course' => $course->id,
'rolec' => $allow_marking_criteria,
'sesskey' => sesskey()
)
);
print '' .
$OUTPUT->pix_icon('i/completion-manual-' . ($is_complete ? 'y' : 'n'), $describe) . ' | ';
} else {
print $OUTPUT->pix_icon('i/' . $completionicon, $fulldescribe) . '';
}
print '';
}
}
// Handle overall course completion
// Load course completion
$params = array(
'userid' => $user->id,
'course' => $course->id
);
$ccompletion = new completion_completion($params);
$completiontype = $ccompletion->is_complete() ? 'y' : 'n';
$describe = get_string('completion-'.$completiontype, 'completion');
$a = new StdClass;
if ($ccompletion->is_complete()) {
$a->date = userdate($ccompletion->timecompleted, get_string('strftimedatetimeshort', 'langconfig'));
} else {
$a->date = '';
}
$a->state = $describe;
$a->user = fullname($user);
$a->activity = strip_tags(get_string('coursecomplete', 'completion'));
$fulldescribe = get_string('progress-title', 'completion', $a);
if ($csv) {
$row[] = $a->date;
} else {
print '';
// Display course completion status icon
print $OUTPUT->pix_icon('i/completion-auto-' . $completiontype, $fulldescribe);
print ' | ';
}
if ($csv) {
$export->add_data($row);
} else {
print '
';
}
}
if ($csv) {
$export->download_file();
} else {
echo '