protected static function _init() { $session = Registry::get("session"); if (!self::$_classroom) { if (!$session->get('StudentService:$classroom')) { $enrollment = \Enrollment::first(array("user_id = ?" => self::$_student->user_id), array("classroom_id")); $c = \Classroom::first(array("id = ?" => $enrollment->classroom_id), array("grade_id", "section", "year", "id", "created")); $g = \Grade::first(array("id = ?" => $c->grade_id), array("title", "id")); $classroom = array("id" => $c->id, "grade" => $g->title, "grade_id" => $g->id, "section" => $c->section, "year" => $c->year, "created" => $c->created); $classroom = ArrayMethods::toObject($classroom); $session->set('StudentService:$classroom', $classroom); } self::$_classroom = $session->get('StudentService:$classroom'); } if (!self::$_courses) { if (!$session->get('StudentService:$courses')) { $courses = \Course::all(array("grade_id = ?" => self::$_classroom->grade_id)); $subject = array(); foreach ($courses as $c) { $subject[$c->id] = $c; } $session->set('StudentService:$courses', $subject); } self::$_courses = $session->get('StudentService:$courses'); } }
public function __construct($options = array()) { parent::__construct($options); $this->noview(); if (!self::$_collection) { $mongo = Registry::get("MongoDB"); self::$_collection = $mongo->selectCollection("attendance"); } }
protected static function _findClasses($teaches) { $class_ids = array(); foreach ($teaches as $t) { $class_ids[] = $t->classroom_id; } $class_ids = array_unique($class_ids); $classes = array(); foreach ($class_ids as $key => $value) { $k = \Classroom::first(array("id = ?" => $value)); $g = \Grade::first(array("id = ?" => $k->grade_id)); $data = array("id" => $k->id, "grade_id" => $g->id, "grade" => $g->title, "section" => $k->section, "year" => $k->year, "educator_id" => $k->educator_id); $classes[$k->id] = ArrayMethods::toObject($data); } return $classes; }