original_string: public function get_student_grades($courseactivities) {
  
          if (empty($courseactivities)) {
              return array();
          }
  
          $grades = array();
          foreach ($courseactivities as $contextid => $instance) {
              $gradesinfo = grade_get_grades($this->course->id, 'mod', $instance->modname, $instance->instance, $this->studentids);
  
              // Sort them by activity context and user.
              if ($gradesinfo && $gradesinfo->items) {
                  foreach ($gradesinfo->items as $gradeitem) {
                      foreach ($gradeitem->grades as $userid => $grade) {
                          if (empty($grades[$contextid][$userid])) {
                              // Initialise it as array because a single activity can have multiple grade items (e.g. workshop).
                              $grades[$contextid][$userid] = array();
                          }
                          $grades[$contextid][$userid][$gradeitem->id] = $grade;
                      }
                  }
              }
          }
  
          return $grades;
      }
code: public function get_student_grades($courseactivities) {
  
          if (empty($courseactivities)) {
              return array();
          }
  
          $grades = array();
          foreach ($courseactivities as $contextid => $instance) {
              $gradesinfo = grade_get_grades($this->course->id, 'mod', $instance->modname, $instance->instance, $this->studentids);
  
              // Sort them by activity context and user.
              if ($gradesinfo && $gradesinfo->items) {
                  foreach ($gradesinfo->items as $gradeitem) {
                      foreach ($gradeitem->grades as $userid => $grade) {
                          if (empty($grades[$contextid][$userid])) {
                              // Initialise it as array because a single activity can have multiple grade items (e.g. workshop).
                              $grades[$contextid][$userid] = array();
                          }
                          $grades[$contextid][$userid][$gradeitem->id] = $grade;
                      }
                  }
              }
          }
  
          return $grades;
      }
code_tokens: public function get_student_grades ( $ courseactivities ) { if ( empty ( $ courseactivities ) ) { return array ( ) ; } $ grades = array ( ) ; foreach ( $ courseactivities as $ contextid => $ instance ) { $ gradesinfo = grade_get_grades ( $ this -> course -> id , 'mod' , $ instance -> modname , $ instance -> instance , $ this -> studentids ) ; // Sort them by activity context and user. if ( $ gradesinfo && $ gradesinfo -> items ) { foreach ( $ gradesinfo -> items as $ gradeitem ) { foreach ( $ gradeitem -> grades as $ userid => $ grade ) { if ( empty ( $ grades [ $ contextid ] [ $ userid ] ) ) { // Initialise it as array because a single activity can have multiple grade items (e.g. workshop). $ grades [ $ contextid ] [ $ userid ] = array ( ) ; } $ grades [ $ contextid ] [ $ userid ] [ $ gradeitem -> id ] = $ grade ; } } } } return $ grades ; }
docstring: Returns the course students grades.
  
  @param array $courseactivities
  @return array
docstring_tokens: Returns the course students grades .