original_string: public static function get_course_user_profiles($userlist) {
          global $CFG, $USER, $DB;
          require_once($CFG->dirroot . "/user/lib.php");
          $params = self::validate_parameters(self::get_course_user_profiles_parameters(), array('userlist' => $userlist));
  
          $userids = array();
          $courseids = array();
          foreach ($params['userlist'] as $value) {
              $userids[] = $value['userid'];
              $courseids[$value['userid']] = $value['courseid'];
          }
  
          // Cache all courses.
          $courses = array();
          list($sqlcourseids, $params) = $DB->get_in_or_equal(array_unique($courseids), SQL_PARAMS_NAMED);
          $cselect = ', ' . context_helper::get_preload_record_columns_sql('ctx');
          $cjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)";
          $params['contextlevel'] = CONTEXT_COURSE;
          $coursesql = "SELECT c.* $cselect
                          FROM {course} c $cjoin
                         WHERE c.id $sqlcourseids";
          $rs = $DB->get_recordset_sql($coursesql, $params);
          foreach ($rs as $course) {
              // Adding course contexts to cache.
              context_helper::preload_from_record($course);
              // Cache courses.
              $courses[$course->id] = $course;
          }
          $rs->close();
  
          list($sqluserids, $params) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
          $uselect = ', ' . context_helper::get_preload_record_columns_sql('ctx');
          $ujoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = u.id AND ctx.contextlevel = :contextlevel)";
          $params['contextlevel'] = CONTEXT_USER;
          $usersql = "SELECT u.* $uselect
                        FROM {user} u $ujoin
                       WHERE u.id $sqluserids";
          $users = $DB->get_recordset_sql($usersql, $params);
          $result = array();
          foreach ($users as $user) {
              if (!empty($user->deleted)) {
                  continue;
              }
              context_helper::preload_from_record($user);
              $course = $courses[$courseids[$user->id]];
              $context = context_course::instance($courseids[$user->id], IGNORE_MISSING);
              self::validate_context($context);
              if ($userarray = user_get_user_details($user, $course)) {
                  $result[] = $userarray;
              }
          }
  
          $users->close();
  
          return $result;
      }
code: public static function get_course_user_profiles($userlist) {
          global $CFG, $USER, $DB;
          require_once($CFG->dirroot . "/user/lib.php");
          $params = self::validate_parameters(self::get_course_user_profiles_parameters(), array('userlist' => $userlist));
  
          $userids = array();
          $courseids = array();
          foreach ($params['userlist'] as $value) {
              $userids[] = $value['userid'];
              $courseids[$value['userid']] = $value['courseid'];
          }
  
          // Cache all courses.
          $courses = array();
          list($sqlcourseids, $params) = $DB->get_in_or_equal(array_unique($courseids), SQL_PARAMS_NAMED);
          $cselect = ', ' . context_helper::get_preload_record_columns_sql('ctx');
          $cjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)";
          $params['contextlevel'] = CONTEXT_COURSE;
          $coursesql = "SELECT c.* $cselect
                          FROM {course} c $cjoin
                         WHERE c.id $sqlcourseids";
          $rs = $DB->get_recordset_sql($coursesql, $params);
          foreach ($rs as $course) {
              // Adding course contexts to cache.
              context_helper::preload_from_record($course);
              // Cache courses.
              $courses[$course->id] = $course;
          }
          $rs->close();
  
          list($sqluserids, $params) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
          $uselect = ', ' . context_helper::get_preload_record_columns_sql('ctx');
          $ujoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = u.id AND ctx.contextlevel = :contextlevel)";
          $params['contextlevel'] = CONTEXT_USER;
          $usersql = "SELECT u.* $uselect
                        FROM {user} u $ujoin
                       WHERE u.id $sqluserids";
          $users = $DB->get_recordset_sql($usersql, $params);
          $result = array();
          foreach ($users as $user) {
              if (!empty($user->deleted)) {
                  continue;
              }
              context_helper::preload_from_record($user);
              $course = $courses[$courseids[$user->id]];
              $context = context_course::instance($courseids[$user->id], IGNORE_MISSING);
              self::validate_context($context);
              if ($userarray = user_get_user_details($user, $course)) {
                  $result[] = $userarray;
              }
          }
  
          $users->close();
  
          return $result;
      }
code_tokens: public static function get_course_user_profiles ( $ userlist ) { global $ CFG , $ USER , $ DB ; require_once ( $ CFG -> dirroot . "/user/lib.php" ) ; $ params = self :: validate_parameters ( self :: get_course_user_profiles_parameters ( ) , array ( 'userlist' => $ userlist ) ) ; $ userids = array ( ) ; $ courseids = array ( ) ; foreach ( $ params [ 'userlist' ] as $ value ) { $ userids [ ] = $ value [ 'userid' ] ; $ courseids [ $ value [ 'userid' ] ] = $ value [ 'courseid' ] ; } // Cache all courses. $ courses = array ( ) ; list ( $ sqlcourseids , $ params ) = $ DB -> get_in_or_equal ( array_unique ( $ courseids ) , SQL_PARAMS_NAMED ) ; $ cselect = ', ' . context_helper :: get_preload_record_columns_sql ( 'ctx' ) ; $ cjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)" ; $ params [ 'contextlevel' ] = CONTEXT_COURSE ; $ coursesql = "SELECT c.* $cselect
                          FROM {course} c $cjoin
                         WHERE c.id $sqlcourseids" ; $ rs = $ DB -> get_recordset_sql ( $ coursesql , $ params ) ; foreach ( $ rs as $ course ) { // Adding course contexts to cache. context_helper :: preload_from_record ( $ course ) ; // Cache courses. $ courses [ $ course -> id ] = $ course ; } $ rs -> close ( ) ; list ( $ sqluserids , $ params ) = $ DB -> get_in_or_equal ( $ userids , SQL_PARAMS_NAMED ) ; $ uselect = ', ' . context_helper :: get_preload_record_columns_sql ( 'ctx' ) ; $ ujoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = u.id AND ctx.contextlevel = :contextlevel)" ; $ params [ 'contextlevel' ] = CONTEXT_USER ; $ usersql = "SELECT u.* $uselect
                        FROM {user} u $ujoin
                       WHERE u.id $sqluserids" ; $ users = $ DB -> get_recordset_sql ( $ usersql , $ params ) ; $ result = array ( ) ; foreach ( $ users as $ user ) { if ( ! empty ( $ user -> deleted ) ) { continue ; } context_helper :: preload_from_record ( $ user ) ; $ course = $ courses [ $ courseids [ $ user -> id ] ] ; $ context = context_course :: instance ( $ courseids [ $ user -> id ] , IGNORE_MISSING ) ; self :: validate_context ( $ context ) ; if ( $ userarray = user_get_user_details ( $ user , $ course ) ) { $ result [ ] = $ userarray ; } } $ users -> close ( ) ; return $ result ; }
docstring: Get course participant's details
  
  @param array $userlist  array of user ids and according course ids
  @return array An array of arrays describing course participants
  @since Moodle 2.2
docstring_tokens: Get course participant s details