/// <summary> /// Convert the ResultRecordType into the Result type. /// </summary> /// <param name="resultRecord">The ResultRecordType which /// specifies the assignment and score.</param> /// <returns>The corresponding Result</returns> private static LisResult GetResult(ResultRecordType resultRecord) { var result = new LisResult { SourcedId = resultRecord.sourcedGUID.sourcedId }; if (resultRecord.result != null) { // The LTI 1.1 specification states in 6.1.1. that the score in replaceResult should // always be formatted using “en” formatting // (http://www.imsglobal.org/LTI/v1p1p1/ltiIMGv1p1p1.html#_Toc330273034). const NumberStyles style = NumberStyles.Number | NumberStyles.AllowDecimalPoint; var culture = CultureInfo.CreateSpecificCulture(LtiConstants.ScoreLanguage); double value; if (double.TryParse(resultRecord.result.resultScore.textString, style, culture, out value)) { if (value >= 0 && value <= 1) { result.Score = value; } } } return result; }
/// <summary> /// Save or update the result (grade, score, outcome) in the consumer. /// </summary> /// <param name="result">The result to save or update.</param> /// <returns>True if the result was saved or updated.</returns> protected abstract bool ReplaceResult(LisResult result);