/** * This function will redirects browser to login page for teacher when no teacher is authentificated. * @param boolean $send_current_url if this is set to TRUE (default), current url will be encoded and sent to login page, so user will be redirected back to it after successful login. */ public function teacher_login_protected_redirect($send_current_url = TRUE) { if (!$this->is_teacher_session_valid()) { $current_url = encode_for_url($this->clear_current_url()); $redirects = $this->CI->config->item('login_redirects'); $redirect_student = $send_current_url ? '/' . trim($redirects['teacher'], '/') . '/current_url/' . $current_url . '/' : '/' . trim($redirects['teacher'], '/') . '/'; $this->CI->messages->keep_messages(); redirect(create_internal_url($redirect_student)); die; } }
function smarty_function_current_url($params, $template) { $CI =& get_instance(); $CI->load->library('usermanager'); return encode_for_url($CI->usermanager->clear_current_url()); }
public function run_test_for_task($test_id, $task_set_id, $student_id, $version, $token = '') { $task_set = new Task_set(); $task_set->include_related('course', 'test_scoring_deadline'); $task_set->get_by_id(intval($task_set_id)); $student = new Student(); $student->get_by_id(intval($student_id)); $output = new stdClass(); $output->text = $this->lang->line('admin_tests_error_message_failed_to_run_student_test'); $output->code = 1; if ($task_set->exists() && $student->exists()) { $files = $task_set->get_student_files($student->id, (int) $version); if (isset($files[(int) $version]['filepath'])) { $run_evaluation = $task_set->enable_tests_scoring > 0 && $task_set->course_test_scoring_deadline >= date('Y-m-d H:i:s') ? TRUE : FALSE; $this->run_single_test($test_id, encode_for_url($files[(int) $version]['filepath']), $run_evaluation, $token, $student->id); } else { $this->output->set_content_type('application/json'); $this->output->set_output(json_encode($output)); } } else { $this->output->set_content_type('application/json'); $this->output->set_output(json_encode($output)); } }
public function upload_csv_file() { $this->load->library('form_validation'); $this->form_validation->set_rules('csv_data[delimiter]', 'lang:admin_students_csv_import_form_field_delimiter', 'required|exact_length[1]'); $this->form_validation->set_rules('csv_data[enclosure]', 'lang:admin_students_csv_import_form_field_enclosure', 'required|exact_length[1]'); $this->form_validation->set_rules('csv_data[escape]', 'lang:admin_students_csv_import_form_field_escape', 'required|exact_length[1]'); if ($this->form_validation->run()) { $config = array('upload_path' => './private/uploads/csv_imports', 'file_name' => 'students_import_' . date('U') . '_' . rand(10000, 99999) . '.csv', 'allowed_types' => 'csv', 'overwrite' => FALSE); $this->load->library('upload', $config); if ($this->upload->do_upload('csv_file')) { $upload_data = $this->upload->data(); $post_data = $this->input->post('csv_data'); $data = array('f' => $upload_data['file_name'], 'd' => $post_data['delimiter'], 'c' => $post_data['enclosure'], 'e' => $post_data['escape']); redirect(create_internal_url('admin_students/show_csv_content/' . encode_for_url(serialize($data)))); } else { $this->parser->assign('error_message', $this->upload->display_errors('', '')); $this->csv_import(); } } else { $this->csv_import(); } }
function lamsfet_import_task_file_to_local_list_storage($full_path, $original_path, $list_task_id, $lamsfet_task_id) { $local_path = 'private/uploads/task_files/task_' . $list_task_id . '/hidden/'; if (!file_exists($local_path)) { @mkdir('private/uploads/task_files/task_' . $list_task_id, DIR_READ_MODE); @mkdir('private/uploads/task_files/task_' . $list_task_id . '/hidden', DIR_READ_MODE); } $file_name = basename($full_path); $full_local_path = $local_path . $file_name; if (lamsfet_download_file($full_path, $full_local_path)) { return 'index.php/tasks/download_hidden_file/' . $list_task_id . '/' . encode_for_url($file_name); } else { echo ' ( FILE NOT FOUND ' . $full_path . ' FOR LaMSfET TASK ' . $lamsfet_task_id . ' [LIST ' . $list_task_id . '] ) '; log_message('ERROR', 'FILE NOT FOUND ' . $full_path . ' FOR LaMSfET TASK ' . $lamsfet_task_id . ' [LIST ' . $list_task_id . ']', FALSE); return $original_path; } }