Example #1
0
 public function viewAction($index)
 {
     $this->response->setHeader("Content-Type", "text/html; charset=utf-8");
     $test = Test::findFirst(array("t_id=:t_id:", "bind" => array("t_id" => $index)));
     $students = $test->getStudent();
     $done = 0;
     foreach ($students as $student) {
         $done += $student->status;
     }
     $sum = count($students);
     $this->view->setVar("notdone", $sum - $done);
     $this->view->setVar("sum", $sum);
     $this->view->setVar("test_id", $index);
     $this->view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_ACTION_VIEW);
 }
Example #2
0
 public function surveyAction()
 {
     $this->assets->collection("header")->addJs("lib/stickUp.min.js");
     // $this->view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_AFTER_TEMPLATE);
     if ($this->request->isGet()) {
         $isfirst = $this->request->get("isfirst");
         if ($isfirst == 1) {
             $this->session->set("p_start", strtotime(date("Y-m-d H:i:s")));
             $test_id = $this->session->get("test_id");
             $test = Test::findFirst(array("t_id=:t_id:", "bind" => array("t_id" => $test_id)));
             $parts = array();
             foreach ($test->Part as $index => $part) {
                 $parts[$index] = $part->p_id;
             }
             $part_num = $this->session->get("exam_num");
             $this->session->set("parts", $parts);
             $answer_num = $this->session->get("answer_num");
             if ($answer_num != 0 && $answer_num < $part_num) {
                 $result = $this->nextpart(-1, $this->session->get("answer_num"));
             } else {
                 if ($answer_num == 0) {
                     $result = new SurveyResult();
                     $tnext = $part_num == 1 ? -1 : 1;
                     $cacheKey = $test->Part[0]->p_id . ".txt";
                     $result->description = $test->Part[0]->description;
                     $result->nextpart = $this->getquestion($test->Part[0], $cacheKey);
                     $result->resultinfo = 1;
                     $result->cur = 0;
                     $this->session->set("cur", 0);
                     $this->session->set("next", $tnext);
                     $result->next = $tnext;
                 } else {
                     $this->response->redirect("student/index");
                 }
             }
         } else {
             if ($isfirst == 2) {
                 $result = $this->nextpart($this->session->get("cur"), $this->session->get("next"));
             } else {
                 $this->response->redirect("student/index");
             }
         }
         $this->view->setVar("testinfo", $result);
     } else {
         $this->response->redirect("student/index");
     }
 }