Example #1
0
 /**
  * @before _secure, _teacher
  */
 public function create($course_id, $classroom_id)
 {
     $teach = \Teach::first(array("course_id = ?" => $course_id, "user_id = ?" => $this->user->id));
     if (!$teach || $teach->classroom_id != $classroom_id) {
         self::redirect("/teacher");
     }
     $this->setSEO(array("title" => "Teacher | Create Assignments"));
     $view = $this->getActionView();
     $grade = Grade::first(array("id = ?" => $teach->grade_id), array("title", "id"));
     $classroom = Classroom::first(array("id = ?" => $classroom_id), array("section", "id"));
     $view->set("grade", $grade);
     $view->set("classroom", $classroom);
     if (RequestMethods::post("action") == "assignment") {
         $headers = getallheaders();
         $attachment = $this->_upload("attachment", "assignments");
         $assignment = new \Assignment(array("title" => RequestMethods::post("title"), "description" => RequestMethods::post("description"), "deadline" => RequestMethods::post("deadline"), "user_id" => $this->user->id, "organization_id" => $this->organization->id, "classroom_id" => $classroom_id, "course_id" => $course_id, "attachment" => $attachment));
         if (!$assignment->validate()) {
             $view->set("success", "Invalid Request");
             return;
         }
         $assignment->save();
         $view->set("success", "Assignment Created successfully!!");
     }
 }
Example #2
0
 /**
  * @todo move to services
  * Grade the students for each week
  * @before _secure, _teacher
  */
 public function weeklyStudentsPerf($course_id, $classroom_id)
 {
     $this->setSEO(array("title" => "Grade Students Weekly Performance | Teacher"));
     $view = $this->getActionView();
     $session = Registry::get("session");
     if (!$course_id || !$classroom_id) {
         self::redirect("/404");
     }
     $teach = Teach::first(array("course_id = ?" => $course_id, "classroom_id = ?" => $classroom_id, "user_id = ?" => $this->user->id));
     if (!$teach) {
         self::redirect("/404");
     }
     $service = new Shared\Services\Classroom();
     $return = $service->weeklyPerformance($teach);
     $view->set($return);
     $classroom = TeacherService::$_classes[$teach->classroom_id];
     $course = TeacherService::$_courses[$teach->course_id];
     $enrollments = $service->enrollments($classroom, array('table' => 'performance', 'teach' => $teach));
     $scale = array();
     for ($i = 1; $i <= 10; $i++) {
         $scale[] = $i;
     }
     $view->set(array("students" => $enrollments, "class" => $classroom->grade . " - " . $classroom->section, "course" => $course->title, "scale" => $scale));
 }