// Handle activity completion differently if ($criterion->criteriatype == COMPLETION_CRITERIA_TYPE_ACTIVITY) { // Load activity $mod = $criterion->get_mod_instance(); $activity = $DB->get_record('course_modules', array('id' => $criterion->moduleinstance)); $activity->name = $mod->name; // Get progress information and state if (array_key_exists($activity->id, $user->progress)) { $thisprogress = $user->progress[$activity->id]; $state = $thisprogress->completionstate; $date = userdate($thisprogress->timemodified); } else { $state = COMPLETION_INCOMPLETE; $date = ''; } $criteria_completion = $completion->get_user_completion($user->id, $criterion); // 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; }