コード例 #1
0
ファイル: student.php プロジェクト: SwiftSchool/School
 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');
     }
 }
コード例 #2
0
ファイル: student.php プロジェクト: SwiftSchool/School
 /**
  * @before _secure, _school
  */
 public function remove($user_id)
 {
     $this->noview();
     $sub = Registry::get("MongoDB")->submission;
     $scholar = Scholar::first(array("user_id = ?" => $user_id));
     if (!$scholar || $scholar->organization_id != $this->organization->id) {
         self::redirect("/404");
     }
     $user = User::first(array("id = ?" => $user_id));
     if (!$user) {
         self::redirect("/404");
     }
     $enrollment = Enrollment::first(array("user_id = ?" => $user->id));
     $submissions = $sub->find(array("user_id" => (int) $user->id));
     $examResults = ExamResult::all(array("user_id = ?" => $user->id));
     foreach ($examResults as $r) {
         // $r->delete();
     }
     foreach ($submissions as $s) {
         // $s->remove();
     }
     // $enrollment->delete();
     // $user->delete();
     // $scholar->delete();
     self::redirect($_SERVER['HTTP_REFERER']);
 }