original_string: public static function get_grades($workshopid, $userid = 0) {
          global $USER;
  
          $params = array(
              'workshopid' => $workshopid,
              'userid' => $userid,
          );
          $params = self::validate_parameters(self::get_grades_parameters(), $params);
          $warnings = array();
  
          list($workshop, $course, $cm, $context) = self::validate_workshop($params['workshopid']);
  
          // Extra checks so only users with permissions can view other users plans.
          if (empty($params['userid']) || $params['userid'] == $USER->id) {
              $userid = $USER->id;
          } else {
              require_capability('mod/workshop:viewallassessments', $context);
              $user = core_user::get_user($params['userid'], '*', MUST_EXIST);
              core_user::require_active_user($user);
              if (!$workshop->check_group_membership($user->id)) {
                  throw new moodle_exception('notingroup');
              }
              $userid = $user->id;
          }
  
          $finalgrades = $workshop->get_gradebook_grades($userid);
  
          $result = array('warnings' => $warnings);
          if ($finalgrades !== false) {
              if (!empty($finalgrades->submissiongrade)) {
                  if (is_numeric($finalgrades->submissiongrade->grade)) {
                      $result['submissionrawgrade'] = $finalgrades->submissiongrade->grade;
                  }
                  $result['submissionlongstrgrade'] = $finalgrades->submissiongrade->str_long_grade;
                  $result['submissiongradehidden'] = $finalgrades->submissiongrade->hidden;
              }
              if (!empty($finalgrades->assessmentgrade)) {
                  if (is_numeric($finalgrades->assessmentgrade->grade)) {
                      $result['assessmentrawgrade'] = $finalgrades->assessmentgrade->grade;
                  }
                  $result['assessmentlongstrgrade'] = $finalgrades->assessmentgrade->str_long_grade;
                  $result['assessmentgradehidden'] = $finalgrades->assessmentgrade->hidden;
              }
          }
  
          return $result;
      }
code: public static function get_grades($workshopid, $userid = 0) {
          global $USER;
  
          $params = array(
              'workshopid' => $workshopid,
              'userid' => $userid,
          );
          $params = self::validate_parameters(self::get_grades_parameters(), $params);
          $warnings = array();
  
          list($workshop, $course, $cm, $context) = self::validate_workshop($params['workshopid']);
  
          // Extra checks so only users with permissions can view other users plans.
          if (empty($params['userid']) || $params['userid'] == $USER->id) {
              $userid = $USER->id;
          } else {
              require_capability('mod/workshop:viewallassessments', $context);
              $user = core_user::get_user($params['userid'], '*', MUST_EXIST);
              core_user::require_active_user($user);
              if (!$workshop->check_group_membership($user->id)) {
                  throw new moodle_exception('notingroup');
              }
              $userid = $user->id;
          }
  
          $finalgrades = $workshop->get_gradebook_grades($userid);
  
          $result = array('warnings' => $warnings);
          if ($finalgrades !== false) {
              if (!empty($finalgrades->submissiongrade)) {
                  if (is_numeric($finalgrades->submissiongrade->grade)) {
                      $result['submissionrawgrade'] = $finalgrades->submissiongrade->grade;
                  }
                  $result['submissionlongstrgrade'] = $finalgrades->submissiongrade->str_long_grade;
                  $result['submissiongradehidden'] = $finalgrades->submissiongrade->hidden;
              }
              if (!empty($finalgrades->assessmentgrade)) {
                  if (is_numeric($finalgrades->assessmentgrade->grade)) {
                      $result['assessmentrawgrade'] = $finalgrades->assessmentgrade->grade;
                  }
                  $result['assessmentlongstrgrade'] = $finalgrades->assessmentgrade->str_long_grade;
                  $result['assessmentgradehidden'] = $finalgrades->assessmentgrade->hidden;
              }
          }
  
          return $result;
      }
code_tokens: public static function get_grades ( $ workshopid , $ userid = 0 ) { global $ USER ; $ params = array ( 'workshopid' => $ workshopid , 'userid' => $ userid , ) ; $ params = self :: validate_parameters ( self :: get_grades_parameters ( ) , $ params ) ; $ warnings = array ( ) ; list ( $ workshop , $ course , $ cm , $ context ) = self :: validate_workshop ( $ params [ 'workshopid' ] ) ; // Extra checks so only users with permissions can view other users plans. if ( empty ( $ params [ 'userid' ] ) || $ params [ 'userid' ] == $ USER -> id ) { $ userid = $ USER -> id ; } else { require_capability ( 'mod/workshop:viewallassessments' , $ context ) ; $ user = core_user :: get_user ( $ params [ 'userid' ] , '*' , MUST_EXIST ) ; core_user :: require_active_user ( $ user ) ; if ( ! $ workshop -> check_group_membership ( $ user -> id ) ) { throw new moodle_exception ( 'notingroup' ) ; } $ userid = $ user -> id ; } $ finalgrades = $ workshop -> get_gradebook_grades ( $ userid ) ; $ result = array ( 'warnings' => $ warnings ) ; if ( $ finalgrades !== false ) { if ( ! empty ( $ finalgrades -> submissiongrade ) ) { if ( is_numeric ( $ finalgrades -> submissiongrade -> grade ) ) { $ result [ 'submissionrawgrade' ] = $ finalgrades -> submissiongrade -> grade ; } $ result [ 'submissionlongstrgrade' ] = $ finalgrades -> submissiongrade -> str_long_grade ; $ result [ 'submissiongradehidden' ] = $ finalgrades -> submissiongrade -> hidden ; } if ( ! empty ( $ finalgrades -> assessmentgrade ) ) { if ( is_numeric ( $ finalgrades -> assessmentgrade -> grade ) ) { $ result [ 'assessmentrawgrade' ] = $ finalgrades -> assessmentgrade -> grade ; } $ result [ 'assessmentlongstrgrade' ] = $ finalgrades -> assessmentgrade -> str_long_grade ; $ result [ 'assessmentgradehidden' ] = $ finalgrades -> assessmentgrade -> hidden ; } } return $ result ; }
docstring: Returns the grades information for the given workshop and user.
  
  @param int $workshopid workshop instance id
  @param int $userid user id
  @return array of warnings and the user plan
  @since Moodle 3.4
  @throws  moodle_exception
docstring_tokens: Returns the grades information for the given workshop and user .