本文整理汇总了PHP中Task::get_iterated方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::get_iterated方法的具体用法?PHP Task::get_iterated怎么用?PHP Task::get_iterated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Task
的用法示例。
在下文中一共展示了Task::get_iterated方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run_comparation
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;
}
//.........这里部分代码省略.........
示例2: clone_task_set
public function clone_task_set()
{
$url = $this->uri->ruri_to_assoc(3);
$task_set_id = isset($url['task_set_id']) ? intval($url['task_set_id']) : 0;
$result = new stdClass();
$result->result = FALSE;
$result->message = $this->lang->line('admin_task_sets_error_task_set_not_found');
if ($task_set_id !== 0) {
$this->_transaction_isolation();
$this->db->trans_begin();
$task_set = new Task_set();
$task_set->get_by_id($task_set_id);
if ($task_set->exists()) {
$new_task_set = $task_set->get_copy();
$new_task_set->published = 0;
if ($new_task_set->save()) {
$this->lang->clone_overlays('task_sets', $task_set->id, $new_task_set->id);
$tasks = new Task();
$tasks->include_join_fields();
$tasks->where_related_task_set($task_set);
$tasks->get_iterated();
foreach ($tasks as $task) {
$new_task_set->save_task($task);
$task->set_join_field($new_task_set, 'sorting', $task->join_sorting);
$task->set_join_field($new_task_set, 'points_total', $task->join_points_total);
$task->set_join_field($new_task_set, 'test_min_points', $task->join_test_min_points);
$task->set_join_field($new_task_set, 'test_max_points', $task->join_test_max_points);
$task->set_join_field($new_task_set, 'bonus_task', $task->join_bonus_task);
$task->set_join_field($new_task_set, 'max_projects_selections', $task->join_max_projects_selections);
}
$task_set_permissions = new Task_set_permission();
$task_set_permissions->where_related($task_set);
$task_set_permissions->get_iterated();
foreach ($task_set_permissions as $task_set_permission) {
$new_task_set_permission = $task_set_permission->get_copy();
$new_task_set_permission->save($new_task_set);
}
if ($this->db->trans_status()) {
$this->db->trans_commit();
$result->result = TRUE;
$result->message = $this->lang->line('admin_task_sets_success_task_set_cloned');
$this->_action_success();
} else {
$this->db->trans_rollback();
$result->message = $this->lang->line('admin_task_sets_error_task_set_cant_be_cloned');
}
} else {
$this->db->trans_rollback();
$result->message = $this->lang->line('admin_task_sets_error_task_set_cant_be_cloned');
}
} else {
$this->db->trans_rollback();
}
}
$this->output->set_content_type('application/json');
$this->output->set_output(json_encode($result));
}
示例3: test_result
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));
}
示例4: evaluate_test_result
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;
//.........这里部分代码省略.........
示例5: fix_broken_tasks_links
function fix_broken_tasks_links($broken_prefix)
{
include_once APPPATH . 'third_party/simplehtmldom/simple_html_dom.php';
$CI =& get_instance();
$CI->lang->load_all_overlays('tasks');
$languages = $CI->lang->get_list_of_languages();
$tasks = new Task();
$tasks->get_iterated();
foreach ($tasks as $task) {
$text_html = str_get_html($task->text, true, true, DEFAULT_TARGET_CHARSET, false);
$save = FALSE;
echo 'TASK ' . $task->id . ":\n";
foreach ($text_html->find('img, a') as $element) {
if ($element->tag == 'a' && mb_strpos(trim($element->href), $broken_prefix) === 0) {
echo ' BROKEN a TAG' . "\n";
echo ' FOUND BROKEN LINK: ' . trim($element->href) . "\n";
$new_link = ltrim(mb_substr(trim($element->href), mb_strlen($broken_prefix)), '\\/');
echo ' REPAIR TO: ' . $new_link . "\n";
$element->href = $new_link;
$save = TRUE;
} elseif ($element->tag == 'img' && mb_strpos(trim($element->src), $broken_prefix) === 0) {
echo ' BROKEN img TAG' . "\n";
echo ' FOUND BROKEN LINK: ' . trim($element->src) . "\n";
$new_link = ltrim(mb_substr(trim($element->src), mb_strlen($broken_prefix)), '\\/');
echo ' REPAIR TO: ' . $new_link . "\n";
$element->src = $new_link;
$save = TRUE;
}
}
if ($save) {
$task->text = $text_html->__toString();
echo 'SAVING TASK' . "\n";
$task->save();
}
echo 'TESTING OVERLAYS' . "\n";
foreach ($languages as $idiom => $title) {
echo ' ' . $title . "\n";
$text = $CI->lang->get_overlay('tasks', $task->id, 'text', $idiom);
if (!empty($text)) {
$text_html = str_get_html($text, true, true, DEFAULT_TARGET_CHARSET, false);
$save = FALSE;
foreach ($text_html->find('img, a') as $element) {
if ($element->tag == 'a' && mb_strpos(trim($element->href), $broken_prefix) === 0) {
echo ' BROKEN a TAG' . "\n";
echo ' FOUND BROKEN LINK: ' . trim($element->href) . "\n";
$new_link = ltrim(mb_substr(trim($element->href), mb_strlen($broken_prefix)), '\\/');
echo ' REPAIR TO: ' . $new_link . "\n";
$element->href = $new_link;
$save = TRUE;
} elseif ($element->tag == 'img' && mb_strpos(trim($element->src), $broken_prefix) === 0) {
echo ' BROKEN img TAG' . "\n";
echo ' FOUND BROKEN LINK: ' . trim($element->src) . "\n";
$new_link = ltrim(mb_substr(trim($element->src), mb_strlen($broken_prefix)), '\\/');
echo ' REPAIR TO: ' . $new_link . "\n";
$element->src = $new_link;
$save = TRUE;
}
}
if ($save) {
$text = $text_html->__toString();
echo ' SAVING OVERLAY' . "\n";
$CI->lang->save_overlay('tasks', $task->id, 'text', $idiom, $text);
}
}
}
}
}
示例6: index
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;
//.........这里部分代码省略.........