Minor - format code

pull/2487/head
jmontoyaa 7 years ago
parent 57ee762215
commit ea9f74d34a
  1. 41
      main/admin/course_add.php
  2. 71
      main/admin/course_edit.php
  3. 42
      main/admin/course_list.php
  4. 7
      main/auth/courses_categories.php
  5. 6
      main/inc/lib/api.lib.php

@ -78,24 +78,6 @@ $form->addText(
$form->applyFilter('visual_code', 'api_strtoupper');
$form->applyFilter('visual_code', 'html_filter');
$form->addRule(
'visual_code',
get_lang('Max'),
'maxlength',
CourseManager::MAX_COURSE_LENGTH_CODE
);
$form->addElement(
'select',
'course_teachers',
get_lang('CourseTeachers'),
$teachers,
[
'id' => 'course_teachers',
'multiple' => 'multiple'
]
);
$form->applyFilter('course_teachers', 'html_filter');
$countCategories = $courseCategoriesRepo->countAllInAccessUrl($accessUrlId);
@ -116,9 +98,8 @@ if ($countCategories >= 100) {
/** @var CourseCategory $category */
foreach ($categories as $category) {
$categoriesOptions[$category->getCode()] = $category;
$categoriesOptions[$category->getCode()] = (string) $category;
}
$form->addSelect(
'category_code',
get_lang('CourseFaculty'),
@ -126,6 +107,26 @@ if ($countCategories >= 100) {
);
}
$form->addRule(
'visual_code',
get_lang('Max'),
'maxlength',
CourseManager::MAX_COURSE_LENGTH_CODE
);
$form->addElement(
'select',
'course_teachers',
get_lang('CourseTeachers'),
$teachers,
[
'id' => 'course_teachers',
'multiple' => 'multiple'
]
);
$form->applyFilter('course_teachers', 'html_filter');
// Course department
$form->addText(
'department_name',

@ -143,6 +143,42 @@ $form->addText(
$form->applyFilter('visual_code', 'strtoupper');
$form->applyFilter('visual_code', 'html_filter');
$countCategories = $courseCategoriesRepo->countAllInAccessUrl($urlId);
if ($countCategories >= 100) {
// Category code
$url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_category';
$categorySelect = $form->addElement(
'select_ajax',
'category_code',
get_lang('CourseFaculty'),
null,
['url' => $url]
);
if (!empty($courseInfo['categoryCode'])) {
$data = \CourseCategory::getCategory($courseInfo['categoryCode']);
$categorySelect->addOption($data['name'], $data['code']);
}
} else {
$courseInfo['category_code'] = $courseInfo['categoryCode'];
$categories = $courseCategoriesRepo->findAllInAccessUrl($urlId);
$categoriesOptions = [null => get_lang('None')];
/** @var CourseCategory $category */
foreach ($categories as $category) {
$categoriesOptions[$category->getCode()] = (string) $category;
}
$form->addSelect(
'category_code',
get_lang('CourseFaculty'),
$categoriesOptions
);
}
$form->addElement(
'advmultiselect',
'course_teachers',
@ -199,41 +235,6 @@ if (!empty($coursesInSession)) {
}
}
$countCategories = $courseCategoriesRepo->countAllInAccessUrl($urlId);
if ($countCategories >= 100) {
// Category code
$url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_category';
$categorySelect = $form->addElement(
'select_ajax',
'category_code',
get_lang('CourseFaculty'),
null,
['url' => $url]
);
if (!empty($courseInfo['categoryCode'])) {
$data = \CourseCategory::getCategory($courseInfo['categoryCode']);
$categorySelect->addOption($data['name'], $data['code']);
}
} else {
$courseInfo['category_code'] = $courseInfo['categoryCode'];
$categories = $courseCategoriesRepo->findAllInAccessUrl($urlId);
$categoriesOptions = [null => get_lang('None')];
/** @var CourseCategory $category */
foreach ($categories as $category) {
$categoriesOptions[$category->getCode()] = $category;
}
$form->addSelect(
'category_code',
get_lang('CourseFaculty'),
$categoriesOptions
);
}
$form->addText('department_name', get_lang('CourseDepartment'), false, array('size' => '60'));
$form->applyFilter('department_name', 'html_filter');
$form->applyFilter('department_name', 'trim');

@ -146,17 +146,15 @@ function get_course_data($from, $number_of_items, $column, $direction)
$res = Database::query($sql);
$courses = array();
$languages = api_get_languages_to_array();
while ($course = Database::fetch_array($res)) {
// Place colour icons in front of courses.
$show_visual_code = $course['visual_code'] != $course[2] ? Display::label($course['visual_code'], 'info') : null;
$course[1] = get_course_visibility_icon($course[8]).'<a href="'.api_get_path(WEB_COURSE_PATH).$course[9].'/index.php">'.$course[1].'</a> '.$show_visual_code;
$course[5] = $course[5] == SUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
$course[6] = $course[6] == UNSUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
$language = isset($languages[$course[3]]) ? $languages[$course[3]] : $course[3];
$course_rem = array(
$courseItem = array(
$course[0],
$course[1],
$course[2],
@ -166,7 +164,7 @@ function get_course_data($from, $number_of_items, $column, $direction)
$course[6],
$course[7],
);
$courses[] = $course_rem;
$courses[] = $courseItem;
}
return $courses;
@ -258,19 +256,39 @@ function get_course_visibility_icon($v)
$style = 'margin-bottom:0;margin-right:5px;';
switch ($v) {
case 0:
return Display::return_icon('bullet_red.png', get_lang('CourseVisibilityClosed'), array('style' => $style));
return Display::return_icon(
'bullet_red.png',
get_lang('CourseVisibilityClosed'),
array('style' => $style)
);
break;
case 1:
return Display::return_icon('bullet_orange.png', get_lang('Private'), array('style' => $style));
return Display::return_icon(
'bullet_orange.png',
get_lang('Private'),
array('style' => $style)
);
break;
case 2:
return Display::return_icon('bullet_green.png', get_lang('OpenToThePlatform'), array('style' => $style));
return Display::return_icon(
'bullet_green.png',
get_lang('OpenToThePlatform'),
array('style' => $style)
);
break;
case 3:
return Display::return_icon('bullet_blue.png', get_lang('OpenToTheWorld'), array('style' => $style));
return Display::return_icon(
'bullet_blue.png',
get_lang('OpenToTheWorld'),
array('style' => $style)
);
break;
case 4:
return Display::return_icon('bullet_grey.png', get_lang('CourseVisibilityHidden'), array('style' => $style));
return Display::return_icon(
'bullet_grey.png',
get_lang('CourseVisibilityHidden'),
array('style' => $style)
);
break;
default:
return '';
@ -414,7 +432,11 @@ if (isset($_GET['search']) && $_GET['search'] === 'advanced') {
});
</script>';
$actions = Display::toolbarAction('toolbar', [$actions1, $actions2, $actions3, $actions4], [2, 4, 3, 3]);
$actions = Display::toolbarAction(
'toolbar',
[$actions1, $actions2, $actions3, $actions4],
[2, 4, 3, 3]
);
if (isset($_GET['session_id']) && !empty($_GET['session_id'])) {
// Create a sortable table with the course data filtered by session

@ -112,8 +112,7 @@ $code = isset($code) ? $code : null;
$categoryCode = $category['code'];
$countCourse = $category['count_courses'];
$form .= '<option '.($categoryCode == $codeType ? 'selected="selected" ' : '')
.' value="'
.$category['code'].'">'.$category['name'].' ( '.$countCourse.' ) </option>';
.' value="'.$category['code'].'">'.$category['name'].' ('.$countCourse.') </option>';
if (!empty($browse_course_categories[$categoryCode])) {
foreach ($browse_course_categories[$categoryCode] as $subCategory) {
$subCategoryCode = $subCategory['code'];
@ -121,9 +120,7 @@ $code = isset($code) ? $code : null;
.($subCategoryCode == $codeType
? 'selected="selected" '
: '')
.' value="'.$subCategory['code'].'">---'.$subCategory['name'].' ( '
.$subCategory['count_courses']
.' )</option>';
.' value="'.$subCategory['code'].'">---'.$subCategory['name'].' ('.$subCategory['count_courses'].')</option>';
}
}
}

@ -1852,13 +1852,13 @@ function api_get_course_info_by_id($id = null)
course_category.name faName
FROM $course_table
LEFT JOIN $course_cat_table
ON course.category_code = course_category.code
ON course.category_code = course_category.code
WHERE course.id = $id";
$result = Database::query($sql);
$_course = array();
if (Database::num_rows($result) > 0) {
$course_data = Database::fetch_array($result);
$_course = api_format_course_array($course_data);
$row = Database::fetch_array($result);
$_course = api_format_course_array($row);
}
return $_course;
}

Loading…
Cancel
Save