Beispiel #1
0
 /**
  * @before _secure, _student
  */
 public function index()
 {
     $this->setSEO(array("title" => "Students | Dashboard"));
     $this->getLayoutView()->set("cal", true);
     $view = $this->getActionView();
     $session = Registry::get("session");
     $enrollment = Enrollment::first(array("user_id = ?" => $this->user->id));
     $classroom = Classroom::first(array("id = ?" => $enrollment->classroom_id));
     $grade = Grade::first(array("id = ?" => $classroom->grade_id));
     $courses = StudentService::$_courses;
     $d = StringMethods::month_se();
     // find average attendance for the month
     $service = new \Shared\Services\Attendance();
     $attendances = $service->find($d['start'], $d['end']);
     $present = 0;
     $total = 0;
     foreach ($attendances as $a) {
         $total++;
         if ($a['title'] == "Present") {
             $present++;
         }
     }
     $avg = (string) ($present / $total * 100);
     // find total assignments
     $service = new \Shared\Services\Assignment();
     $asmt = $service->total($classroom, $courses);
     $view->set("enrollment", $enrollment)->set("classroom", $classroom)->set("grade", $grade)->set("courses", $courses)->set("assignments", $asmt)->set("attendance", substr($avg, 0, 5));
 }
Beispiel #2
0
 public function performance($course)
 {
     $session = Registry::get("session");
     $perf = Registry::get("MongoDB")->performance;
     $week = (new \DateTime(date('Y-m-d')))->format("W");
     $performance = array();
     $classroom = self::$_classroom;
     $record = $perf->findOne(array('user_id' => (int) self::$_student->user_id, 'course_id' => (int) $course->id, 'year' => date('Y'), 'classroom_id' => (int) $classroom->id));
     $d = StringMethods::month_se();
     $start = (int) (new \DateTime($d['start']))->format("W");
     if ($start == 53) {
         $start = 1;
     }
     $end = (int) (new \DateTime($d['end']))->format("W");
     $monthly = array();
     if (isset($record)) {
         $performance['course'] = $course->title;
         $performance['teacher'] = \User::first(array("id = ?" => $record['teacher_id']), array("name"))->name;
         foreach ($record['track'] as $track) {
             $week = $track['week'];
             if ($week <= $end && $week >= $start) {
                 $monthly[] = $track['grade'];
             }
             $performance['tracking'][] = $track;
         }
     }
     return array('performance' => $performance, 'monthly' => $monthly);
 }