original_string: public function get_completed_courses() {
          global $DB;
  
          if ($this->get_feedback()->course != SITEID) {
              return [];
          }
  
          if ($this->allcourses !== null) {
              return $this->allcourses;
          }
  
          $courseselect = "SELECT fbc.courseid
              FROM {feedback_completed} fbc
              WHERE fbc.feedback = :feedbackid";
  
          $ctxselect = context_helper::get_preload_record_columns_sql('ctx');
  
          $sql = 'SELECT c.id, c.shortname, c.fullname, c.idnumber, c.visible, '. $ctxselect. '
                  FROM {course} c
                  JOIN {context} ctx ON c.id = ctx.instanceid AND ctx.contextlevel = :contextcourse
                  WHERE c.id IN ('. $courseselect.') ORDER BY c.sortorder';
          $list = $DB->get_records_sql($sql, ['contextcourse' => CONTEXT_COURSE, 'feedbackid' => $this->get_feedback()->id]);
  
          $this->allcourses = array();
          foreach ($list as $course) {
              context_helper::preload_from_record($course);
              if (!$course->visible &&
                  !has_capability('moodle/course:viewhiddencourses', context_course::instance($course->id), $this->userid)) {
                  // Do not return courses that current user can not see.
                  continue;
              }
              $label = get_course_display_name_for_list($course);
              $this->allcourses[$course->id] = $label;
          }
          return $this->allcourses;
      }
code: public function get_completed_courses() {
          global $DB;
  
          if ($this->get_feedback()->course != SITEID) {
              return [];
          }
  
          if ($this->allcourses !== null) {
              return $this->allcourses;
          }
  
          $courseselect = "SELECT fbc.courseid
              FROM {feedback_completed} fbc
              WHERE fbc.feedback = :feedbackid";
  
          $ctxselect = context_helper::get_preload_record_columns_sql('ctx');
  
          $sql = 'SELECT c.id, c.shortname, c.fullname, c.idnumber, c.visible, '. $ctxselect. '
                  FROM {course} c
                  JOIN {context} ctx ON c.id = ctx.instanceid AND ctx.contextlevel = :contextcourse
                  WHERE c.id IN ('. $courseselect.') ORDER BY c.sortorder';
          $list = $DB->get_records_sql($sql, ['contextcourse' => CONTEXT_COURSE, 'feedbackid' => $this->get_feedback()->id]);
  
          $this->allcourses = array();
          foreach ($list as $course) {
              context_helper::preload_from_record($course);
              if (!$course->visible &&
                  !has_capability('moodle/course:viewhiddencourses', context_course::instance($course->id), $this->userid)) {
                  // Do not return courses that current user can not see.
                  continue;
              }
              $label = get_course_display_name_for_list($course);
              $this->allcourses[$course->id] = $label;
          }
          return $this->allcourses;
      }
code_tokens: public function get_completed_courses ( ) { global $ DB ; if ( $ this -> get_feedback ( ) -> course != SITEID ) { return [ ] ; } if ( $ this -> allcourses !== null ) { return $ this -> allcourses ; } $ courseselect = "SELECT fbc.courseid
              FROM {feedback_completed} fbc
              WHERE fbc.feedback = :feedbackid" ; $ ctxselect = context_helper :: get_preload_record_columns_sql ( 'ctx' ) ; $ sql = 'SELECT c.id, c.shortname, c.fullname, c.idnumber, c.visible, ' . $ ctxselect . '
                  FROM {course} c
                  JOIN {context} ctx ON c.id = ctx.instanceid AND ctx.contextlevel = :contextcourse
                  WHERE c.id IN (' . $ courseselect . ') ORDER BY c.sortorder' ; $ list = $ DB -> get_records_sql ( $ sql , [ 'contextcourse' => CONTEXT_COURSE , 'feedbackid' => $ this -> get_feedback ( ) -> id ] ) ; $ this -> allcourses = array ( ) ; foreach ( $ list as $ course ) { context_helper :: preload_from_record ( $ course ) ; if ( ! $ course -> visible && ! has_capability ( 'moodle/course:viewhiddencourses' , context_course :: instance ( $ course -> id ) , $ this -> userid ) ) { // Do not return courses that current user can not see. continue ; } $ label = get_course_display_name_for_list ( $ course ) ; $ this -> allcourses [ $ course -> id ] = $ label ; } return $ this -> allcourses ; }
docstring: For the frontpage feedback returns the list of courses with at least one completed feedback
  
  @return array id=>name pairs of courses
docstring_tokens: For the frontpage feedback returns the list of courses with at least one completed feedback