/** * @before _secure, _school */ public function add() { $this->setSEO(array("title" => "Add Payment | School")); $view = $this->getActionView(); $grades = \Grade::all(array("organization_id = ?" => $this->organization->id), array("id", "title")); $view->set("grades", $grades); }
/** * @before _secure, _school */ public function manage() { $this->setSEO(array("title" => "School | Manage Classes")); $view = $this->getActionView(); $grades = \Grade::all(array("organization_id = ?" => $this->organization->id), array("*"), "title", "asc"); $view->set("grades", $grades); }
/** * @before _secure, _teacher */ public function manage($course_id = null) { $this->setSEO(array("title" => "Manage Your assignments | Teacher")); $view = $this->getActionView(); $where = array("user_id = ?" => $this->user->id); $fields = array("title", "created", "course_id", "classroom_id", "deadline", "live", "id"); $course_id = RequestMethods::post("course", $course_id); if ($course_id) { $assignments = \Assignment::all(array_merge($where, array("course_id = ?" => $course_id)), $fields); } else { $assignments = \Assignment::all($where, $fields); } $results = array(); $grades = Grade::all(array("organization_id = ?" => $this->organization->id), array("id", "title")); $storedGrades = array(); foreach ($grades as $g) { $storedGrades[$g->id] = $g->title; } $courses = TeacherService::$_courses; $classrooms = array(); $message = Registry::get("session")->get('$redirectMessage'); if ($message) { $view->set("message", $message); Registry::get("session")->erase('$redirectMessage'); } $notification = Registry::get("MongoDB")->notifications; foreach ($assignments as $a) { $course = $courses[$a->course_id]; $grade = $storedGrades[$course->grade_id]; if (!isset($classrooms[$a->classroom_id])) { $classroom = $classrooms[$a->classroom_id] = \Classroom::first(array("id = ?" => $a->classroom_id), array("section")); } else { $classroom = $classrooms[$a->classroom_id]; } $record = $notification->findOne(array('sender' => 'user', 'sender_id' => (int) $this->user->id, 'type' => 'assignment', 'type_id' => (int) $a->id)); if (isset($record)) { $notify = false; } else { $notify = true; } $data = array("id" => $a->id, "course" => $course->title, "title" => $a->title, "class" => $grade, "notified" => !$notify, "live" => $a->live, "section" => $classroom->section, "deadline" => $a->deadline, "created" => $a->created, "course_id" => $a->course_id, "classroom_id" => $a->classroom_id); $data = ArrayMethods::toObject($data); $results[] = $data; } $view->set("assignments", $results)->set("courses", $courses)->set("course_id", $course_id); }
/** * @before _secure, _school */ public function addToClass($user_id) { $usr = \User::first(array("id = ?" => $user_id), array("id")); if (!$usr) { self::redirect("/school"); } $this->setSEO(array("title" => "Parent Info | Student | School")); $view = $this->getActionView(); $grades = \Grade::all(array("organization_id = ?" => $this->organization->id), array("id", "title")); $enrollment = Enrollment::first(array("user_id = ?" => $user_id)); if ($enrollment) { $view->set("success", "Student has already been added! Response will be updated"); } if (RequestMethods::post("action") == "addToClass") { $classroom = Markup::checkValue(RequestMethods::post("classroom")); if (!$enrollment) { $enrollment = new Enrollment(array()); } $enrollment->user_id = $usr->id; $enrollment->classroom_id = $classroom; $enrollment->organization_id = $this->organization->id; if ($enrollment->validate()) { $enrollment->save(); $view->set("success", "Student successfully added to classroom"); } } if ($enrollment) { $class = Classroom::first(array("id = ?" => $enrollment->classroom_id), array("id", "grade_id", "section")); foreach ($grades as $g) { if ($g->id == $class->grade_id) { $grade = $g->id; break; } } $view->set("class", $class); } if (!isset($grade)) { $grade = null; } $view->set("grade", $grade); $view->set("enrollment", $enrollment); $view->set("grades", $grades); }
/** * Find all the courses to which the teacher is assigned * @before _secure, _teacher */ public function courses() { $this->setSEO(array("title" => "Manage Your Courses | Teacher")); $view = $this->getActionView(); $teaches = \Teach::all(array("user_id = ?" => $this->user->id, "live = ?" => true)); $grades = \Grade::all(array("organization_id = ?" => $this->organization->id), array("id", "title")); $storedGrades = array(); foreach ($grades as $g) { $storedGrades[$g->id] = $g; } $courses = TeacherService::$_courses; $classes = TeacherService::$_classes; $result = array(); foreach ($teaches as $t) { $grade = $storedGrades[$t->grade_id]; $class = $classes[$t->classroom_id]; $course = $courses[$t->course_id]; $asgmnt = \Assignment::count(array("course_id = ?" => $t->course_id)); $data = array("grade" => $grade->title, "grade_id" => $g->id, "section" => $class->section, "course" => $course->title, "course_id" => $course->id, "classroom_id" => $class->id, "assignments" => $asgmnt); $data = ArrayMethods::toObject($data); $result[] = $data; } $session = Registry::get("session"); if ($session->get('Notification\\Students:$sent')) { $view->set("success", "Notification sent to students"); $session->erase('Notification\\Students:$sent'); } $view->set("courses", $result); }
/** * @before _secure, _school */ public function marks() { $this->setSEO(array("title" => "View Marks | School")); $view = $this->getActionView(); $session = Registry::get("session"); $view->set("results", array()); $grades = Grade::all(array("organization_id = ?" => $this->organization->id)); if (RequestMethods::post("action") == "findStudents") { $exam = RequestMethods::post("exam"); preg_match("/(.*);(.*)/", $exam, $matches); $exam_type = $matches[1]; $exam_year = $matches[2]; $grade = RequestMethods::post("grade"); $classroom_id = RequestMethods::post("classroom_id"); /*** Stores courses in an array ***/ $courses = Course::all(array("grade_id = ?" => $grade), array("id", "title")); $setCourses = array(); foreach ($courses as $c) { $setCourses["{$c->id}"] = $c->title; } /*** Store exams in an array ***/ $exams = Exam::all(array("type = ?" => $exam_type, "grade_id = ?" => $grade)); foreach ($exams as $e) { $setExams["{$e->id}"] = array("course_id" => $e->course_id); } /*** Find all students in class and store his details in an array ***/ $users = Enrollment::all(array("classroom_id = ?" => $classroom_id)); $results = array(); foreach ($users as $u) { $usr = User::first(array("id = ?" => $u->user_id), array("name")); $scholar = Scholar::first(array("user_id = ?" => $u->user_id), array("roll_no")); $result = ExamResult::all(array("user_id = ?" => $u->user_id)); /*** We need to find marks of the all the subject ***/ $marks = array(); foreach ($result as $r) { if (!array_key_exists($r->exam_id, $setExams)) { continue; } $c_id = $setExams["{$r->exam_id}"]["course_id"]; $marks[] = array("subject" => $setCourses["{$c_id}"], "marks" => $r->marks); } $results[] = array("name" => $usr->name, "user_id" => $u->user_id, "roll_no" => $scholar->roll_no, "results" => $marks); } $session->set('Exams\\Marks:$exam', array("type" => $exam_type, "year" => $exam_year, "grade_id" => $grade)); $session->set('Exams\\Marks:$marks', ArrayMethods::toObject($marks)); $session->set('Exams\\Marks:$results', ArrayMethods::toObject($results)); } $view->set('exam', $session->get('Exams\\Marks:$exam'))->set("marks", $session->get('Exams\\Marks:$marks'))->set("results", $session->get('Exams\\Marks:$results'))->set("grades", $grades); }
public function create() { // Get grades $grades = []; foreach (Grade::all() as $i) { $grades[] = $i->getValues(); } // Get Schools $schools = []; foreach (School::all() as $i) { $schools[] = $i->getValues(); } include_once 'views/student/create.php'; }