course.ajax.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Responses to AJAX calls
  5. */
  6. $language_file[] = 'admin';
  7. require_once '../global.inc.php';
  8. $action = $_REQUEST['a'];
  9. $user_id = api_get_user_id();
  10. switch ($action) {
  11. case 'add_course_vote':
  12. $course_id = intval($_REQUEST['course_id']);
  13. $star = intval($_REQUEST['star']);
  14. if (!api_is_anonymous()) {
  15. CourseManager::add_course_vote($user_id, $star, $course_id, 0);
  16. }
  17. $point_info = CourseManager::get_course_ranking($course_id, 0);
  18. $ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
  19. $rating = Display::return_rating_system('star_'.$course_id, $ajax_url.'&amp;course_id='.$course_id, $point_info, false);
  20. echo $rating;
  21. break;
  22. case 'get_user_courses':
  23. if (api_is_platform_admin()) {
  24. $user_id = intval($_POST['user_id']);
  25. $list_course_all_info = CourseManager::get_courses_list_by_user_id($user_id, false);
  26. if (!empty($list_course_all_info)) {
  27. foreach($list_course_all_info as $course_item) {
  28. $course_info = api_get_course_info($course_item['code']);
  29. echo $course_info['title'].'<br />';
  30. }
  31. } else {
  32. echo get_lang('UserHasNoCourse');
  33. }
  34. }
  35. break;
  36. default:
  37. echo '';
  38. }
  39. exit;