original_string: public static function result_for_json($grade, $endpoint, $typeid) {
  
          if (is_null($typeid)) {
              $id = "{$endpoint}/results?user_id={$grade->userid}";
          } else {
              $id = "{$endpoint}/results?type_id={$typeid}&user_id={$grade->userid}";
          }
          $result = new \stdClass();
          $result->id = $id;
          $result->userId = $grade->userid;
          if (!empty($grade->finalgrade)) {
              $result->resultScore = floatval($grade->finalgrade);
              $result->resultMaximum = floatval($grade->rawgrademax);
              if (!empty($grade->feedback)) {
                  $result->comment = $grade->feedback;
              }
              if (is_null($typeid)) {
                  $result->scoreOf = $endpoint;
              } else {
                  $result->scoreOf = "{$endpoint}?type_id={$typeid}";
              }
              $result->timestamp = date('c', $grade->timemodified);
          }
          return $result;
      }
code: public static function result_for_json($grade, $endpoint, $typeid) {
  
          if (is_null($typeid)) {
              $id = "{$endpoint}/results?user_id={$grade->userid}";
          } else {
              $id = "{$endpoint}/results?type_id={$typeid}&user_id={$grade->userid}";
          }
          $result = new \stdClass();
          $result->id = $id;
          $result->userId = $grade->userid;
          if (!empty($grade->finalgrade)) {
              $result->resultScore = floatval($grade->finalgrade);
              $result->resultMaximum = floatval($grade->rawgrademax);
              if (!empty($grade->feedback)) {
                  $result->comment = $grade->feedback;
              }
              if (is_null($typeid)) {
                  $result->scoreOf = $endpoint;
              } else {
                  $result->scoreOf = "{$endpoint}?type_id={$typeid}";
              }
              $result->timestamp = date('c', $grade->timemodified);
          }
          return $result;
      }
code_tokens: public static function result_for_json ( $ grade , $ endpoint , $ typeid ) { if ( is_null ( $ typeid ) ) { $ id = "{$endpoint}/results?user_id={$grade->userid}" ; } else { $ id = "{$endpoint}/results?type_id={$typeid}&user_id={$grade->userid}" ; } $ result = new \ stdClass ( ) ; $ result -> id = $ id ; $ result -> userId = $ grade -> userid ; if ( ! empty ( $ grade -> finalgrade ) ) { $ result -> resultScore = floatval ( $ grade -> finalgrade ) ; $ result -> resultMaximum = floatval ( $ grade -> rawgrademax ) ; if ( ! empty ( $ grade -> feedback ) ) { $ result -> comment = $ grade -> feedback ; } if ( is_null ( $ typeid ) ) { $ result -> scoreOf = $ endpoint ; } else { $ result -> scoreOf = "{$endpoint}?type_id={$typeid}" ; } $ result -> timestamp = date ( 'c' , $ grade -> timemodified ) ; } return $ result ; }
docstring: Get the object matching the JSON representation of the result.
  
  @param object  $grade              Grade record
  @param string  $endpoint           Endpoint for lineitem
  @param int  $typeid                The id of the type to include in the result url.
  
  @return object
docstring_tokens: Get the object matching the JSON representation of the result .