Beispiel #1
0
 /**
  * Delete this object from database or specified relations.
  * If this object is deleted, all student files will be deleted as well.
  * @param DataMapper|string $object related object to delete from relation.
  * @param string $related_field relation internal name.
  */
 public function delete($object = '', $related_field = '')
 {
     $this_id = $this->id;
     $this_task_set_id = $this->task_set_id;
     $this_student_id = $this->student_id;
     parent::delete($object, $related_field);
     if (empty($object) && !is_array($object) && !empty($this_id)) {
         $task_set = new Task_set();
         $task_set->get_by_id($this_task_set_id);
         if ($task_set->exists()) {
             $student_files = $task_set->get_student_files($this_student_id);
             if (count($student_files) > 0) {
                 foreach ($student_files as $file) {
                     @unlink($file['filepath']);
                 }
             }
         }
     }
 }
Beispiel #2
0
 public function insert_to_task_set()
 {
     $this->load->library('form_validation');
     $task_set_id = intval($this->input->post('task_set_id'));
     $this->_transaction_isolation();
     $this->db->trans_begin();
     $task_set = new Task_set();
     $task_set->get_by_id($task_set_id);
     $this->form_validation->set_rules('task_id', 'task_id', 'required');
     $this->form_validation->set_rules('task_set_id', 'task_set_id', 'required');
     if ($task_set->exists()) {
         if ($task_set->content_type == 'task_set') {
             $this->form_validation->set_rules('points_total', 'lang:admin_tasks_add_to_task_set_form_field_points_total', 'required|number|greater_than_equal[0]');
             $this->form_validation->set_rules('test_max_points', 'lang:admin_tasks_add_to_task_set_form_field_test_max_points', 'required|number|greater_than_equal[0]');
             $this->form_validation->set_rules('test_min_points', 'lang:admin_tasks_add_to_task_set_form_field_test_min_points', 'required|number|less_than_field_or_equal[test_max_points]');
         } else {
             $this->form_validation->set_rules('max_projects_selections', 'lang:admin_tasks_add_to_task_set_form_field_max_projects_selections', 'required|integer|greater_than[0]');
         }
     }
     if ($this->form_validation->run()) {
         $task_id = intval($this->input->post('task_id'));
         $points_total = floatval($this->input->post('points_total'));
         $test_max_points = floatval($this->input->post('test_max_points'));
         $test_min_points = floatval($this->input->post('test_min_points'));
         $bonus_task = (int) (bool) intval($this->input->post('bonus_task'));
         $max_projects_selections = intval($this->input->post('max_projects_selections'));
         $internal_comment = $this->input->post('internal_comment');
         $task = new Task();
         $task->get_by_id($task_id);
         if (!$task->exists()) {
             $this->db->trans_rollback();
             $this->messages->add_message('lang:admin_tasks_error_message_task_not_found', Messages::MESSAGE_TYPE_ERROR);
         } elseif (!$task_set->exists()) {
             $this->db->trans_rollback();
             $this->messages->add_message('lang:admin_tasks_add_to_task_set_nothing_opened', Messages::MESSAGE_TYPE_ERROR);
         } elseif ($task_set->is_related_to($task)) {
             $this->db->trans_rollback();
             $this->messages->add_message('lang:admin_tasks_add_to_task_set_already_related', Messages::MESSAGE_TYPE_ERROR);
         } else {
             $related_task = $task_set->task->include_join_fields()->order_by('join_sorting', 'desc')->limit(1)->get();
             $new_sorting = $related_task->exists() ? intval($related_task->join_sorting) + 1 : 1;
             $task_set->save($task);
             $task_set->set_join_field($task, 'points_total', $points_total);
             $task_set->set_join_field($task, 'test_max_points', $test_max_points);
             $task_set->set_join_field($task, 'test_min_points', $test_min_points);
             $task_set->set_join_field($task, 'sorting', $new_sorting);
             $task_set->set_join_field($task, 'bonus_task', $bonus_task);
             $task_set->set_join_field($task, 'max_projects_selections', $max_projects_selections);
             $task_set->set_join_field($task, 'internal_comment', $internal_comment);
             if ($this->db->trans_status()) {
                 $this->db->trans_commit();
                 $this->messages->add_message('lang:admin_tasks_add_to_task_set_save_success', Messages::MESSAGE_TYPE_SUCCESS);
                 $this->_action_success();
             } else {
                 $this->db->trans_rollback();
                 $this->messages->add_message('lang:admin_tasks_add_to_task_set_save_failed', Messages::MESSAGE_TYPE_ERROR);
             }
         }
         redirect(create_internal_url('admin_tasks/add_to_task_set/task_id/' . $task_id));
     } else {
         $this->db->trans_rollback();
         $this->add_to_task_set();
     }
 }
 public function delete_permission($task_set_id, $task_set_permission_id)
 {
     $output = new stdClass();
     $output->result = FALSE;
     $output->message = '';
     $this->_transaction_isolation();
     $this->db->trans_begin();
     $task_set = new Task_set();
     $task_set->get_by_id((int) $task_set_id);
     $task_set_permission = new Task_set_permission();
     $task_set_permission->get_by_id((int) $task_set_permission_id);
     if ($task_set->exists() && !is_null($task_set->course_id)) {
         if ($task_set_permission->exists() && $task_set_permission->is_related_to($task_set)) {
             $task_set_permission->delete();
             if ($this->db->trans_status()) {
                 $this->db->trans_commit();
                 $output->result = TRUE;
                 $output->message = $this->lang->line('admin_task_set_permissions_success_message_deleted');
                 $this->_action_success();
             } else {
                 $this->db->trans_rollback();
                 $output->message = $this->lang->line('admin_task_set_permissions_error_message_delete_error');
             }
         } else {
             $this->db->trans_rollback();
             $output->message = $this->lang->line('admin_task_set_permissions_error_message_cant_find_task_set_permission_or_is_not_related_to_task_set');
         }
     } else {
         $this->db->trans_rollback();
         $output->message = $this->lang->line('lang:admin_task_set_permissions_error_message_cant_find_task_set_or_course');
     }
     $this->output->set_content_type('application/json');
     $this->output->set_output(json_encode($output));
 }
Beispiel #4
0
 public function send_deadline_notifications($lang_idiom = NULL)
 {
     $this->load->database();
     $this->load->model('translations');
     if (!is_null($lang_idiom)) {
         $this->lang->reinitialize_for_idiom($lang_idiom);
     }
     $translations = $this->translations->get_translations_for_idiom($this->lang->get_current_idiom());
     $this->lang->add_custom_translations($translations);
     $this->lang->load('cli');
     $current_time = Date('Y-m-d H:i:s');
     $one_day_back_time = Date('Y-m-d H:i:s', strtotime('now -1 day'));
     $task_sets1 = new Task_set();
     $task_sets1->select('id, name, course_id, group_id AS common_group_id, upload_end_time AS common_upload_end_time, deadline_notified AS common_deadline_notified, deadline_notification_emails AS common_deadline_notification_emails, deadline_notification_emails_handler AS common_deadline_notification_emails_handler');
     $task_sets1->select('null AS `task_set_permission_id`', FALSE);
     $task_sets1->where('deadline_notified', 0);
     $task_sets1->where('deadline_notification_emails_handler >', 0);
     $task_sets1->group_start();
     $task_sets1->not_group_start();
     $task_sets1->where('upload_end_time', NULL);
     $task_sets1->group_end();
     $task_sets1->where('upload_end_time <', $current_time);
     $task_sets1->where('upload_end_time >=', $one_day_back_time);
     $task_sets1->group_end();
     $task_sets1->where_subquery(0, '(SELECT COUNT(`tsp`.`id`) AS `count` FROM `task_set_permissions` tsp WHERE `tsp`.`task_set_id` = `task_sets`.`id` AND `tsp`.`enabled` = 1)');
     $task_sets1->where('published', 1);
     $task_sets2 = new Task_set();
     $task_sets2->select('id, name, course_id');
     $task_sets2->include_related('task_set_permission', 'group_id', 'common');
     $task_sets2->include_related('task_set_permission', 'upload_end_time', 'common');
     $task_sets2->include_related('task_set_permission', 'deadline_notified', 'common');
     $task_sets2->include_related('task_set_permission', 'deadline_notification_emails', 'common');
     $task_sets2->include_related('task_set_permission', 'deadline_notification_emails_handler', 'common');
     $task_sets2->include_related('task_set_permission', 'id');
     $task_sets2->where_related('task_set_permission', 'enabled', 1);
     $task_sets2->where_related('task_set_permission', 'deadline_notified', 0);
     $task_sets2->where_related('task_set_permission', 'deadline_notification_emails_handler >', 0);
     $task_sets2->group_start();
     $task_sets2->not_group_start();
     $task_sets2->where_related('task_set_permission', 'upload_end_time', NULL);
     $task_sets2->group_end();
     $task_sets2->where_related('task_set_permission', 'upload_end_time <', $current_time);
     $task_sets2->where_related('task_set_permission', 'upload_end_time >=', $one_day_back_time);
     $task_sets2->group_end();
     $task_sets2->where('published', 1);
     $task_sets1->union_iterated($task_sets2, TRUE);
     $this->load->library('email');
     $sent_notifications = 0;
     foreach ($task_sets1 as $task_set) {
         if ($task_set->common_deadline_notification_emails_handler > 0) {
             $emails = trim($task_set->common_deadline_notification_emails) != '' ? explode(',', $task_set->common_deadline_notification_emails) : array();
             array_walk($emails, function (&$email, $key) {
                 $email = trim($email);
             });
             if ($task_set->common_deadline_notification_emails_handler == 1) {
                 $groups = new Group();
                 $groups->where_related('course', 'id', $task_set->course_id);
                 $groups->include_related('room/teacher', '*');
                 $groups->group_start('NOT');
                 $groups->where_related('room', 'id', null);
                 $groups->or_where_related('room/teacher', 'id', null);
                 $groups->group_end();
                 $groups->group_by_related('room/teacher', 'email');
                 if (!is_null($task_set->common_group_id)) {
                     $groups->where('id', $task_set->common_group_id);
                 }
                 $groups->get_iterated();
                 foreach ($groups as $teacher) {
                     if (trim($teacher->room_teacher_email) != '') {
                         $email = trim($teacher->room_teacher_email);
                         if (!in_array($email, $emails)) {
                             $emails[] = $email;
                         }
                     }
                 }
             }
             $group = new Group();
             if (!is_null($task_set->common_group_id)) {
                 $group->get_by_id((int) $task_set->common_group_id);
             }
             if (count($emails)) {
                 $this->email->from_system();
                 $this->email->reply_to_system();
                 $this->email->build_message_body('file:emails/cli/deadline_notification.tpl', array('task_set' => $task_set, 'group' => $group));
                 if ($this->config->item('email_multirecipient_batch_mode')) {
                     $this->email->to($emails);
                     $this->email->subject('LIST: ' . $this->lang->line('cli_deadline_notification_subject'));
                     $this->email->send();
                 } else {
                     foreach ($emails as $email) {
                         $this->email->to($email);
                         $this->email->subject('TEST');
                         $this->email->send();
                     }
                 }
                 $sent_notifications++;
                 if (!is_null($task_set->task_set_permission_id)) {
                     $task_set_permission = new Task_set_permission();
                     $task_set_permission->get_by_id($task_set->task_set_permission_id);
                     if ($task_set_permission->exists()) {
                         $task_set_permission->deadline_notified = 1;
                         $task_set_permission->save();
                     }
                 } else {
                     $task_set_update = new Task_set();
                     $task_set_update->get_by_id($task_set->id);
                     if ($task_set_update->exists()) {
                         $task_set_update->deadline_notified = 1;
                         $task_set_update->save();
                     }
                 }
             }
         }
     }
     echo "Process finished, {$sent_notifications} notifications were sent ...\n";
 }
Beispiel #5
0
 private function inject_batch_valuation($task_set_id)
 {
     $filter = $this->input->post('filter');
     $filter = is_array($filter) && count($filter) > 0 ? $filter : $this->get_batch_valuation_filter((int) $task_set_id);
     $this->store_batch_valuation_filter($filter, (int) $task_set_id);
     $task_set = new Task_set();
     $task_set->get_by_id($task_set_id);
     $task_set_permissions = new Task_set_permission();
     $task_set_permissions->where_related($task_set);
     $task_set_permissions->where('enabled', 1);
     $task_set_permissions->get_iterated();
     $solutions = new Solution();
     $solutions->where_related($task_set);
     $solutions->group_by('student_id');
     if (isset($filter['group']) && (int) $filter['group'] > 0) {
         $solutions->where_related('student/participant/group', 'id', (int) $filter['group']);
     }
     $solutions->get_iterated();
     $additional_student_ids = array(0);
     foreach ($solutions as $solution) {
         $additional_student_ids[] = $solution->student_id;
     }
     $data = array();
     if ($task_set->exists()) {
         $students = new Student();
         $students->where_related('participant', 'allowed', 1);
         $students->where_related('participant/course/task_set', 'id', intval($task_set_id));
         if ($task_set_permissions->result_count() == 0) {
             if (!is_null($task_set->group_id)) {
                 $students->where_related('participant/group', 'id', intval($task_set->group_id));
             }
         } else {
             $group_ids = array();
             foreach ($task_set_permissions as $task_set_permission) {
                 $group_ids[] = (int) $task_set_permission->group_id;
             }
             $students->where_in_related('participant/group', 'id', $group_ids);
         }
         $students->include_related('solution');
         $students->add_join_condition('`solutions`.`task_set_id` = ?', array($task_set->id));
         $students->order_by_as_fullname('fullname', 'asc');
         $students->order_by('email', 'asc');
         if (isset($filter['group']) && (int) $filter['group'] > 0) {
             $students->where_related('participant/group', 'id', (int) $filter['group']);
         }
         $students->or_where_in('id', $additional_student_ids);
         $students->get_iterated();
         foreach ($students as $student) {
             $data[$student->id] = clone $student;
         }
     }
     $this->parser->assign('batch_valuation_students', $data);
 }
Beispiel #6
0
 public function run_comparation()
 {
     $task_sets_setup_data = $this->input->post('task_sets_setup');
     $solutions_data = $this->input->post('solutions');
     $comparator_setup_data = $this->input->post('comparator_setup');
     $course = new Course();
     $course->get_by_id((int) $task_sets_setup_data['course']);
     $task_set = new Task_set();
     $task_set->where_related($course);
     $task_set->get_by_id(isset($task_sets_setup_data['task_set']) ? (int) $task_sets_setup_data['task_set'] : 0);
     $this->parser->assign(array('course' => $course, 'task_set' => $task_set));
     if ($course->exists() && $task_set->exists()) {
         $this->load->library('form_validation');
         $this->form_validation->set_rules('solutions', 'lang:admin_comparator_list_solutions_form_field_solution_selection', 'callback__selected_solutions');
         $this->form_validation->set_rules('comparator_setup[threshold]', 'lang:admin_comparator_list_solutions_form_field_threshold', 'required|numeric|greater_than_equal[0]|less_than_equal[1]');
         $this->form_validation->set_rules('comparator_setup[min_tree_size]', 'lang:admin_comparator_list_solutions_form_field_min_tree_size', 'required|integer|greater_than_equal[1]');
         $this->form_validation->set_rules('comparator_setup[max_cutted_tree_size]', 'lang:admin_comparator_list_solutions_form_field_max_cutted_tree_size', 'required|integer|greater_than_field_or_equal[comparator_setup[min_tree_size]]');
         $this->form_validation->set_rules('comparator_setup[branching_factor]', 'lang:admin_comparator_list_solutions_form_field_branching_factor', 'required|integer|greater_than_equal[1]');
         $this->form_validation->set_rules('comparator_setup[min_similarity]', 'lang:admin_comparator_list_solutions_form_field_minimum_similarity', 'required|numeric|greater_than_equal[0]|less_than_equal[1]');
         $this->form_validation->set_rules('comparator_setup[timeout]', 'lang:admin_comparator_list_solutions_form_field_timeout', 'required|integer|greater_than_equal[1]');
         $this->form_validation->set_message('_selected_solutions', $this->lang->line('admin_comparator_list_solutions_validation_callback_selected_solutions'));
         if ($this->form_validation->run()) {
             $solutions = new Solution();
             $solutions->include_related('student');
             $solutions->where_related($task_set);
             $solutions->order_by_related_as_fullname('student', 'fullname', 'asc');
             $solutions->get_iterated();
             $this->parser->assign('solutions', $solutions);
             $path = $this->get_random_hash_folder($course->id, $task_set->id);
             $path_source = $path . '/source';
             $path_output = $path . '/output';
             @mkdir($path_source, DIR_WRITE_MODE, TRUE);
             @mkdir($path_output, DIR_WRITE_MODE, TRUE);
             $all_extracted = TRUE;
             foreach ($solutions_data as $id => $config) {
                 if (isset($config['selected']) && $config['selected'] == 1) {
                     set_time_limit(120);
                     $version = isset($config['version']) ? $config['version'] : 0;
                     $student = isset($config['student']) ? $config['student'] : 0;
                     $file = $task_set->get_student_files($student, $version);
                     if (count($file) == 1) {
                         $file = $file[$version];
                         $subdir = '/' . normalize($file['file_name']) . '_sid-' . $file['student_id'] . '_ver-' . $file['version'];
                         $extract_path = $path_source . $subdir;
                         @mkdir($extract_path, DIR_WRITE_MODE, TRUE);
                         $status = $task_set->extract_student_zip_to_folder($file['file'], $extract_path, array('java'));
                         $all_extracted = $all_extracted && $status;
                     }
                 }
             }
             if (!$all_extracted) {
                 unlink_recursive($path, TRUE);
             }
             $this->parser->assign('all_extracted', $all_extracted);
             $this->parser->assign('path', $path);
             $this->parser->assign('comparator_config', array('t' => $comparator_setup_data['threshold'], 'm' => $comparator_setup_data['min_tree_size'], 'cut' => $comparator_setup_data['max_cutted_tree_size'], 'bf' => $comparator_setup_data['branching_factor'], 'mp' => $comparator_setup_data['min_similarity'], 'timeout' => $comparator_setup_data['timeout'] * 60000));
             $this->parser->parse('backend/comparator/run_comparation.tpl');
         } else {
             $this->list_solutions();
         }
     } else {
         $this->list_solutions();
     }
 }
Beispiel #7
0
 public function run_comparation()
 {
     $task_sets_setup_data = $this->input->post('task_sets_setup');
     $solutions_data = $this->input->post('solutions');
     $moss_setup_data = $this->input->post('moss_setup');
     $moss_base_files_data = $this->input->post('moss_base_files');
     $course = new Course();
     $course->get_by_id((int) $task_sets_setup_data['course']);
     $task_set = new Task_set();
     $task_set->where_related($course);
     $task_set->get_by_id(isset($task_sets_setup_data['task_set']) ? (int) $task_sets_setup_data['task_set'] : 0);
     $this->config->load('moss');
     $languages = $this->config->item('moss_langs_for_list');
     asort($languages);
     $this->parser->assign(array('course' => $course, 'task_set' => $task_set, 'languages' => $languages));
     $this->parser->assign('moss_enabled', $this->is_moss_user_id_set());
     if ($course->exists() && $task_set->exists()) {
         $this->load->library('form_validation');
         $this->form_validation->set_rules('solutions', 'lang:admin_moss_list_solutions_form_field_solution_selection', 'callback__selected_solutions');
         $this->form_validation->set_rules('moss_setup[l]', 'lang:admin_moss_list_solutions_form_field_language', 'required');
         $this->form_validation->set_rules('moss_setup[m]', 'lang:admin_moss_list_solutions_form_field_sensitivity', 'required|integer|greater_than[1]');
         $this->form_validation->set_rules('moss_setup[n]', 'lang:admin_moss_list_solutions_form_field_matching_files', 'required|integer|greater_than[1]');
         $this->form_validation->set_message('_selected_solutions', $this->lang->line('admin_moss_list_solutions_validation_callback_selected_solutions'));
         if ($this->form_validation->run() && $this->is_moss_user_id_set()) {
             $solutions = new Solution();
             $solutions->include_related('student');
             $solutions->where_related($task_set);
             $solutions->order_by_related_as_fullname('student', 'fullname', 'asc');
             $solutions->get_iterated();
             $this->parser->assign('solutions', $solutions);
             $tasks = new Task();
             $tasks->where_related($task_set);
             $tasks->get_iterated();
             $base_files_list = array();
             foreach ($tasks as $task) {
                 $base_files_list[$task->id] = array('task_id' => $task->id, 'task_name' => $this->lang->get_overlay_with_default('tasks', $task->id, 'name', $task->name), 'files' => $this->construct_base_files_for_task($task->id));
             }
             $this->parser->assign('base_files_list', $base_files_list);
             $path = $this->get_random_hash_folder($course->id, $task_set->id);
             $path_source = $path . '/source';
             $path_base = $path . '/base';
             @mkdir($path_source, DIR_WRITE_MODE, TRUE);
             @mkdir($path_base, DIR_WRITE_MODE, TRUE);
             $all_extracted = TRUE;
             $moss_langs_extensions = $this->config->item('moss_langs_file_extensions');
             if (isset($moss_langs_extensions[$moss_setup_data['l']])) {
                 $file_extensions = $moss_langs_extensions[$moss_setup_data['l']];
             } else {
                 $all_extracted = FALSE;
             }
             foreach ($solutions_data as $id => $config) {
                 if (!$all_extracted) {
                     break;
                 }
                 if (isset($config['selected']) && $config['selected'] == 1) {
                     set_time_limit(120);
                     $version = isset($config['version']) ? $config['version'] : 0;
                     $student = isset($config['student']) ? $config['student'] : 0;
                     $file = $task_set->get_student_files($student, $version);
                     if (count($file) == 1) {
                         $file = $file[$version];
                         $subdir = '/' . normalize($file['file_name']) . '_sid-' . $file['student_id'] . '_ver-' . $file['version'];
                         $extract_path = $path_source . $subdir;
                         @mkdir($extract_path, DIR_WRITE_MODE, TRUE);
                         $status = $task_set->extract_student_zip_to_folder($file['file'], $extract_path, $file_extensions);
                         $all_extracted = $all_extracted && $status;
                     }
                 }
             }
             if (is_array($moss_base_files_data) && count($moss_base_files_data)) {
                 foreach ($moss_base_files_data as $task_id => $path_array) {
                     if (!$all_extracted) {
                         break;
                     }
                     if (is_array($path_array) && count($path_array)) {
                         foreach ($path_array as $path_hash => $file_path) {
                             if (!$all_extracted) {
                                 break;
                             }
                             if (preg_match('/\\.zip(?P<indexNumberBox>\\[(?P<zipIndexNumber>[0-9]+)\\])$/', $file_path, $matches)) {
                                 $zipfile = mb_substr($file_path, 0, mb_strlen($file_path) - mb_strlen($matches['indexNumberBox']));
                                 $zipindex = (int) $matches['zipIndexNumber'];
                                 $zip = new ZipArchive();
                                 if ($zip->open($zipfile)) {
                                     set_time_limit(120);
                                     @mkdir($path_base . '/' . $task_id . '/' . $path_hash, DIR_WRITE_MODE, TRUE);
                                     if (!$zip->extractTo($path_base . '/' . $task_id . '/' . $path_hash, $zip->getNameIndex($zipindex))) {
                                         $all_extracted = FALSE;
                                     }
                                     $zip->close();
                                 } else {
                                     $all_extracted = FALSE;
                                 }
                             } else {
                                 set_time_limit(120);
                                 @mkdir($path_base . '/' . $task_id . '/' . $path_hash, DIR_WRITE_MODE, TRUE);
                                 $path_info = pathinfo($file_path);
                                 if (!copy($file_path, $path_base . '/' . $task_id . '/' . $path_hash . '/' . $path_info['basename'])) {
                                     $all_extracted = FALSE;
                                 }
                             }
                         }
                     }
                 }
             }
             if (!$all_extracted) {
                 unlink_recursive($path, TRUE);
             }
             $this->parser->assign('all_extracted', $all_extracted);
             $this->parser->assign('path', $path);
             $this->parser->assign('moss_config', $moss_setup_data);
             $this->parser->parse('backend/moss/run_comparation.tpl');
         } else {
             $this->list_solutions();
         }
     }
 }
Beispiel #8
0
 public function details($log_id)
 {
     $log = new Log();
     $log->include_related('student');
     $log->include_related('teacher');
     $log->get_by_id($log_id);
     if ($log->exists()) {
         if ($log->log_type == Log::LOG_TYPE_STUDENT_SOLUTION_UPLOAD || $log->log_type == Log::LOG_TYPE_TEACHER_SOLUTION_UPLOAD) {
             $solution = new Solution();
             $solution->include_related('student');
             $solution->include_related('task_set');
             $solution->include_related('task_set/course');
             $solution->include_related('task_set/course/period');
             $solution->get_by_id((int) $log->affected_row_primary_id);
             $this->parser->assign('solution', $solution);
         } elseif ($log->log_type == Log::LOG_TYPE_STUDENT_SOLUTION_DOWNLOAD) {
             $additional_data = unserialize($log->additional_data);
             $task_set = new Task_set();
             $task_set->include_related('course');
             $task_set->include_related('course/period');
             $task_set->get_by_id(@$additional_data['task_set_id']);
             $this->parser->assign(array('task_set' => $task_set, 'filename' => @$additional_data['solution_file']));
         }
     }
     $this->parser->add_css_file('admin_logs.css');
     $this->parser->parse('backend/logs/details.tpl', array('log' => $log));
 }
Beispiel #9
0
 private function add_comment($task_set_id, $reply_at_id = NULL)
 {
     $comment_data = $this->input->post('comment');
     if (isset($comment_data['task_set_id']) && $comment_data['task_set_id'] == $task_set_id) {
         $this->_transaction_isolation();
         $this->db->trans_begin();
         $task_set = new Task_set();
         $task_set->get_by_id($task_set_id);
         if ($task_set->exists()) {
             if ((bool) $task_set->comments_enabled) {
                 $save_array = array();
                 $save_array['task_set'] = $task_set;
                 if (isset($comment_data['reply_at_id']) && $comment_data['reply_at_id'] == $reply_at_id) {
                     $reply_at = new Comment();
                     $reply_at->get_by_id($reply_at_id);
                     if ($reply_at->exists()) {
                         if ($reply_at->task_set_id == $task_set_id) {
                             $save_array['reply_at'] = $reply_at;
                         } else {
                             $this->db->trans_rollback();
                             $this->messages->add_message('lang:admin_task_sets_comments_error_reply_at_comment_from_different_task_set', Messages::MESSAGE_TYPE_ERROR);
                             return;
                         }
                     } else {
                         $this->db->trans_rollback();
                         $this->messages->add_message('lang:admin_task_sets_comments_error_reply_at_comment_not_exists', Messages::MESSAGE_TYPE_ERROR);
                         return;
                     }
                 }
                 $teacher = new Teacher();
                 $teacher->get_by_id($this->usermanager->get_teacher_id());
                 $save_array['teacher'] = $teacher;
                 $comment = new Comment();
                 $comment->text = strip_tags($comment_data['text'], '<a><strong><em><span>');
                 $comment->approved = 1;
                 if ($comment->save($save_array)) {
                     $this->db->trans_commit();
                     $this->messages->add_message('lang:admin_task_sets_comments_save_successfully', Messages::MESSAGE_TYPE_SUCCESS);
                     $all_students = $task_set->comment_subscriber_student;
                     $all_students->get();
                     $this->_send_multiple_emails($all_students, 'lang:admin_task_sets_comments_email_subject_new_post', 'file:emails/backend/comments/new_comment_student.tpl', array('task_set' => $task_set, 'teacher' => $teacher, 'comment' => $comment));
                     $all_teachers = $task_set->comment_subscriber_teacher;
                     $all_teachers->where('id !=', $this->usermanager->get_teacher_id());
                     $all_teachers->get();
                     $this->_send_multiple_emails($all_teachers, 'lang:admin_task_sets_comments_email_subject_new_post', 'file:emails/backend/comments/new_comment_teacher.tpl', array('task_set' => $task_set, 'teacher' => $teacher, 'comment' => $comment));
                 } else {
                     $this->db->trans_rollback();
                     $this->messages->add_message('lang:admin_task_sets_comments_error_save_failed', Messages::MESSAGE_TYPE_ERROR);
                 }
             } else {
                 $this->db->trans_rollback();
                 $this->messages->add_message('lang:admin_task_sets_comments_error_comments_disabled', Messages::MESSAGE_TYPE_ERROR);
             }
         } else {
             $this->db->trans_rollback();
             $this->messages->add_message('lang:admin_task_sets_error_task_set_not_found', Messages::MESSAGE_TYPE_ERROR);
         }
     } else {
         $this->messages->add_message('lang:admin_task_sets_error_task_set_not_found', Messages::MESSAGE_TYPE_ERROR);
     }
 }
Beispiel #10
0
 private function create_comment()
 {
     $post_data = $this->input->post('comment');
     if (array_key_exists('text', $post_data) && array_key_exists('task_set_id', $post_data) && array_key_exists('reply_at_id', $post_data)) {
         $task_set = new Task_set();
         $task_set->get_by_id(intval($post_data['task_set_id']));
         $student = new Student();
         $student->get_by_id($this->usermanager->get_student_id());
         if ($task_set->exists() && $student->exists() && (bool) $task_set->comments_enabled) {
             if (trim(strip_tags($post_data['text'])) != '') {
                 $text = strip_tags($post_data['text'], '<a><strong><em><span>');
                 $comment = new Comment();
                 $comment->text = $text;
                 $comment->approved = (bool) $task_set->comments_moderated ? 0 : 1;
                 $comment->reply_at_id = empty($post_data['reply_at_id']) ? NULL : intval($post_data['reply_at_id']);
                 $this->_transaction_isolation();
                 $this->db->trans_begin();
                 if ($comment->save(array($task_set, $student))) {
                     $this->db->trans_commit();
                     $this->messages->add_message('lang:tasks_comments_message_comment_post_success_save', Messages::MESSAGE_TYPE_SUCCESS);
                     if ((bool) $comment->approved) {
                         $all_students = $task_set->comment_subscriber_student;
                         $all_students->where('id !=', $this->usermanager->get_student_id());
                         $all_students->get();
                         $this->_send_multiple_emails($all_students, 'lang:tasks_comments_email_subject_new_post', 'file:emails/frontend/comments/new_comment_student.tpl', array('task_set' => $task_set, 'student' => $student, 'comment' => $comment));
                         $task_set_related_teachers = new Teacher();
                         if (!is_null($task_set->group_id)) {
                             $task_set_related_teachers->where_related('room/group', 'id', $task_set->group_id);
                         } else {
                             $task_set_related_teachers->where_related('room/group/course', 'id', $task_set->course_id);
                         }
                         $task_set_related_teachers->group_by('id');
                         $all_teachers = new Teacher();
                         $all_teachers->where_related('comment_subscription', 'id', $task_set->id);
                         $all_teachers->union($task_set_related_teachers, FALSE, '', NULL, NULL, 'id');
                         $all_teachers->check_last_query();
                         $this->_send_multiple_emails($all_teachers, 'lang:tasks_comments_email_subject_new_post', 'file:emails/frontend/comments/new_comment_teacher.tpl', array('task_set' => $task_set, 'student' => $student, 'comment' => $comment));
                     }
                     return TRUE;
                 } else {
                     $this->db->trans_rollback();
                     $this->messages->add_message('lang:tasks_comments_message_comment_post_error_save', Messages::MESSAGE_TYPE_ERROR);
                     return FALSE;
                 }
             } else {
                 $this->messages->add_message('lang:tasks_comments_message_comment_post_error_empty', Messages::MESSAGE_TYPE_ERROR);
                 return FALSE;
             }
         } else {
             $this->messages->add_message('lang:tasks_comments_message_not_found_or_disabled', Messages::MESSAGE_TYPE_ERROR);
             return FALSE;
         }
     } else {
         $this->messages->add_message('lang:tasks_comments_message_comment_post_error_data', Messages::MESSAGE_TYPE_ERROR);
         return FALSE;
     }
 }
Beispiel #11
0
 public function evaluate_test_result($task_set_id, $student_id, $version, $test_type, $token)
 {
     $task_set = new Task_set();
     $task_set->include_related('course', 'test_scoring_deadline');
     $task_set->get_by_id((int) $task_set_id);
     $student = new Student();
     $student->get_by_id((int) $student_id);
     $output = new stdClass();
     $output->result = FALSE;
     $output->message = '';
     $output->points_new = 0;
     $output->points_before = 0;
     $this->load->model('test_score');
     if ($task_set->exists() && $student->exists()) {
         if ($task_set->course_test_scoring_deadline >= date('Y-m-d H:i:s') && $task_set->enable_tests_scoring > 0) {
             $results = $this->test_score->get_data_for_student($student->id, $token, $test_type);
             $this->_transaction_isolation();
             $this->db->trans_start();
             $tests = new Test();
             $tests->where_related('task/task_set', 'id', $task_set->id);
             $tests->where('type', $test_type);
             $tests->where('enable_scoring >', 0);
             $tests->group_by('task_id');
             $tests->where('task_task_task_set_rel.bonus_task', 0);
             $tests->get_iterated();
             //$output->debug = $tests->check_last_query(array('', ''), TRUE);
             $test_count = $tests->result_count();
             $min_results = $task_set->test_min_needed > $test_count ? $test_count : $task_set->test_min_needed;
             $course = new Course();
             $course->where_related_task_set('id', $task_set->id);
             $course->get();
             $min_points_limit = -$course->default_points_to_remove;
             if ($test_count > 0) {
                 $total_score = 0;
                 $score_array = array();
                 $bonus_tasks_array = array();
                 $score_percentage = array();
                 $bonus_tasks_percentage = array();
                 if (count($results)) {
                     foreach ($results as $task_id => $score) {
                         $this->db->select('*');
                         $this->db->where('task_set_id', $task_set->id);
                         $this->db->where('task_id', (int) $task_id);
                         $query = $this->db->get('task_task_set_rel');
                         if ($query->num_rows() > 0) {
                             $task_rel = $query->row_object();
                             $min = $task_rel->test_min_points;
                             $max = $task_rel->test_max_points;
                             $diff = abs($max - $min);
                             $score_percent = (double) $score / 100;
                             $sub_score = round(10 * ($min + $diff * $score_percent)) / 10;
                             if ($task_rel->bonus_task == 0) {
                                 $score_array[$task_id] = $sub_score;
                                 $score_percentage[$task_id] = $score;
                             } else {
                                 $bonus_tasks_array[$task_id] = $sub_score;
                                 $bonus_tasks_percentage[$task_id] = $score;
                             }
                         }
                         $query->free_result();
                     }
                 }
                 $max_results = $task_set->test_max_allowed < count($score_array) ? $task_set->test_max_allowed : count($score_array);
                 arsort($score_array, SORT_NUMERIC);
                 $i = 0;
                 foreach ($score_array as $task_id => $points) {
                     if ($i < $max_results) {
                         $total_score += $points;
                         $i++;
                     } else {
                         break;
                     }
                 }
                 $total_score = $total_score < $min_points_limit ? $min_points_limit : $total_score;
                 arsort($bonus_tasks_array, SORT_NUMERIC);
                 $total_score += array_sum($bonus_tasks_array);
                 if (count($score_array) >= $min_results) {
                     $tasks = new Task();
                     $tasks->where_related_task_set('id', $task_set_id);
                     $tasks->order_by('`task_task_set_rel`.`sorting`', 'asc');
                     $tasks->get_iterated();
                     //$output->debug = $tasks->check_last_query(array('', ''), TRUE);
                     $output->evaluation = $this->parser->parse('backend/tests/evaluation_table.tpl', array('tasks' => $tasks, 'real_points' => $score_array, 'bonus_points' => $bonus_tasks_array, 'real_percentage' => $score_percentage, 'bonus_percentage' => $bonus_tasks_percentage, 'max_results' => $max_results), TRUE);
                     $solution = new Solution();
                     $solution->where('task_set_id', $task_set->id);
                     $solution->where('student_id', $student->id);
                     $solution->get();
                     $save_solution = FALSE;
                     $solution_not_considered = FALSE;
                     $output->points_new = $total_score;
                     if ($solution->exists()) {
                         if ($solution->not_considered == 0) {
                             $output->points_before = $solution->points;
                             if ($solution->points < $total_score || is_null($solution->points)) {
                                 $solution->points = $total_score;
                                 $solution->comment = '';
                                 $solution->teacher_id = NULL;
                                 $solution->best_version = (int) $version;
                                 $solution->revalidate = 0;
                                 $save_solution = TRUE;
                             }
                         } else {
                             $solution_not_considered = TRUE;
                         }
                     } else {
                         $solution->points = $total_score;
                         $solution->comment = '';
                         $solution->teacher_id = NULL;
                         $solution->best_version = (int) $version;
                         $solution->task_set_id = $task_set->id;
                         $solution->student_id = $student->id;
                         $solution->revalidate = 0;
                         $save_solution = TRUE;
                     }
                     if ($save_solution) {
                         $solution->save();
                         $output->result = TRUE;
                         $this->_action_success();
                     } else {
                         if (!$solution_not_considered) {
                             $output->message = sprintf($this->lang->line('admin_tests_test_result_nothing_to_update'), $output->points_new, $output->points_before);
                         } else {
                             $output->message = $this->lang->line('admin_tests_test_result_solution_not_considered');
                         }
                     }
                 } else {
                     $output->message = sprintf($this->lang->line('admin_tests_test_result_minimum_number_of_test_not_selected'), $min_results);
                 }
             } else {
                 $output->message = $this->lang->line('admin_tests_test_result_no_evaluationg_tests');
             }
             $this->db->trans_complete();
         } else {
             $output->message = $this->lang->line('admin_tests_test_result_disabled');
         }
     } else {
         $output->message = $this->lang->line('admin_tests_test_result_input_error');
     }
     $this->test_score->delete_token($token);
     $this->output->set_content_type('application/json');
     $this->output->set_output(json_encode($output));
 }
Beispiel #12
0
function list_import_lamsfet_tasks_in_sets_relation($sets, $tasks, $tasks_in_sets)
{
    echo 'Starting task_task_set_rel import (' . count($tasks_in_sets) . ') [';
    if (count($tasks_in_sets)) {
        foreach ($tasks_in_sets as $task_in_set) {
            $task_set_id = $sets[$task_in_set->set_id]->_list_id;
            $task_id = $tasks[$task_in_set->task_id]->_list_id;
            $task_set = new Task_set();
            $task_set->get_by_id(intval($task_set_id));
            $task = new Task();
            $task->get_by_id(intval($task_id));
            if ($task_set->exists() && $task->exists()) {
                $task_set->save($task);
                $task_set->set_join_field($task, 'sorting', $task_in_set->order);
                $task_set->set_join_field($task, 'points_total', floatval($task_in_set->points));
                $task_set->set_join_field($task, 'bonus_task', 0);
            } else {
                echo ' ( TASK SET OR TASK NOT FOUND ' . $task_set_id . '(' . $task_in_set->set_id . ')/' . $task_id . '(' . $task_in_set->task_id . ') ) ';
            }
            echo '.';
        }
    }
    echo '] ... done' . "\n";
}
Beispiel #13
0
 private function get_task_set_overview($task_set_id, &$course)
 {
     $task_set = new Task_set();
     $task_set->where('published', 1);
     $task_set->include_related_count('task', 'total_tasks');
     $task_set->where('content_type', 'project');
     $task_set->order_by('publish_start_time', 'asc');
     $task_set->order_by('upload_end_time', 'asc');
     $task_set->order_by_with_overlay('name', 'asc');
     $task_set->get_by_id((int) $task_set_id);
     $course = new Course();
     $course->where_related('task_set', 'id', (int) $task_set->id);
     $course->include_related('period');
     $course->get();
     return $task_set;
 }
Beispiel #14
0
 public function index($worker_id = 0)
 {
     $test_queue = new Test_queue();
     $execute_tests = FALSE;
     try {
         $this->db->query('SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;');
         $this->db->trans_begin();
         $test_queue->where('worker', NULL);
         $test_queue->where('status', 0);
         $test_queue->where('version >', 0);
         $test_queue->group_start(' NOT ');
         $test_queue->where('task_set_id', NULL);
         $test_queue->group_end();
         $test_queue->group_start(' NOT ');
         $test_queue->where('student_id', NULL);
         $test_queue->group_end();
         $test_queue->order_by('priority', 'asc');
         $test_queue->order_by('start', 'asc');
         $test_queue->limit(1);
         $sql_query = $test_queue->get_sql();
         $sql_query = rtrim($sql_query, '; ' . "\n\r") . ' FOR UPDATE;';
         $test_queue->query($sql_query);
         if ($test_queue->exists()) {
             $test_queue->worker = (int) $worker_id;
             $test_queue->status = 1;
             $test_queue->exec_start = date('Y-m-d H:i:s');
             $test_queue->where('worker', NULL);
             $test_queue->where('status', 0);
             if ($test_queue->save()) {
                 $this->db->trans_commit();
                 $execute_tests = TRUE;
             } else {
                 $this->db->trans_rollback();
             }
         } else {
             $this->db->trans_rollback();
         }
     } catch (Exception $e) {
     }
     if ($test_queue->exists() && $execute_tests) {
         //$this->db->query('SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;');
         //$this->db->trans_begin();
         $this->lang->reinitialize_for_idiom($test_queue->system_language);
         $this->lang->load('admin/tests');
         $task_set = new Task_set();
         $task_set->include_related('course', 'test_scoring_deadline');
         $task_set->get_by_id($test_queue->task_set_id);
         $student = new Student();
         $student->get_by_id($test_queue->student_id);
         $tests = new Test();
         $tests->where_related($test_queue);
         $tests->get_iterated();
         try {
             if ($task_set->exists() && $student->exists() && $tests->exists()) {
                 $version = $test_queue->version;
                 $run_evaluation = $task_set->enable_tests_scoring > 0 && $task_set->course_test_scoring_deadline >= date('Y-m-d H:i:s') ? TRUE : FALSE;
                 $score_percent = array();
                 $score_points = array();
                 $bonus_percent = array();
                 $bonus_points = array();
                 $total_tests_count = $tests->result_count();
                 foreach ($tests as $test) {
                     $test_queue->single_test_exec_start = date('Y-m-d H:i:s');
                     $test_queue->save();
                     $files = $task_set->get_student_files($student->id, (int) $version);
                     if (isset($files[(int) $version]['filepath']) && file_exists($files[(int) $version]['filepath'])) {
                         $test_object = $this->load->test($test->type);
                         $test_object->initialize($test);
                         $token = '';
                         //echo 'Test queue ' . $test_queue->id . ' is running test ' . $test->id . ' ... ' . PHP_EOL;
                         try {
                             $test_output = $test_object->run($files[(int) $version]['filepath'], $run_evaluation && $test->enable_scoring > 0, $student->id, $token);
                             $test_score = $test_object->get_last_test_score();
                         } catch (Exception $e) {
                             $test_output = $e->getMessage();
                             $test_score = 0;
                         }
                         $test_queue->set_join_field($test, 'result_text', $test_output);
                         $test_queue->set_join_field($test, 'evaluation_table', $test_object->get_last_test_scoring());
                         $test_queue->set_join_field($test, 'result', $test_object->get_last_exit_code());
                         //echo 'Test queue ' . $test_queue->id . ' is done with test ' . $test->id . ' ... ' . PHP_EOL;
                         if ($run_evaluation && $test->enable_scoring > 0) {
                             $this->db->select('*');
                             $task_id = $test->task_id;
                             $this->db->where('task_set_id', $task_set->id);
                             $this->db->where('task_id', (int) $task_id);
                             $query = $this->db->get('task_task_set_rel');
                             if ($query->num_rows() > 0) {
                                 $task_rel = $query->row_object();
                                 $min = (double) $task_rel->test_min_points;
                                 $max = (double) $task_rel->test_max_points;
                                 $percent = (double) $test_score / 100.0;
                                 $points = (1.0 - $percent) * $min + $percent * $max;
                                 if ($task_rel->bonus_task == 0) {
                                     $test_queue->set_join_field($test, 'percent_points', $test_score);
                                     $test_queue->set_join_field($test, 'points', $points);
                                     $score_percent[$task_id] = isset($score_percent[$task_id]) ? $score_percent[$task_id] + $percent : $percent;
                                     $percent = (double) $score_percent[$task_id];
                                     $points = (1.0 - $percent) * $min + $percent * $max;
                                     $score_points[$task_id] = $points;
                                 } else {
                                     $test_queue->set_join_field($test, 'percent_bonus', $test_score);
                                     $test_queue->set_join_field($test, 'bonus', $points);
                                     $bonus_percent[$task_id] = isset($bonus_percent[$task_id]) ? $bonus_percent[$task_id] + $percent : $percent;
                                     $percent = (double) $bonus_percent[$task_id];
                                     $points = (1.0 - $percent) * $min + $percent * $max;
                                     $bonus_points[$task_id] = $points;
                                 }
                             }
                             $query->free_result();
                         }
                     } else {
                         //$this->db->trans_rollback();
                         $test_queue->worker = NULL;
                         $test_queue->status = 3;
                         $test_queue->finish = date('Y-m-d H:i:s');
                         $test_queue->save();
                         die;
                     }
                 }
                 $tests = new Test();
                 $tests->where_related('task/task_set', 'id', $task_set->id);
                 $tests->where('type', $test_queue->test_type);
                 $tests->where('enable_scoring >', 0);
                 $tests->group_by('task_id');
                 $tests->where('task_task_task_set_rel.bonus_task', 0);
                 $tests->get_iterated();
                 $test_count = $tests->result_count();
                 $min_results = $task_set->test_min_needed > $test_count ? $test_count : $task_set->test_min_needed;
                 $course = new Course();
                 $course->where_related_task_set('id', $task_set->id);
                 $course->get();
                 $min_points_limit = -$course->default_points_to_remove;
                 if ($test_count > 0 && $run_evaluation) {
                     $max_results = $task_set->test_max_allowed < count($score_points) ? $task_set->test_max_allowed : count($score_points);
                     arsort($score_points, SORT_NUMERIC);
                     $i = 0;
                     $total_score = 0;
                     foreach ($score_points as $task_id => $points) {
                         if ($i < $max_results) {
                             $total_score += $points;
                             $i++;
                         } else {
                             break;
                         }
                     }
                     $total_score = $total_score < $min_points_limit ? $min_points_limit : $total_score;
                     $total_bonus = array_sum($bonus_points);
                     $total_score += $total_bonus;
                     if (count($score_points) >= $min_results) {
                         $solution = new Solution();
                         $solution->where('task_set_id', $task_set->id);
                         $solution->where('student_id', $student->id);
                         $solution->get();
                         $save_solution = FALSE;
                         $solution_not_considered = FALSE;
                         $solution_disable_evaluation = FALSE;
                         $best_old_score = $min_points_limit;
                         if ($solution->exists()) {
                             if ($solution->not_considered == 0) {
                                 if ($solution->disable_evaluation_by_tests == 0) {
                                     if ($solution->tests_points < $total_score || is_null($solution->tests_points)) {
                                         $solution->tests_points = $total_score;
                                         $solution->teacher_id = NULL;
                                         $solution->best_version = (int) $version;
                                         $solution->revalidate = 0;
                                         $save_solution = TRUE;
                                     } else {
                                         $best_old_score = $solution->tests_points;
                                     }
                                 } else {
                                     $solution_disable_evaluation = TRUE;
                                 }
                             } else {
                                 $solution_not_considered = TRUE;
                             }
                         } else {
                             $solution->tests_points = $total_score;
                             $solution->comment = '';
                             $solution->teacher_id = NULL;
                             $solution->best_version = (int) $version;
                             $solution->task_set_id = $task_set->id;
                             $solution->student_id = $student->id;
                             $solution->revalidate = 0;
                             $save_solution = TRUE;
                         }
                         if ($save_solution) {
                             $solution->save();
                             $this->parser->clearCache('frontend/tasks/index.tpl');
                             $test_queue->result_message = $this->lang->line('admin_tests_test_result_new_points_added');
                         } else {
                             if (!$solution_disable_evaluation) {
                                 if (!$solution_not_considered) {
                                     $test_queue->result_message = sprintf($this->lang->line('admin_tests_test_result_nothing_to_update'), $total_score, $best_old_score);
                                 } else {
                                     $test_queue->result_message = $this->lang->line('admin_tests_test_result_solution_not_considered');
                                 }
                             } else {
                                 $test_queue->result_message = $this->lang->line('admin_tests_test_result_solution_disable_evaluation');
                             }
                         }
                         $test_queue->points = $total_score - $total_bonus;
                         $test_queue->bonus = $total_bonus;
                     } else {
                         $test_queue->result_message = sprintf($this->lang->line('admin_tests_test_result_minimum_number_of_test_not_selected'), $min_results);
                     }
                     $result_table_tasks = new Task();
                     $result_table_tasks->where_related_task_set('id', $task_set->id);
                     $result_table_tasks->order_by('`task_task_set_rel`.`sorting`', 'asc');
                     $result_table_tasks->get_iterated();
                     $test_queue->result_html = $this->parser->parse('backend/tests/evaluation_table.tpl', array('tasks' => $result_table_tasks, 'real_points' => $score_points, 'bonus_points' => $bonus_points, 'real_percentage' => $score_percent, 'bonus_percentage' => $bonus_percent, 'max_results' => $max_results), TRUE);
                     $test_queue->worker = NULL;
                     $test_queue->status = 2;
                     $test_queue->finish = date('Y-m-d H:i:s');
                     $test_queue->save();
                     //$this->db->trans_commit();
                 } else {
                     if ($total_tests_count && !$run_evaluation) {
                         $test_queue->worker = NULL;
                         $test_queue->status = 2;
                         $test_queue->finish = date('Y-m-d H:i:s');
                         $test_queue->result_message = $this->lang->line('admin_tests_test_result_testing_finished');
                         $test_queue->save();
                         //$this->db->trans_commit();
                     } else {
                         //$this->db->trans_rollback();
                         $test_queue->worker = NULL;
                         $test_queue->status = 3;
                         $test_queue->finish = date('Y-m-d H:i:s');
                         $test_queue->result_message = $this->lang->line('admin_tests_test_result_no_test_selected');
                         $test_queue->save();
                     }
                 }
             } else {
                 //$this->db->trans_rollback();
                 $test_queue->worker = NULL;
                 $test_queue->status = 3;
                 $test_queue->finish = date('Y-m-d H:i:s');
                 $test_queue->result_message = $this->lang->line('admin_tests_test_result_configuration_error');
                 $test_queue->save();
             }
         } catch (Exception $e) {
             //$this->db->trans_rollback();
             $test_queue->worker = NULL;
             $test_queue->status = 3;
             $test_queue->finish = date('Y-m-d H:i:s');
             $test_queue->result_message = $this->lang->line('admin_tests_test_result_execution_error');
             $test_queue->result_html = '<pre>' . $e->getMessage() . '</pre>';
             $test_queue->save();
         }
     }
     //@unlink($test_locks_path . 'worker_' . (int)$worker_id . '_lock.txt');
 }