Merge branch 'MDL-65211-master' of git://github.com/jleyva/moodle
authorDavid MonllaĆ³ <davidm@moodle.com>
Mon, 22 Apr 2019 08:23:49 +0000 (10:23 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 23 Apr 2019 11:42:33 +0000 (13:42 +0200)
1  2 
enrol/externallib.php

diff --combined enrol/externallib.php
@@@ -366,6 -366,7 +366,7 @@@ class core_enrol_external extends exter
              $progress = null;
              $completed = null;
              $completionhascriteria = false;
+             $completionusertracked = false;
  
              // Return only private information if the user should be able to see it.
              if ($sameuser || completion_can_view_data($userid, $course)) {
                      $completion = new completion_info($course);
                      $completed = $completion->is_course_complete($userid);
                      $completionhascriteria = $completion->has_criteria();
+                     $completionusertracked = $completion->is_tracked_user($userid);
                      $progress = \core_completion\progress::get_course_progress_percentage($course, $userid);
                  }
              }
                  'lang' => clean_param($course->lang, PARAM_LANG),
                  'enablecompletion' => $course->enablecompletion,
                  'completionhascriteria' => $completionhascriteria,
+                 'completionusertracked' => $completionusertracked,
                  'category' => $course->category,
                  'progress' => $progress,
                  'completed' => $completed,
                      'enablecompletion' => new external_value(PARAM_BOOL, 'true if completion is enabled, otherwise false',
                                                                  VALUE_OPTIONAL),
                      'completionhascriteria' => new external_value(PARAM_BOOL, 'If completion criteria is set.', VALUE_OPTIONAL),
+                     'completionusertracked' => new external_value(PARAM_BOOL, 'If the user is completion tracked.', VALUE_OPTIONAL),
                      'category' => new external_value(PARAM_INT, 'course category id', VALUE_OPTIONAL),
                      'progress' => new external_value(PARAM_FLOAT, 'Progress percentage', VALUE_OPTIONAL),
                      'completed' => new external_value(PARAM_BOOL, 'Whether the course is completed.', VALUE_OPTIONAL),
          self::validate_context(context_system::instance());
  
          $course = $DB->get_record('course', array('id' => $params['courseid']), '*', MUST_EXIST);
 -        $context = context_course::instance($course->id);
 -        if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $context)) {
 +        if (!core_course_category::can_view_course_info($course) && !can_access_course($course)) {
              throw new moodle_exception('coursehidden');
          }