public function __construct(attendance $att)
 {
     global $CFG;
     $this->perm = $att->perm;
     $this->pageparams = $att->pageparams;
     $this->users = $att->get_users($att->pageparams->group, $att->pageparams->page);
     $this->groups = groups_get_all_groups($att->course->id);
     $this->sessions = $att->get_filtered_sessions();
     $this->statuses = $att->get_statuses();
     $this->allstatuses = $att->get_statuses(false);
     $this->gradable = $att->grade > 0;
     if (!($this->decimalpoints = grade_get_setting($att->course->id, 'decimalpoints'))) {
         $this->decimalpoints = $CFG->grade_decimalpoints;
     }
     foreach ($this->users as $user) {
         $this->usersgroups[$user->id] = groups_get_all_groups($att->course->id, $user->id);
         $this->sessionslog[$user->id] = $att->get_user_filtered_sessions_log($user->id);
         $this->usersstats[$user->id] = $att->get_user_statuses_stat($user->id);
         if ($this->gradable) {
             $this->grades[$user->id] = $att->get_user_grade($user->id);
             $this->maxgrades[$user->id] = $att->get_user_max_grade($user->id);
         }
     }
     $this->att = $att;
 }
 public function __construct(attendance $att)
 {
     global $CFG;
     $this->perm = $att->perm;
     $currenttime = time();
     if ($att->pageparams->view == ATT_VIEW_NOTPRESENT) {
         $att->pageparams->enddate = $currenttime;
     }
     $this->pageparams = $att->pageparams;
     $this->users = $att->get_users($att->pageparams->group, $att->pageparams->page);
     if (isset($att->pageparams->userids)) {
         foreach ($this->users as $key => $user) {
             if (!in_array($user->id, $att->pageparams->userids)) {
                 unset($this->users[$key]);
             }
         }
     }
     $this->groups = groups_get_all_groups($att->course->id);
     $this->sessions = $att->get_filtered_sessions();
     $this->statuses = $att->get_statuses(true, true);
     $this->allstatuses = $att->get_statuses(false, true);
     $this->gradable = $att->grade > 0;
     if (!($this->decimalpoints = grade_get_setting($att->course->id, 'decimalpoints'))) {
         $this->decimalpoints = $CFG->grade_decimalpoints;
     }
     $maxgrade = att_get_user_max_grade(count($this->sessions), $this->statuses);
     foreach ($this->users as $key => $user) {
         $grade = 0;
         if ($this->gradable) {
             $grade = $att->get_user_grade($user->id, array('enddate' => $currenttime));
             $totalgrade = $att->get_user_grade($user->id);
         }
         if ($att->pageparams->view != ATT_VIEW_NOTPRESENT || $grade < $maxgrade) {
             $this->usersgroups[$user->id] = groups_get_all_groups($att->course->id, $user->id);
             $this->sessionslog[$user->id] = $att->get_user_filtered_sessions_log($user->id);
             $this->usersstats[$user->id] = $att->get_user_statuses_stat($user->id);
             if ($this->gradable) {
                 $this->grades[$user->id] = $totalgrade;
                 $this->maxgrades[$user->id] = $att->get_user_max_grade($user->id);
             }
         } else {
             unset($this->users[$key]);
         }
     }
     $this->att = $att;
 }