require_once api_get_path(SYS_CODE_PATH) . 'work/work.lib.php'; $count = getWorkListTeacher(0, $limit, $sidx, $sord, $whereCondition, true); break; case 'get_work_student': require_once api_get_path(SYS_CODE_PATH) . 'work/work.lib.php'; $count = getWorkListStudent(0, $limit, $sidx, $sord, $whereCondition, true); break; case 'get_work_user_list_all': require_once api_get_path(SYS_CODE_PATH) . 'work/work.lib.php'; $work_id = $_REQUEST['work_id']; $count = get_count_work($work_id); break; case 'get_work_user_list_others': require_once api_get_path(SYS_CODE_PATH) . 'work/work.lib.php'; $work_id = $_REQUEST['work_id']; $count = get_count_work($work_id, api_get_user_id()); break; case 'get_work_user_list': require_once api_get_path(SYS_CODE_PATH) . 'work/work.lib.php'; $work_id = $_REQUEST['work_id']; $courseInfo = api_get_course_info(); $documents = getAllDocumentToWork($work_id, api_get_course_int_id()); if (empty($documents)) { $whereCondition .= " AND u.user_id = " . api_get_user_id(); $count = get_work_user_list(0, $limit, $sidx, $sord, $work_id, $whereCondition, null, true); } else { $count = get_work_user_list_from_documents(0, $limit, $sidx, $sord, $work_id, api_get_user_id(), $whereCondition, true); } break; case 'get_work_student_list_overview': if (!(api_is_allowed_to_edit() || api_is_coach())) {
echo Display::return_icon('upload_file.png', get_lang('UploadADocument'), '', ICON_SIZE_MEDIUM).'</a>';*/ if (ADD_DOCUMENT_TO_WORK) { echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_document.php?'.api_get_cidreq().'&id='.$workId.'">'; echo Display::return_icon('new_document.png', get_lang('AddDocument'), '', ICON_SIZE_MEDIUM).'</a>'; echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_user.php?'.api_get_cidreq().'&id='.$workId.'">'; echo Display::return_icon('user.png', get_lang('AddUsers'), '', ICON_SIZE_MEDIUM).'</a>'; echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId.'&action=export_pdf">'; echo Display::return_icon('pdf.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>'; } $display_output = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_missing.php?'.api_get_cidreq().'&id='.$workId.'&list=without">'. Display::return_icon('exercice_uncheck.png', get_lang('ViewUsersWithoutTask'), '', ICON_SIZE_MEDIUM)."</a>"; $count = get_count_work($workId); if ($count > 0) { $display_output .= '<a href="downloadfolder.inc.php?id='.$workId.'&'.api_get_cidreq().'">'. Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'), ICON_SIZE_MEDIUM).'</a>'; } echo $display_output; echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/edit_work.php?'.api_get_cidreq().'&id='.$workId.'">'; echo Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>'; } echo '</div>'; if (!empty($my_folder_data['title'])) { echo Display::page_subheader($my_folder_data['title']); }
/** * @param int $start * @param int $limit * @param string $column * @param string $direction * @param string $where_condition * @param bool $getCount * @return array */ function getWorkListTeacher( $start, $limit, $column, $direction, $where_condition, $getCount = false ) { $workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION); $workTableAssignment = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); $course_id = api_get_course_int_id(); $session_id = api_get_session_id(); $condition_session = api_get_session_condition($session_id); $group_id = api_get_group_id(); $is_allowed_to_edit = api_is_allowed_to_edit() || api_is_coach(); if (!in_array($direction, array('asc', 'desc'))) { $direction = 'desc'; } $column = !empty($column) ? Database::escape_string($column) : 'sent_date'; $start = intval($start); $limit = intval($limit); $works = array(); // Get list from database if ($is_allowed_to_edit) { $active_condition = ' active IN (0, 1)'; if ($getCount) { $select = " SELECT count(w.id) as count"; } else { $select = " SELECT w.*, a.expires_on, expires_on, ends_on, enable_qualification "; } $sql = " $select FROM $workTable w LEFT JOIN $workTableAssignment a ON (a.publication_id = w.id AND a.c_id = w.c_id) WHERE w.c_id = $course_id $condition_session AND $active_condition AND (parent_id = 0) AND post_group_id = '".$group_id."' $where_condition ORDER BY $column $direction LIMIT $start, $limit"; $result = Database::query($sql); if ($getCount) { $row = Database::fetch_array($result); return $row['count']; } $url = api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq(); while ($work = Database::fetch_array($result, 'ASSOC')) { $workId = $work['id']; $work['type'] = Display::return_icon('work.png'); $work['expires_on'] = $work['expires_on'] == '0000-00-00 00:00:00' ? null : api_get_local_time($work['expires_on']); $totalUsers = getStudentSubscribedToWork( $workId, $course_id, $group_id, $session_id, true ); $countUniqueAttempts = getUniqueStudentAttemptsTotal( $workId, $group_id, $course_id, $session_id ); $work['amount'] = Display::label( $countUniqueAttempts . '/' . $totalUsers, 'success' ); if (empty($work['title'])) { $work['title'] = basename($work['url']); } $work['title'] = Display::url($work['title'], $url.'&id='.$workId); $work['title'] .= ' '.Display::label(get_count_work($work['id']), 'success'); $work['sent_date'] = api_get_local_time($work['sent_date']); $editLink = Display::url( Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL), api_get_path(WEB_CODE_PATH).'work/edit_work.php?id='.$workId.'&'.api_get_cidreq() ); if ($countUniqueAttempts > 0) { $downloadLink = Display::url( Display::return_icon( 'save_pack.png', get_lang('Save'), array(), ICON_SIZE_SMALL ), api_get_path(WEB_CODE_PATH) . 'work/downloadfolder.inc.php?id=' . $workId . '&' . api_get_cidreq() ); } else { $downloadLink = Display::url( Display::return_icon( 'save_pack_na.png', get_lang('Save'), array(), ICON_SIZE_SMALL ), '#' ); } $deleteUrl = api_get_path(WEB_CODE_PATH).'work/work.php?id='.$workId.'&action=delete_dir&'.api_get_cidreq(); $deleteLink = '<a href="#" onclick="showConfirmationPopup(this, \'' . $deleteUrl . '\' ) " >' . Display::return_icon( 'delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL ) . '</a>'; if (!api_is_allowed_to_edit()) { $deleteLink = null; $editLink = null; } $work['actions'] = $downloadLink.$editLink.$deleteLink; $works[] = $work; } } return $works; }
/** * @param Application $app * @return string */ public function indexAction(Application $app) { $request = $app['request']; $language_file = array('admin', 'exercice', 'gradebook', 'tracking'); // 1. Setting variables needed by jqgrid $action = $request->get('a'); $page = $request->get('page'); //page $limit = $request->get('rows'); //quantity of rows $sidx = $request->get('sidx'); //index (field) to filter $sord = $request->get('sord'); //asc or desc if (strpos(strtolower($sidx), 'asc') !== false) { $sidx = str_replace(array('asc', ','), '', $sidx); $sord = 'asc'; } if (strpos(strtolower($sidx), 'desc') !== false) { $sidx = str_replace(array('desc', ','), '', $sidx); $sord = 'desc'; } if (!in_array($sord, array('asc', 'desc'))) { $sord = 'desc'; } if (!in_array($action, array('get_exercise_results', 'get_hotpotatoes_exercise_results', 'get_work_user_list', 'get_timelines', 'get_user_skill_ranking', 'get_usergroups_teacher', 'get_question_list', 'get_user_list_plugin_widescale'))) { api_protect_admin_script(true); } if ($action == 'get_user_list_plugin_widescale') { $allowed = api_is_drh() || api_is_platform_admin(); if (!$allowed) { api_not_allowed(); } } // Search features. // If there is no search request sent by jqgrid, $where should be empty. $where_condition = ""; $operation = $request->get('oper'); $export_format = $request->get('export_format'); $search_field = $request->get('searchField'); $search_oper = $request->get('searchOper'); $search_string = $request->get('searchString'); $isSearch = $request->get('_search'); $filters = $request->get('filters'); $type = $request->get('type'); $extra_fields = array(); $questionFields = array(); if ($isSearch == 'true') { $where_condition = ' 1 = 1 '; $where_condition_in_form = $this->getWhereClause($search_field, $search_oper, $search_string); if (!empty($where_condition_in_form)) { $where_condition .= ' AND ' . $where_condition_in_form; } $filters = isset($filters) ? json_decode($filters) : false; // for now if (!empty($filters)) { switch ($action) { case 'get_questions': $extraFieldtype = 'question'; break; case 'get_sessions': $extraFieldtype = 'session'; break; } // Extra field. $extraField = new \ExtraField($extraFieldtype); $result = $extraField->getExtraFieldRules($filters, 'extra_'); $extra_fields = $result['extra_fields']; $condition_array = $result['condition_array']; if (!empty($condition_array)) { $where_condition .= ' AND ( '; $where_condition .= implode($filters->groupOp, $condition_array); $where_condition .= ' ) '; } // Question field. $resultQuestion = $extraField->getExtraFieldRules($filters, 'question_'); $questionFields = $resultQuestion['extra_fields']; $condition_array = $resultQuestion['condition_array']; if (!empty($condition_array)) { $where_condition .= ' AND ( '; $where_condition .= implode($filters->groupOp, $condition_array); $where_condition .= ' ) '; } } } // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if (!$sidx) { $sidx = 1; } //2. Selecting the count FIRST //@todo rework this switch ($action) { case 'get_questions': $categoryId = $request->get('categoryId'); $exerciseId = $request->get('exerciseId'); //$courseId = null; //$request->get('courseId'); $courseId = $request->get('courseId'); // Question manager can view all questions if (api_is_question_manager()) { $courseId = null; } $count = \Question::getQuestions($app, $categoryId, $exerciseId, $courseId, array('where' => $where_condition, 'extra' => $extra_fields, 'question' => $questionFields), true); break; case 'get_user_list_plugin_widescale': $count = \UserManager::get_user_data(null, null, null, null, true); break; case 'get_question_list': require_once api_get_path(SYS_CODE_PATH) . 'exercice/exercise.class.php'; $exerciseId = $request->get('exerciseId'); $exercise = new \Exercise(api_get_course_int_id()); $exercise->read($exerciseId); $count = $exercise->selectNbrQuestions(); break; case 'get_group_reporting': $course_id = $request->get('course_id'); $group_id = $request->get('gidReq'); $count = \Tracking::get_group_reporting($course_id, $group_id, 'count'); break; case 'get_user_course_report_resumed': $count = \CourseManager::get_count_user_list_from_course_code(true, 'ruc'); break; case 'get_user_course_report': $count = \CourseManager::get_count_user_list_from_course_code(false); break; case 'get_course_exercise_medias': $course_id = api_get_course_int_id(); $count = \Question::get_count_course_medias($course_id); break; case 'get_user_skill_ranking': $skill = new \Skill(); $count = $skill->get_user_list_skill_ranking_count(); break; case 'get_work_user_list': require_once api_get_path(SYS_CODE_PATH) . 'work/work.lib.php'; $work_id = $request->get('work_id'); //$_REQUEST['work_id']; $count = get_count_work($work_id); break; case 'get_exercise_results': $exercise_id = $request->get('exerciseId'); //$_REQUEST['exerciseId']; $filter_by_user = $request->get('filter_by_user'); if (isset($filter_by_user) && !empty($filter_by_user)) { $filter_user = intval($filter_by_user); if ($where_condition == "") { $where_condition .= " te.exe_user_id = '{$filter_user}'"; } else { $where_condition .= " AND te.exe_user_id = '{$filter_user}'"; } } $count = \ExerciseLib::get_count_exam_results($exercise_id, $where_condition); break; case 'get_hotpotatoes_exercise_results': $hotpot_path = $request->get('path'); //$_REQUEST['path']; $count = \ExerciseLib::get_count_exam_hotpotatoes_results($hotpot_path); break; case 'get_sessions': $list_type = $request->get('list_type'); if ($list_type == 'simple' || empty($list_type)) { $count = \SessionManager::get_sessions_admin(array('where' => $where_condition, 'extra' => $extra_fields), true); } else { $count = \SessionManager::get_count_admin_complete(array('where' => $where_condition, 'extra' => $extra_fields)); } break; case 'get_extra_fields': $obj = new \ExtraField($type); $count = $obj->get_count(); break; case 'get_extra_field_options': $field_id = $request->get('field_id'); $obj = new \ExtraFieldOption($type); $count = $obj->get_count_by_field_id($field_id); break; case 'get_timelines': $obj = new \Timeline(); $count = $obj->get_count(); break; case 'get_gradebooks': $obj = new \Gradebook(); $count = $obj->get_count(); break; case 'get_event_email_template': $obj = new \EventEmailTemplate(); $count = $obj->get_count(); break; case 'get_careers': $obj = new \Career(); $count = $obj->get_count(); break; case 'get_promotions': $obj = new \Promotion(); $count = $obj->get_count(); break; case 'get_grade_models': $obj = new \GradeModel(); $count = $obj->get_count(); break; case 'get_usergroups': $obj = new \UserGroup(); $count = $obj->get_count(); break; case 'get_usergroups_teacher': $obj = new \UserGroup(); $course_id = api_get_course_int_id(); if ($type == 'registered') { $count = $obj->get_usergroup_by_course_with_data_count($course_id); } else { $count = $obj->get_count(); } break; default: exit; } //3. Calculating first, end, etc $total_pages = 0; if ((int) $count > 0) { if (!empty($limit)) { $total_pages = ceil($count / $limit); } } if ($page > $total_pages) { $page = $total_pages; } $start = $limit * $page - $limit; if ($start < 0) { $start = 0; } //4. Deleting an element if the user wants to if ($operation == 'del') { $obj->delete($request->get('id')); } $is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_allowed_to_edit(true) || api_is_drh(); //5. Querying the DB for the elements $columns = array(); switch ($action) { case 'get_questions': $columns = \Question::getQuestionColumns(api_get_course_id(), $extra_fields, $questionFields, true); $columns = $columns['simple_column_name']; $result = \Question::getQuestions($app, $categoryId, $exerciseId, $courseId, array('where' => $where_condition, 'order' => "{$sidx} {$sord}", 'extra' => $extra_fields, 'question' => $questionFields, 'limit' => "{$start} , {$limit}")); //var_dump($result); break; case 'get_user_list_plugin_widescale': $columns = array('username', 'firstname', 'lastname', 'exam_password'); $column_names = array(get_lang('Username'), get_lang('Firstname'), get_lang('Lastname'), get_lang('Password')); $result = \UserManager::get_user_data($start, $limit, $sidx, $sord); break; case 'get_question_list': if (isset($exercise) && !empty($exercise)) { $columns = array('question', 'type', 'category', 'level', 'score', 'actions'); $result = $exercise->getQuestionListPagination($start, $limit, $sidx, $sord, $where_condition); } break; case 'get_group_reporting': $columns = array('name', 'time', 'progress', 'score', 'works', 'messages', 'actions'); $result = \Tracking::get_group_reporting($course_id, $group_id, 'all', $start, $limit, $sidx, $sord, $where_condition); break; case 'get_course_exercise_medias': $columns = array('question'); $result = \Question::get_course_medias($course_id, $start, $limit, $sidx, $sord, $where_condition); if (!empty($result)) { foreach ($result as &$media) { $media['id'] = $media['iid']; } } break; case 'get_user_course_report_resumed': $columns = array('extra_ruc', 'training_hours', 'count_users', 'count_users_registered', 'average_hours_per_user', 'count_certificates'); $column_names = array(get_lang('Company'), get_lang('TrainingHoursAccumulated'), get_lang('CountOfSubscriptions'), get_lang('CountOfUsers'), get_lang('AverageHoursPerStudent'), get_lang('CountCertificates')); $result = \CourseManager::get_user_list_from_course_code(null, null, "LIMIT {$start}, {$limit}", " {$sidx} {$sord}", null, null, true, true, 'ruc'); $new_result = array(); if (!empty($result)) { foreach ($result as $row) { $row['training_hours'] = api_time_to_hms($row['training_hours']); $row['average_hours_per_user'] = api_time_to_hms($row['average_hours_per_user']); $new_result[] = $row; } $result = $new_result; } break; case 'get_user_course_report': $columns = array('course', 'user', 'time', 'certificate', 'progress_100', 'progress'); $column_names = array(get_lang('Course'), get_lang('User'), get_lang('ManHours'), get_lang('CertificateGenerated'), get_lang('Approved'), get_lang('CourseAdvance')); $extra_fields = \UserManager::get_extra_fields(0, 100, null, null, true, true); if (!empty($extra_fields)) { foreach ($extra_fields as $extra) { $columns[] = $extra['1']; $column_names[] = $extra['3']; } } $result = \CourseManager::get_user_list_from_course_code(null, null, "LIMIT {$start}, {$limit}", " {$sidx} {$sord}", null, null, true); break; case 'get_user_skill_ranking': $columns = array('photo', 'firstname', 'lastname', 'skills_acquired', 'currently_learning', 'rank'); $result = $skill->get_user_list_skill_ranking($start, $limit, $sidx, $sord, $where_condition); $result = \ArrayClass::msort($result, 'skills_acquired', 'asc'); $skills_in_course = array(); if (!empty($result)) { //$counter = 1; foreach ($result as &$item) { $user_info = api_get_user_info($item['user_id']); $personal_course_list = \UserManager::get_personal_session_course_list($item['user_id']); $count_skill_by_course = array(); foreach ($personal_course_list as $course_item) { if (!isset($skills_in_course[$course_item['code']])) { $count_skill_by_course[$course_item['code']] = $skill->get_count_skills_by_course($course_item['code']); $skills_in_course[$course_item['code']] = $count_skill_by_course[$course_item['code']]; } else { $count_skill_by_course[$course_item['code']] = $skills_in_course[$course_item['code']]; } } $item['photo'] = \Display::img($user_info['avatar_small']); $item['currently_learning'] = !empty($count_skill_by_course) ? array_sum($count_skill_by_course) : 0; } } break; case 'get_work_user_list': if (isset($type) && $type == 'simple') { $columns = array('type', 'firstname', 'lastname', 'username', 'title', 'qualification', 'sent_date', 'qualificator_id', 'actions'); } else { $columns = array('type', 'firstname', 'lastname', 'username', 'title', 'sent_date', 'actions'); } $result = get_work_user_list($start, $limit, $sidx, $sord, $work_id, $where_condition); break; case 'get_exercise_results': $course = api_get_course_info(); //used inside get_exam_results_data() $documentPath = api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document"; if ($is_allowedToEdit) { $columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_duration', 'start_date', 'exe_date', 'score', 'status', 'lp', 'actions'); } else { //$columns = array('exe_duration', 'start_date', 'exe_date', 'score', 'status', 'actions'); } $result = \ExerciseLib::get_exam_results_data($start, $limit, $sidx, $sord, $exercise_id, $where_condition); break; case 'get_hotpotatoes_exercise_results': $course = api_get_course_info(); //used inside get_exam_results_data() $documentPath = api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document"; $columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_date', 'score', 'actions'); $result = ExerciseLib::get_exam_results_hotpotatoes_data($start, $limit, $sidx, $sord, $hotpot_path, $where_condition); //get_exam_results_data($start, $limit, $sidx, $sord, $exercise_id, $where_condition); break; case 'get_sessions': $session_columns = \SessionManager::get_session_columns($list_type); $columns = $session_columns['simple_column_name']; if ($list_type == 'simple') { $result = SessionManager::get_sessions_admin(array('where' => $where_condition, 'order' => "{$sidx} {$sord}", 'extra' => $extra_fields, 'limit' => "{$start} , {$limit}"), false); } else { $result = SessionManager::get_sessions_admin_complete(array('where' => $where_condition, 'order' => "{$sidx} {$sord}", 'extra' => $extra_fields, 'limit' => "{$start} , {$limit}")); } break; case 'get_timelines': $columns = array('headline', 'actions'); //$columns = array('headline', 'type', 'start_date', 'end_date', 'text', 'media', 'media_credit', 'media_caption', 'title_slide', 'parent_id'); if (!in_array($sidx, $columns)) { $sidx = 'headline'; } $course_id = api_get_course_int_id(); $result = Database::select('*', $obj->table, array('where' => array('parent_id = ? AND c_id = ?' => array('0', $course_id)), 'order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}")); $new_result = array(); foreach ($result as $item) { if (!$item['status']) { $item['name'] = '<font style="color:#AAA">' . $item['name'] . '</font>'; } $item['headline'] = Display::url($item['headline'], api_get_path(WEB_CODE_PATH) . 'timeline/view.php?id=' . $item['id']); $item['actions'] = Display::url(Display::return_icon('add.png', get_lang('AddItems')), api_get_path(WEB_CODE_PATH) . 'timeline/?action=add_item&parent_id=' . $item['id']); $item['actions'] .= Display::url(Display::return_icon('edit.png', get_lang('Edit')), api_get_path(WEB_CODE_PATH) . 'timeline/?action=edit&id=' . $item['id']); $item['actions'] .= Display::url(Display::return_icon('delete.png', get_lang('Delete')), api_get_path(WEB_CODE_PATH) . 'timeline/?action=delete&id=' . $item['id']); $new_result[] = $item; } $result = $new_result; break; case 'get_gradebooks': $columns = array('name', 'certificates', 'skills', 'actions', 'has_certificates'); if (!in_array($sidx, $columns)) { $sidx = 'name'; } $result = Database::select('*', $obj->table, array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}")); $new_result = array(); foreach ($result as $item) { if ($item['parent_id'] != 0) { continue; } $skills = $obj->get_skills_by_gradebook($item['id']); //Fixes bug when gradebook doesn't have names if (empty($item['name'])) { $item['name'] = $item['course_code']; } else { //$item['name'] = $item['name'].' ['.$item['course_code'].']'; } $item['name'] = Display::url($item['name'], api_get_path(WEB_CODE_PATH) . 'gradebook/index.php?id_session=0&cidReq=' . $item['course_code']); if (!empty($item['certif_min_score']) && !empty($item['document_id'])) { $item['certificates'] = Display::return_icon('accept.png', get_lang('WithCertificate'), array(), ICON_SIZE_SMALL); $item['has_certificates'] = '1'; } else { $item['certificates'] = Display::return_icon('warning.png', get_lang('NoCertificate'), array(), ICON_SIZE_SMALL); $item['has_certificates'] = '0'; } if (!empty($skills)) { foreach ($skills as $skill) { $item['skills'] .= Display::span($skill['name'], array('class' => 'label_tag skill')); } } $new_result[] = $item; } $result = $new_result; break; case 'get_event_email_template': $columns = array('subject', 'event_type_name', 'language_id', 'activated', 'actions'); if (!in_array($sidx, $columns)) { $sidx = 'subject'; } $result = Database::select('*', $obj->table, array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}")); $new_result = array(); foreach ($result as $item) { $language_info = api_get_language_info($item['language_id']); $item['language_id'] = $language_info['english_name']; $item['actions'] = Display::url(Display::return_icon('edit.png', get_lang('Edit')), api_get_path(WEB_CODE_PATH) . 'admin/event_type.php?action=edit&event_type_name=' . $item['event_type_name']); $item['actions'] .= Display::url(Display::return_icon('delete.png', get_lang('Delete')), api_get_path(WEB_CODE_PATH) . 'admin/event_controller.php?action=delete&id=' . $item['id']); /*if (!$item['status']) { $item['name'] = '<font style="color:#AAA">'.$item['subject'].'</font>'; }*/ $new_result[] = $item; } $result = $new_result; break; case 'get_careers': $columns = array('name', 'description', 'actions'); if (!in_array($sidx, $columns)) { $sidx = 'name'; } $result = Database::select('*', $obj->table, array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}")); $new_result = array(); foreach ($result as $item) { if (!$item['status']) { $item['name'] = '<font style="color:#AAA">' . $item['name'] . '</font>'; } $new_result[] = $item; } $result = $new_result; break; case 'get_promotions': $columns = array('name', 'career', 'description', 'actions'); if (!in_array($sidx, $columns)) { $sidx = 'name'; } $result = Database::select('p.id,p.name, p.description, c.name as career, p.status', "{$obj->table} p LEFT JOIN " . Database::get_main_table(TABLE_CAREER) . " c ON c.id = p.career_id ", array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}")); $new_result = array(); foreach ($result as $item) { if (!$item['status']) { $item['name'] = '<font style="color:#AAA">' . $item['name'] . '</font>'; } $new_result[] = $item; } $result = $new_result; break; case 'get_grade_models': $columns = array('name', 'description', 'actions'); if (!in_array($sidx, $columns)) { $sidx = 'name'; } $result = Database::select('*', "{$obj->table} ", array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}")); $new_result = array(); foreach ($result as $item) { $new_result[] = $item; } $result = $new_result; break; case 'get_usergroups': $columns = array('name', 'users', 'courses', 'sessions', 'group_type', 'actions'); $result = Database::select('*', $obj->table, array('order' => "name {$sord}", 'LIMIT' => "{$start} , {$limit}")); $new_result = array(); if (!empty($result)) { foreach ($result as $group) { $group['sessions'] = count($obj->get_sessions_by_usergroup($group['id'])); $group['courses'] = count($obj->get_courses_by_usergroup($group['id'])); $group['users'] = count($obj->get_users_by_usergroup($group['id'])); switch ($group['group_type']) { case '0': $group['group_type'] = Display::label(get_lang('Class'), 'info'); break; case '1': $group['group_type'] = Display::label(get_lang('Social'), 'success'); break; } $new_result[] = $group; } $result = $new_result; } $columns = array('name', 'users', 'courses', 'sessions', 'group_type'); if (!in_array($sidx, $columns)) { $sidx = 'name'; } //Multidimensional sort ArrayClass::msort($result, $sidx); break; case 'get_extra_fields': $obj = new \ExtraField($type); $columns = array('field_display_text', 'field_variable', 'field_type', 'field_changeable', 'field_visible', 'field_filter', 'field_order'); $result = \Database::select('*', $obj->table, array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}")); $new_result = array(); if (!empty($result)) { foreach ($result as $item) { $item['field_type'] = $obj->get_field_type_by_id($item['field_type']); $item['field_changeable'] = $item['field_changeable'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif'); $item['field_visible'] = $item['field_visible'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif'); $item['field_filter'] = $item['field_filter'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif'); $new_result[] = $item; } $result = $new_result; } break; case 'get_extra_field_options': $obj = new \ExtraFieldOption($type); $columns = array('option_display_text', 'option_value', 'option_order'); $result = \Database::select('*', $obj->table, array('where' => array("field_id = ? " => $field_id), 'order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}")); /*$new_result = array(); if (!empty($result)) { foreach ($result as $item) { $item['field_type'] = $obj->get_field_type_by_id($item['field_type']); $item['field_changeable'] = $item['field_changeable'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif'); $item['field_visible'] = $item['field_visible'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif'); $item['field_filter'] = $item['field_filter'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif'); $new_result[] = $item; } $result = $new_result; }*/ break; case 'get_usergroups_teacher': $columns = array('name', 'users', 'actions'); $options = array('order' => "name {$sord}", 'LIMIT' => "{$start} , {$limit}"); $options['course_id'] = $course_id; switch ($type) { case 'not_registered': $options['where'] = array(" (course_id IS NULL OR course_id != ?) " => $course_id); $result = $obj->get_usergroup_not_in_course($options); break; case 'registered': $options['where'] = array(" usergroup.course_id = ? " => $course_id); $result = $obj->get_usergroup_in_course($options); break; } $new_result = array(); if (!empty($result)) { foreach ($result as $group) { $group['users'] = count($obj->get_users_by_usergroup($group['id'])); if ($obj->usergroup_was_added_in_course($group['id'], $course_id)) { $url = 'class.php?action=remove_class_from_course&id=' . $group['id']; $icon = Display::return_icon('delete.png', get_lang('Remove')); } else { $url = 'class.php?action=add_class_to_course&id=' . $group['id']; $icon = Display::return_icon('add.png', get_lang('Add')); } $group['actions'] = Display::url($icon, $url); $new_result[] = $group; } $result = $new_result; } if (!in_array($sidx, $columns)) { $sidx = 'name'; } //Multidimensional sort \ArrayClass::msort($result, $sidx); break; default: exit; } $allowed_actions = array('get_careers', 'get_promotions', 'get_usergroups', 'get_usergroups_teacher', 'get_gradebooks', 'get_sessions', 'get_exercise_results', 'get_hotpotatoes_exercise_results', 'get_work_user_list', 'get_timelines', 'get_grade_models', 'get_event_email_template', 'get_user_skill_ranking', 'get_extra_fields', 'get_extra_field_options', 'get_course_exercise_medias', 'get_user_course_report', 'get_user_course_report_resumed', 'get_group_reporting', 'get_question_list', 'get_user_list_plugin_widescale', 'get_questions'); //5. Creating an obj to return a json if (in_array($action, $allowed_actions)) { $response = new \stdClass(); $response->page = $page; $response->total = $total_pages; $response->records = $count; if ($operation && $operation == 'excel') { $j = 1; $array = array(); if (empty($column_names)) { $column_names = $columns; } //Headers foreach ($column_names as $col) { $array[0][] = $col; } foreach ($result as $row) { foreach ($columns as $col) { $array[$j][] = strip_tags($row[$col]); } $j++; } switch ($export_format) { case 'xls': Export::export_table_xls($array, 'company_report'); break; case 'csv': default: Export::export_table_csv($array, 'company_report'); break; } exit; } $i = 0; if (!empty($result)) { foreach ($result as $row) { //print_r($row); // if results tab give not id, set id to $i otherwise id="null" for all <tr> of the jqgrid - ref #4235 if (!isset($row['id']) || isset($row['id']) && $row['id'] == "") { $response->rows[$i]['id'] = $i; } else { $response->rows[$i]['id'] = $row['id']; } $array = array(); foreach ($columns as $col) { $array[] = isset($row[$col]) ? $row[$col] : null; } $response->rows[$i]['cell'] = $array; $i++; } } return json_encode($response); } }
/** * Display the list of student publications, taking into account the user status * * @param $origin - typically empty or 'learnpath' */ function display_student_publications_list($id, $my_folder_data, $work_parents, $origin, $add_in_where_query = '', $userList = array()) { global $gradebook; $_course = api_get_course_info(); // Database table names $work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); $iprop_table = Database::get_course_table(TABLE_ITEM_PROPERTY); $user_table = Database::get_main_table(TABLE_MAIN_USER); $work_assigment = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); $is_allowed_to_edit = api_is_allowed_to_edit(null, true); $session_id = api_get_session_id(); $condition_session = api_get_session_condition($session_id); $course_id = api_get_course_int_id(); $course_info = api_get_course_info(api_get_course_id()); $sort_params = array(); if (isset($_GET['column'])) { $sort_params[] = 'column=' . Security::remove_XSS($_GET['column']); } if (isset($_GET['page_nr'])) { $sort_params[] = 'page_nr=' . Security::remove_XSS($_GET['page_nr']); } if (isset($_GET['per_page'])) { $sort_params[] = 'per_page=' . Security::remove_XSS($_GET['per_page']); } if (isset($_GET['direction'])) { $sort_params[] = 'direction=' . Security::remove_XSS($_GET['direction']); } $sort_params = implode('&', $sort_params); $my_params = $sort_params; $origin = Security::remove_XSS($origin); $qualification_exists = false; if (!empty($my_folder_data['qualification']) && intval($my_folder_data['qualification']) > 0) { $qualification_exists = true; } $edit_dir = isset($_GET['edit_dir']) ? intval($_GET['edit_dir']) : ''; $table_header = array(); $table_has_actions_column = false; $table_header[] = array(get_lang('Type'), false, 'style="width:40px"'); $table_header[] = array(get_lang('Title'), true); if (!empty($id)) { $table_header[] = array(get_lang('FirstName'), true); $table_header[] = array(get_lang('LastName'), true); } $table_header[] = array(get_lang('HandOutDateLimit'), true, 'style="width:200px"'); if ($is_allowed_to_edit) { $table_header[] = array(get_lang('HandedOut'), false); $table_header[] = array(get_lang('Actions'), false, 'style="width:90px"', array('class' => 'td_actions')); $table_has_actions_column = true; if ($qualification_exists) { $table_header[] = array(get_lang('Qualification'), true); } } else { // All users if ($course_info['show_score'] == 0) { $table_header[] = array(get_lang('Others'), false); } } $table_data = array(); // List of all folders if no id was provided $group_id = api_get_group_id(); if (is_array($work_parents)) { foreach ($work_parents as $work_parent) { $sql_select_directory = "SELECT\n\t\t\t title,\n\t\t\t url,\n\t\t\t prop.insert_date,\n\t\t\t prop.lastedit_date,\n\t\t\t work.id, author,\n\t\t\t has_properties,\n\t\t\t view_properties,\n\t\t\t description,\n\t\t\t qualification,\n\t\t\t weight,\n\t\t\t allow_text_assignment\n FROM " . $iprop_table . " prop INNER JOIN " . $work_table . " work ON (prop.ref=work.id AND prop.c_id = {$course_id})\n WHERE active IN (0, 1) AND "; if (!empty($group_id)) { $sql_select_directory .= " work.post_group_id = '" . $group_id . "' "; // set to select only messages posted by the user's group } else { $sql_select_directory .= " work.post_group_id = '0' "; } $sql_select_directory .= " AND " . " work.c_id = {$course_id} AND " . " work.id = " . $work_parent->id . " AND " . " work.filetype = 'folder' AND " . " prop.tool='work' {$condition_session}"; $result = Database::query($sql_select_directory); $row = Database::fetch_array($result, 'ASSOC'); if (!$row) { // the folder belongs to another session continue; } $direc_date = $row['lastedit_date']; //directory's date $author = $row['author']; //directory's author $view_properties = $row['view_properties']; $is_assignment = $row['has_properties']; $id2 = $row['id']; //work id $locked = api_resource_is_locked_by_gradebook($id2, LINK_STUDENTPUBLICATION); // form edit directory if (!empty($row['has_properties'])) { $sql = Database::query('SELECT * FROM ' . $work_assigment . ' WHERE c_id = ' . $course_id . ' AND id = "' . $row['has_properties'] . '" LIMIT 1'); $homework = Database::fetch_array($sql); } // save original value for later $utc_expiry_time = $homework['expires_on']; if ($is_allowed_to_edit && $locked == false) { if (!empty($edit_dir) && $edit_dir == $id2) { $form_folder = new FormValidator('edit_dir', 'post', api_get_self() . '?origin=' . $origin . '&gradebook=' . $gradebook . '&edit_dir=' . $id2); $form_folder->addElement('text', 'dir_name', get_lang('Title')); $form_folder->addElement('hidden', 'work_id', $id2); $form_folder->addRule('dir_name', get_lang('ThisFieldIsRequired'), 'required'); $my_title = !empty($row['title']) ? $row['title'] : basename($row['url']); $defaults = array('dir_name' => Security::remove_XSS($my_title), 'description' => Security::remove_XSS($row['description'])); $form_folder->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'work', 'Width' => '80%', 'Height' => '200')); $there_is_a_end_date = false; $form_folder->addElement('advanced_settings', 'work', get_lang('AdvancedParameters')); $form_folder->addElement('html', '<div id="work_options" style="display: none;">'); if (empty($default)) { $default = api_get_local_time(); } $parts = explode(' ', $default); list($d_year, $d_month, $d_day) = explode('-', $parts[0]); list($d_hour, $d_minute) = explode(':', $parts[1]); $qualification_input[] = $form_folder->createElement('text', 'qualification'); $form_folder->addGroup($qualification_input, 'qualification', get_lang('QualificationNumeric')); if (Gradebook::is_active()) { $link_info = is_resource_in_course_gradebook(api_get_course_id(), LINK_STUDENTPUBLICATION, $id2); $form_folder->addElement('checkbox', 'make_calification', null, get_lang('MakeQualifiable'), 'onclick="javascript: if(this.checked){document.getElementById(\'option3\').style.display = \'block\';}else{document.getElementById(\'option3\').style.display = \'none\';}"'); if (!empty($link_info)) { $form_folder->addElement('html', '<div id=\'option3\' style="display:block">'); } else { $form_folder->addElement('html', '<div id=\'option3\' style="display:none">'); } //Loading gradebook select load_gradebook_select_in_tool($form_folder); $weight_input2[] = $form_folder->createElement('text', 'weight'); $form_folder->addGroup($weight_input2, 'weight', get_lang('WeightInTheGradebook'), 'size="10"'); $form_folder->addElement('html', '</div>'); $defaults['weight[weight]'] = $link_info['weight']; if (!empty($link_info)) { $defaults['category_id'] = $link_info['category_id']; $defaults['make_calification'] = 1; } } else { $defaults['category_id'] = ''; } if ($homework['expires_on'] != '0000-00-00 00:00:00') { $homework['expires_on'] = api_get_local_time($homework['expires_on']); $there_is_a_expire_date = true; $defaults['enableExpiryDate'] = true; $form_folder->addElement('checkbox', 'enableExpiryDate', null, get_lang('EnableExpiryDate'), 'onclick="javascript: if(this.checked){document.getElementById(\'option1\').style.display = \'block\';}else{document.getElementById(\'option1\').style.display = \'none\';}"'); $form_folder->addElement('html', '<div id=\'option1\' style="display:block">'); $form_folder->addGroup(create_group_date_select(), 'expires', get_lang('ExpiresAt')); $form_folder->addElement('html', '</div>'); } else { $homework['expires_on'] = api_get_local_time(); $expires_date_array = convert_date_to_array(api_get_local_time(), 'expires'); $defaults = array_merge($defaults, $expires_date_array); $there_is_a_expire_date = false; $form_folder->addElement('checkbox', 'enableExpiryDate', null, get_lang('EnableExpiryDate'), 'onclick="javascript: if(this.checked){document.getElementById(\'option1\').style.display = \'block\';}else{document.getElementById(\'option1\').style.display = \'none\';}"'); $form_folder->addElement('html', '<div id=\'option1\' style="display:none">'); $form_folder->addGroup(create_group_date_select(), 'expires', get_lang('ExpiresAt')); $form_folder->addElement('html', '</div>'); } if ($homework['ends_on'] != '0000-00-00 00:00:00') { $homework['ends_on'] = api_get_local_time($homework['ends_on']); $there_is_a_end_date = true; $defaults['enableEndDate'] = true; $form_folder->addElement('checkbox', 'enableEndDate', null, get_lang('EnableEndDate'), 'onclick="javascript: if(this.checked){document.getElementById(\'option2\').style.display = \'block\';}else{document.getElementById(\'option2\').style.display = \'none\';}"'); $form_folder->addElement('html', '<div id=\'option2\' style="display:block">'); $form_folder->addGroup(create_group_date_select(), 'ends', get_lang('EndsAt')); $form_folder->addElement('html', '</div>'); $form_folder->addRule(array('expires', 'ends'), get_lang('DateExpiredNotBeLessDeadLine'), 'comparedate'); } else { $homework['ends_on'] = api_get_local_time(); $expires_date_array = convert_date_to_array(api_get_local_time(), 'ends'); $defaults = array_merge($defaults, $expires_date_array); $there_is_a_end_date = false; $form_folder->addElement('checkbox', 'enableEndDate', null, get_lang('EnableEndDate'), 'onclick="javascript: if(this.checked){document.getElementById(\'option2\').style.display = \'block\';}else{document.getElementById(\'option2\').style.display = \'none\';}"'); $form_folder->addElement('html', '<div id=\'option2\' style="display:none">'); $form_folder->addGroup(create_group_date_select(), 'ends', get_lang('EndsAt')); $form_folder->addElement('html', '</div>'); $form_folder->addRule(array('expires', 'ends'), get_lang('DateExpiredNotBeLessDeadLine'), 'comparedate'); } if ($there_is_a_expire_date && $there_is_a_end_date) { $form_folder->addRule(array('expires', 'ends'), get_lang('DateExpiredNotBeLessDeadLine'), 'comparedate'); } $form_folder->addElement('checkbox', 'allow_text_assignment', null, get_lang('AllowTextAssignments')); $form_folder->addElement('html', '</div>'); $form_folder->addElement('style_submit_button', 'submit', get_lang('ModifyDirectory'), 'class="save"'); if ($there_is_a_end_date) { $end_date_array = convert_date_to_array($homework['ends_on'], 'ends'); $defaults = array_merge($defaults, $end_date_array); } if ($there_is_a_expire_date) { $expires_date_array = convert_date_to_array($homework['expires_on'], 'expires'); $defaults = array_merge($defaults, $expires_date_array); } if (!empty($row['qualification'])) { $defaults = array_merge($defaults, array('qualification[qualification]' => $row['qualification'])); } $defaults['allow_text_assignment'] = $row['allow_text_assignment']; $form_folder->setDefaults($defaults); $display_edit_form = true; if ($form_folder->validate()) { if ($_POST['enableExpiryDate'] == '1') { $there_is_a_expire_date = true; } else { $there_is_a_expire_date = false; } if ($_POST['enableEndDate'] == '1') { $there_is_a_end_date = true; } else { $there_is_a_end_date = false; } $values = $form_folder->exportValues(); $work_id = $values['work_id']; $dir_name = replace_dangerous_char($values['dir_name']); $dir_name = disable_dangerous_file($dir_name); $edit_check = false; $work_data = get_work_data_by_id($work_id); if (!empty($work_data)) { $edit_check = true; } else { $edit_check = true; } if ($edit_check) { $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA); $expires_query = ' SET expires_on = ' . "'" . ($there_is_a_expire_date ? api_get_utc_datetime(get_date_from_group('expires')) : '0000-00-00 00:00:00') . "'"; Database::query('UPDATE ' . $work_assigment . $expires_query . ' WHERE c_id = ' . $course_id . ' AND id = ' . "'" . $row['has_properties'] . "'"); $sql_add_publication = "UPDATE " . $work_table . " SET has_properties = '" . $row['has_properties'] . "', view_properties=1 WHERE c_id = {$course_id} AND id ='" . $row['id'] . "'"; Database::query($sql_add_publication); $ends_query = ' SET ends_on = ' . "'" . ($there_is_a_end_date ? api_get_utc_datetime(get_date_from_group('ends')) : '0000-00-00 00:00:00') . "'"; Database::query('UPDATE ' . $work_assigment . $ends_query . ' WHERE c_id = ' . $course_id . ' AND id = ' . "'" . $row['has_properties'] . "'"); $sql_add_publication = "UPDATE " . $work_table . " SET has_properties = '" . $row['has_properties'] . "', view_properties=1 WHERE c_id = {$course_id} AND id ='" . $row['id'] . "'"; Database::query($sql_add_publication); $qualification_value = isset($_POST['qualification']['qualification']) && !empty($_POST['qualification']['qualification']) ? intval($_POST['qualification']['qualification']) : 0; $enable_qualification = !empty($qualification_value) ? 1 : 0; $sql_add_publication = "UPDATE " . $work_assigment . " SET enable_qualification = '" . $enable_qualification . "' WHERE c_id = {$course_id} AND publication_id ='" . $row['id'] . "'"; Database::query($sql_add_publication); $sql = 'UPDATE ' . $work_table . ' SET allow_text_assignment = ' . "'" . intval($_POST['allow_text_assignment']) . "'" . ' , title = ' . "'" . Database::escape_string($_POST['dir_name']) . "'" . ', description = ' . "'" . Database::escape_string($_POST['description']) . "'" . ', qualification = ' . "'" . Database::escape_string($_POST['qualification']['qualification']) . "'" . ', weight = ' . "'" . Database::escape_string($_POST['weight']['weight']) . "'" . ' WHERE c_id = ' . $course_id . ' AND id = ' . $row['id']; Database::query($sql); require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/gradebook_functions.inc.php'; require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/be/gradebookitem.class.php'; require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/be/evaluation.class.php'; require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/be/abstractlink.class.php'; $link_info = is_resource_in_course_gradebook(api_get_course_id(), LINK_STUDENTPUBLICATION, $row['id'], api_get_session_id()); $link_id = null; if (!empty($link_info)) { $link_id = $link_info['id']; } if (isset($_POST['make_calification']) && $_POST['make_calification'] == 1 && !empty($_POST['category_id'])) { if (empty($link_id)) { add_resource_to_course_gradebook($_POST['category_id'], api_get_course_id(), LINK_STUDENTPUBLICATION, $row['id'], $_POST['dir_name'], (double) $_POST['weight']['weight'], (double) $_POST['qualification']['qualification'], $_POST['description'], 1, api_get_session_id(), $link_id); } else { update_resource_from_course_gradebook($link_id, api_get_course_id(), $_POST['weight']['weight']); } } else { //Delete everything of the gradebook remove_resource_from_course_gradebook($link_id); } update_dir_name($work_data, $dir_name, $values['dir_name']); $dir = $dir_name; $display_edit_form = false; // gets calendar_id from student_publication_assigment $sql = "SELECT add_to_calendar FROM {$work_assigment} WHERE c_id = {$course_id} AND publication_id ='" . $row['id'] . "'"; $res = Database::query($sql); $calendar_id = Database::fetch_row($res); $dir_name = sprintf(get_lang('HandingOverOfTaskX'), $dir_name); $end_date = $row['insert_date']; if ($_POST['enableExpiryDate'] == '1') { $end_date = Database::escape_string(api_get_utc_datetime(get_date_from_group('expires'))); } // update from agenda if it exists if (!empty($calendar_id[0])) { $sql = "UPDATE " . $TABLEAGENDA . "\n\t\t\t\t\t\t\t\t\t\tSET title='" . $values['dir_name'] . "',\n\t\t\t\t\t\t\t\t\t\t\tcontent = '" . Database::escape_string($_POST['description']) . "',\n\t\t\t\t\t\t\t\t\t\t\tstart_date = '" . $end_date . "',\n\t\t\t\t\t\t\t\t\t\t\tend_date = '" . $end_date . "'\n\t\t\t\t\t\t\t\t\t\tWHERE c_id = {$course_id} AND id='" . $calendar_id[0] . "'"; Database::query($sql); } Display::display_confirmation_message(get_lang('FolderEdited')); } else { Display::display_warning_message(get_lang('FileExists')); } } } } $work_data = get_work_data_by_id($work_parent->id); $action = ''; $row = array(); $class = ''; $course_id = api_get_course_int_id(); $session_id = api_get_session_id(); if (api_is_allowed_to_edit()) { $cant_files = get_count_work($work_data['id']); } else { $isSubscribed = userIsSubscribedToWork(api_get_user_id(), $work_data['id'], $course_id); if ($isSubscribed == false) { continue; } $cant_files = get_count_work($work_data['id'], api_get_user_id()); } $text_file = get_lang('FilesUpload'); if ($cant_files == 1) { $text_file = api_strtolower(get_lang('FileUpload')); } $icon = Display::return_icon('work.png', get_lang('Assignment'), array(), ICON_SIZE_SMALL); if (!empty($display_edit_form) && !empty($edit_dir) && $edit_dir == $id2) { $row[] = $icon; $row[] = '<span class="invisible" style="display:none">' . $dir . '</span>' . $form_folder->toHtml(); // form to edit the directory's name } else { $row[] = '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&origin=' . $origin . '&gradebook=' . $gradebook . '">' . $icon . '</a>'; $add_to_name = ''; require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/gradebook_functions.inc.php'; $link_info = is_resource_in_course_gradebook(api_get_course_id(), 3, $id2, api_get_session_id()); $link_id = $link_info['id']; $count = 0; if ($link_info !== false) { $gradebook_data = get_resource_from_course_gradebook($link_id); $count = $gradebook_data['weight']; } if ($count > 0) { $add_to_name = Display::label(get_lang('IncludedInEvaluation'), 'info'); } else { $add_to_name = ''; } $work_title = !empty($work_data['title']) ? $work_data['title'] : basename($work_data['url']); // Work name if ($cant_files > 0) { $zip = '<a href="downloadfolder.inc.php?id=' . $work_data['id'] . '">' . Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'), ICON_SIZE_SMALL) . '</a>'; } $link = 'work_list.php'; if (api_is_allowed_to_edit()) { $link = 'work_list_all.php'; } $url = $zip . '<a href="' . api_get_path(WEB_CODE_PATH) . 'work/' . $link . '?' . api_get_cidreq() . '&origin=' . $origin . '&gradebook=' . Security::remove_XSS($_GET['gradebook']) . '&id=' . $work_data['id'] . '"' . $class . '>' . $work_title . '</a> ' . $add_to_name . '<br />' . $cant_files . ' ' . $text_file . $dirtext; $row[] = $url; } if ($count_files != 0) { $row[] = ''; } if (!empty($homework)) { // use original utc value saved previously to avoid doubling the utc-to-local conversion ($homework['expires_on'] might have been tainted) $row[] = !empty($utc_expiry_time) && $utc_expiry_time != '0000-00-00 00:00:00' ? api_get_local_time($utc_expiry_time) : '-'; } else { $row[] = '-'; } if (!$is_allowed_to_edit) { if ($course_info['show_score'] == 0) { $url = api_get_path(WEB_CODE_PATH) . 'work/work_list_others.php?' . api_get_cidreq() . '&id=' . $work_parent->id; $row[] = Display::url(Display::return_icon('group.png', get_lang('Others')), $url); } } if ($origin != 'learnpath') { if ($is_allowed_to_edit) { $cant_files_per_user = getUniqueStudentAttempts($work_data['id'], $group_id, $course_id, api_get_session_id(), null, $userList); $row[] = $cant_files_per_user . '/' . count($userList); if (api_resource_is_locked_by_gradebook($id2, LINK_STUDENTPUBLICATION)) { $action .= Display::return_icon('edit_na.png', get_lang('Edit'), array(), ICON_SIZE_SMALL); $action .= Display::return_icon('delete_na.png', get_lang('Delete'), array(), ICON_SIZE_SMALL); } else { $action .= '<a href="' . api_get_self() . '?cidReq=' . api_get_course_id() . '&origin=' . $origin . '&gradebook=' . $gradebook . '&edit_dir=' . $id2 . '">' . Display::return_icon('edit.png', get_lang('Modify'), array(), ICON_SIZE_SMALL) . '</a>'; $action .= ' <a href="' . api_get_self() . '?' . api_get_cidreq() . '&origin=' . $origin . '&gradebook=' . $gradebook . '&delete_dir=' . $id2 . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . "'" . ')) return false;" title="' . get_lang('DirDelete') . '" >' . Display::return_icon('delete.png', get_lang('DirDelete'), '', ICON_SIZE_SMALL) . '</a>'; } $row[] = $action; } else { $row[] = ''; } } //$row[] = $direc_date_local; $row[] = $work_data['title']; $table_data[] = $row; } } $sorting_options = array(); $sorting_options['column'] = 1; // Here we change the way how the columns are going to be sorted // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48" $column_order = array(); $i = 0; foreach ($table_header as $item) { $column_order[$i] = $i; $i++; } if (empty($my_folder_data)) { $column_order[1] = 5; } else { $column_order[2] = 2; } // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide $column_show = array(); $column_show[] = 1; // type 0 $column_show[] = 1; // title 1 if (!empty($my_folder_data)) { $column_show[] = 1; // 2 $column_show[] = 1; // 3 if ($qualification_exists) { $column_show[] = 1; // 4 } } $column_show[] = 1; //date if ($table_has_actions_column) { $column_show[] = 1; // modify } $column_show[] = 1; //real date in correct format $column_show[] = 0; //real date in correct format $paging_options = array(); if (isset($_GET['curdirpath'])) { $my_params = array('curdirpath' => Security::remove_XSS($_GET['curdirpath'])); } $my_params = array('id' => isset($_GET['id']) ? $_GET['id'] : null); if (isset($_GET['edit_dir'])) { $my_params = array('edit_dir' => intval($_GET['edit_dir'])); } $my_params['origin'] = $origin; Display::display_sortable_config_table('work', $table_header, $table_data, $sorting_options, $paging_options, $my_params, $column_show, $column_order); }
/** * @param int $start * @param int $limit * @param string $column * @param string $direction * @param string $where_condition * @param bool $getCount * @return array */ function getWorkListTeacher($start, $limit, $column, $direction, $where_condition, $getCount = false) { $workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION); $workTableAssignment = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); $courseInfo = api_get_course_info(); $course_id = api_get_course_int_id(); $session_id = api_get_session_id(); $condition_session = api_get_session_condition($session_id); $group_id = api_get_group_id(); $is_allowed_to_edit = api_is_allowed_to_edit() || api_is_coach(); if (!in_array($direction, array('asc', 'desc'))) { $direction = 'desc'; } if (!empty($where_condition)) { $where_condition = ' AND ' . $where_condition; } $column = !empty($column) ? Database::escape_string($column) : 'sent_date'; $start = intval($start); $limit = intval($limit); $works = array(); // Get list from database if ($is_allowed_to_edit) { $active_condition = ' active IN (0, 1)'; if ($getCount) { $select = " SELECT count(w.id) as count"; } else { $select = " SELECT w.*, a.expires_on, expires_on, ends_on, enable_qualification "; } $sql = " {$select}\n FROM {$workTable} w\n LEFT JOIN {$workTableAssignment} a\n ON (a.publication_id = w.id AND a.c_id = w.c_id)\n WHERE\n w.c_id = {$course_id}\n {$condition_session} AND\n {$active_condition} AND\n (parent_id = 0) AND\n post_group_id = '" . $group_id . "'\n {$where_condition}\n ORDER BY {$column} {$direction}\n LIMIT {$start}, {$limit}"; $result = Database::query($sql); if ($getCount) { $row = Database::fetch_array($result); return $row['count']; } $url = api_get_path(WEB_CODE_PATH) . 'work/work_list_all.php?' . api_get_cidreq(); while ($work = Database::fetch_array($result, 'ASSOC')) { $workId = $work['id']; $work['type'] = Display::return_icon('work.png'); $work['expires_on'] = empty($work['expires_on']) ? null : api_get_local_time($work['expires_on']); $totalUsers = getStudentSubscribedToWork($workId, $course_id, $group_id, $session_id, true); $countUniqueAttempts = getUniqueStudentAttemptsTotal($workId, $group_id, $course_id, $session_id); $work['amount'] = Display::label($countUniqueAttempts . '/' . $totalUsers, 'success'); $visibility = api_get_item_visibility($courseInfo, 'work', $workId, $session_id); if ($visibility == 1) { $icon = 'visible.png'; $text = get_lang('Visible'); $action = 'invisible'; $class = ''; } else { $icon = 'invisible.png'; $text = get_lang('Invisible'); $action = 'visible'; $class = 'muted'; } $visibilityLink = Display::url(Display::return_icon($icon, $text, array(), ICON_SIZE_SMALL), api_get_path(WEB_CODE_PATH) . 'work/work.php?id=' . $workId . '&action=' . $action . '&' . api_get_cidreq()); if (empty($work['title'])) { $work['title'] = basename($work['url']); } $work['title'] = Display::url($work['title'], $url . '&id=' . $workId, ['class' => $class]); $work['title'] .= ' ' . Display::label(get_count_work($work['id']), 'success'); $work['sent_date'] = api_get_local_time($work['sent_date']); $editLink = Display::url(Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL), api_get_path(WEB_CODE_PATH) . 'work/edit_work.php?id=' . $workId . '&' . api_get_cidreq()); $correctionLink = Display::url(Display::return_icon('upload_file.png', get_lang('UploadCorrections'), '', ICON_SIZE_SMALL), api_get_path(WEB_CODE_PATH) . 'work/upload_corrections.php?' . api_get_cidreq() . '&id=' . $workId); if ($countUniqueAttempts > 0) { $downloadLink = Display::url(Display::return_icon('save_pack.png', get_lang('Save'), array(), ICON_SIZE_SMALL), api_get_path(WEB_CODE_PATH) . 'work/downloadfolder.inc.php?id=' . $workId . '&' . api_get_cidreq()); } else { $downloadLink = Display::url(Display::return_icon('save_pack_na.png', get_lang('Save'), array(), ICON_SIZE_SMALL), '#'); } // Remove Delete Work Button from action List // Because removeXSS "removes" the onClick JS Event to do the action (See model.ajax.php - Line 1639) // But still can use the another jqgrid button to remove works (trash icon) // // $deleteUrl = api_get_path(WEB_CODE_PATH).'work/work.php?id='.$workId.'&action=delete_dir&'.api_get_cidreq(); // $deleteLink = '<a href="#" onclick="showConfirmationPopup(this, \'' . $deleteUrl . '\' ) " >' . // Display::return_icon( // 'delete.png', // get_lang('Delete'), // array(), // ICON_SIZE_SMALL // ) . '</a>'; if (!api_is_allowed_to_edit()) { // $deleteLink = null; $editLink = null; } $work['actions'] = $visibilityLink . $correctionLink . $downloadLink . $editLink; $works[] = $work; } } return $works; }