Exemplo n.º 1
0
 public function get_student_test_queue_all($task_set_id, $student_id)
 {
     $task_set = new Task_set();
     $task_set->get_by_id((int) $task_set_id);
     $student = new Student();
     $student->get_by_id((int) $student_id);
     $test_queue = new Test_queue();
     if ($task_set->exists() && $student->exists()) {
         $test = new Test();
         $test->select_func('COUNT', array('@id'), 'tests_count');
         $test->where_related('test_queue', 'id', '${parent}.id');
         $test_queue->select('*');
         //$test_queue->select_func('COUNT', array('@test/id'), 'tests_count');
         $test_queue->select_subquery($test, 'tests_count');
         $test_queue->where_related($task_set);
         $test_queue->where_related($student);
         $test_queue->order_by('status', 'desc');
         $test_queue->order_by('finish', 'desc');
         $test_queue->order_by('start', 'asc');
         $test_queue->get_iterated();
     }
     //$test_queue->check_last_query();
     $this->load->helper('tests');
     $test_types = get_all_supported_test_types();
     $this->parser->parse('backend/tests/get_student_test_queue_all.tpl', array('test_queue' => $test_queue, 'task_set' => $task_set, 'student' => $student, 'test_types' => $test_types));
 }
Exemplo n.º 2
0
 public function test_result($test_queue_id)
 {
     $this->usermanager->student_login_protected_redirect();
     $this->parser->add_css_file('frontend_tasks.css');
     $test_queue = new Test_queue();
     $test_queue->where_related('student', 'id', $this->usermanager->get_student_id());
     $test_queue->include_related('task_set');
     $test_queue->include_related('task_set/course');
     $test_queue->include_related('task_set/course/period');
     $test_queue->get_by_id((int) $test_queue_id);
     $tasks = new Task();
     if ($test_queue->exists()) {
         $tasks->distinct();
         $tasks->where_related('task_set', 'id', $test_queue->task_set_id);
         $tasks->order_by('task_task_set_rel.sorting', 'asc');
         $tasks->get_iterated();
         $tests = $test_queue->test->include_join_fields()->order_by('id', 'asc')->get_iterated();
         $tests_per_task = array();
         $overlays_tests = array();
         foreach ($tests as $test) {
             $test_line = array('id' => $test->id, 'name' => $test->name, 'task_id' => $test->task_id, 'result' => $test->join_result, 'result_text' => $test->join_result_text, 'percent_points' => $test->join_percent_points, 'percent_bonus' => $test->join_percent_bonus, 'points' => $test->join_points, 'bonus' => $test->join_bonus, 'evaluation_table' => is_null($test->join_evaluation_table) ? array() : unserialize($test->join_evaluation_table));
             $overlays_tests[] = $test->id;
             $tests_per_task[$test->task_id][] = $test_line;
         }
         $this->lang->init_overlays('tests', $overlays_tests, array('name'));
         $this->parser->assign('tests_per_task', $tests_per_task);
     }
     $this->load->helper('tests');
     $test_types = get_all_supported_test_types();
     $this->parser->parse('frontend/tasks/test_result.tpl', array('test_queue' => $test_queue, 'tasks' => $tasks, 'test_types' => $test_types));
 }
Exemplo n.º 3
0
 public function reset_all()
 {
     echo 'Reseting old tests that may be freezed.' . PHP_EOL;
     $this->db->query('SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;');
     $this->db->trans_start();
     $test_queue = new Test_queue();
     $test_queue->where('status', 1);
     $test_queue->get_iterated();
     if ($test_queue->result_count() > 0) {
         echo 'Found ' . $test_queue->result_count() . ' old tests.' . PHP_EOL;
         foreach ($test_queue as $single_test) {
             $tests = $single_test->test->get_iterated();
             foreach ($tests as $test) {
                 $set = array('result' => 0, 'result_text' => NULL, 'percent_points' => 0, 'percent_bonus' => 0, 'points' => 0, 'bonus' => 0, 'evaluation_table' => NULL);
                 $this->db->set($set);
                 $this->db->where('test_id', $test->id);
                 $this->db->where('test_queue_id', $single_test->id);
                 $this->db->update('test_test_queue_rel');
             }
             $single_test->status = 0;
             $single_test->worker = NULL;
             $single_test->save();
         }
         echo 'All old tests were reset.' . PHP_EOL;
     } else {
         echo 'Nothing found.' . PHP_EOL;
     }
     $this->db->trans_complete();
 }