Esempio n. 1
0
 public function executeCustom(sfWebRequest $request)
 {
     $this->form = new ExamForm(new Exam());
     if ($request->hasParameter("course") && $request->hasParameter("year") && $request->hasParameter("term")) {
         // find the course and the semester in question
         $courseId = $request->getParameter("course");
         $fuzSearch = new fuzzySearch();
         try {
             $fuzSearch->query($courseId);
             $_res = $fuzSearch->getCourseList();
             if ($_res === null || count($_res) != 1) {
                 return sfView::SUCCESS;
             }
         } catch (Exception $e) {
             return sfView::SUCCESS;
         }
         $this->courseId = $_res[0]->getId();
         $year = $request->getParameter("year");
         $term = $request->getParameter("term");
         $this->year = $year . $term;
         if ($request->hasParameter("id")) {
             $this->redirect("adminexam/edit?id=" . $request->getParameter("id") . "&course=" . $this->courseId . "&year=" . $year . "&term=" . $term);
         }
         $this->examList = $this->getExamList($this->courseId, $this->year);
         $this->form->setDefault("year", $year);
         $this->form->setDefault("term", $term);
     }
 }
Esempio n. 2
0
 /**
  * The true index of course commenting editor page
  * @param sfWebRequest $request
  */
 public function executeCoursecommenting(sfWebRequest $request)
 {
     $this->form = new CourseCommentForm();
     if ($request->hasParameter("course")) {
         // find the course and the semester in question
         $courseId = $request->getParameter("course");
         $fuzSearch = new fuzzySearch();
         try {
             $fuzSearch->query($courseId);
             $_res = $fuzSearch->getCourseList();
             if ($_res === null || count($_res) != 1) {
                 return sfView::SUCCESS;
             }
         } catch (Exception $e) {
             return sfView::SUCCESS;
         }
         $this->courseId = $_res[0]->getId();
         if ($request->hasParameter("id")) {
             $this->redirect("admincommenting/editCourse?id=" . $request->getParameter("id") . "&course=" . $this->courseId);
         }
         $this->commentList = $this->getCourseList($this->courseId);
     }
 }
Esempio n. 3
0
 public function executeFuzzySearch(sfWebRequest $request)
 {
     if (!$request->hasParameter("query")) {
         $this->forward("search", "index");
     }
     $conn = Propel::getConnection();
     $query = $request->getParameter("query");
     $this->query = $query;
     $fuzzySearch = new fuzzySearch();
     try {
         $fuzzySearch->query($query, $conn);
     } catch (Exception $e) {
         $this->error = $e->getMessage();
         return;
     }
     $countCourseList = count($fuzzySearch->getCourseList());
     $countInstrList = count($fuzzySearch->getInstructorList());
     $countProgList = count($fuzzySearch->getProgramList());
     if ($countCourseList + $countInstrList + $countProgList < 1) {
         $this->error = "No result found.";
     } else {
         if ($countCourseList == 1) {
             $list = $fuzzySearch->getCourseList();
             $this->redirect("course/index?id=" . $list[0]->getId());
         } else {
             $this->courseList = $fuzzySearch->getCourseList();
             $this->instructorList = $fuzzySearch->getInstructorList();
             $this->programList = $fuzzySearch->getProgramList();
         }
     }
 }
Esempio n. 4
0
 /**
  * Return a list of courses in <li></li> format
  * Must be called in an Ajax request
  * Requires the existence of addToSelected javascript method on client
  */
 public function executeAjaxSearch(sfWebRequest $request)
 {
     if (!$request->isXmlHttpRequest()) {
         $this->forward404();
     }
     if (!$request->hasParameter("ajax_query")) {
         throw new Exception("ajax_query does not exist");
     }
     // use fuzzySearch class to get a list of courses matching the query
     $query = $request->getParameter("ajax_query");
     $fuzzySearch = new fuzzySearch();
     try {
         $fuzzySearch->query($query);
         $courseList = $fuzzySearch->getCourseList();
     } catch (Exception $e) {
         echo "<li>No match found</li>";
         return sfView::NONE;
     }
     if (!isset($courseList) || count($courseList) == 0) {
         echo "<li>No match found</li>";
     } else {
         foreach ($courseList as $course) {
             echo "<li><a style='cursor:pointer' onclick='addToSelected(\"" . $course->getId() . " (" . $course->getDescr() . ")" . "\")'>" . $course->getId() . " (" . $course->getDescr() . ")</a></li>";
         }
     }
     return sfView::NONE;
 }