Skip to content

Commit

Permalink
Backup: Get only courses as a teacher BT#17848
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Nov 23, 2020
1 parent 0607b35 commit 3f0490a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
35 changes: 19 additions & 16 deletions main/coursecopy/copy_course.php
Expand Up @@ -78,34 +78,37 @@
$hiddenFields['sec_token'] = Security::get_token();
CourseSelectForm::display_form($course, $hiddenFields, true);
} else {
$table_c = Database::get_main_table(TABLE_MAIN_COURSE);
$table_cu = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$user_info = api_get_user_info();
$course_info = api_get_course_info();

$courseList = CourseManager::get_courses_list_by_user_id(
$user_info['user_id'],
false,
$courseList = CourseManager::getCoursesFollowedByUser(
api_get_user_id(),
COURSEMANAGER,
null,
null,
null,
null,
false,
null,
null,
false,
[$course_info['real_id']]
'ORDER BY c.title'
);
$courses = [];
foreach ($courseList as $courseItem) {
if ($courseItem['real_id'] == $course_info['real_id']) {
continue;
}
$courses[$courseItem['code']] = $courseItem['title'].' ('.$courseItem['code'].')';
}

if (empty($courseList)) {
if (empty($courses)) {
echo Display::return_message(get_lang('NoDestinationCoursesAvailable'), 'normal');
} else {
$options = [];
foreach ($courseList as $courseItem) {
$courseInfo = api_get_course_info_by_id($courseItem['real_id']);
$options[$courseInfo['code']] = $courseInfo['title'].' ('.$courseInfo['code'].')';
}

$form = new FormValidator(
'copy_course',
'post',
api_get_path(WEB_CODE_PATH).'coursecopy/copy_course.php?'.api_get_cidreq()
);
$form->addElement('select', 'destination_course', get_lang('SelectDestinationCourse'), $options);
$form->addElement('select', 'destination_course', get_lang('SelectDestinationCourse'), $courses);

$group = [];
$group[] = $form->createElement('radio', 'copy_option', null, get_lang('FullCopy'), 'full_copy');
Expand Down
6 changes: 5 additions & 1 deletion main/inc/lib/course.lib.php
Expand Up @@ -3607,7 +3607,8 @@ public static function getCoursesFollowedByUser(
$getCount = false,
$keyword = null,
$sessionId = 0,
$showAllAssignedCourses = false
$showAllAssignedCourses = false,
$order = ''
) {
// Database Table Definitions
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
Expand Down Expand Up @@ -3647,6 +3648,9 @@ public static function getCoursesFollowedByUser(
}

$orderBy = null;
if (!empty($order)) {
$orderBy = Database::escape_string($order);
}
$extraInnerJoin = null;

if (!empty($sessionId)) {
Expand Down

0 comments on commit 3f0490a

Please sign in to comment.