/// <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 Result GetResult(ResultRecordType resultRecord) { var result = new Result { 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 = new CultureInfo(LtiConstants.ScoreLanguage); if (double.TryParse(resultRecord.result.resultScore.textString, style, culture, out var value)) { if (value >= 0 && value <= 1) { result.Score = value; } } // Get the optional Canvas-style submission details result.Text = resultRecord.result.ResultData?.Text; result.Url = resultRecord.result.ResultData?.Url; result.LtiLaunchUrl = resultRecord.result.ResultData?.LtiLaunchUrl; } return(result); }
/// <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) { double value; if (double.TryParse(resultRecord.result.resultScore.textString, out value)) { if (value >= 0 && value <= 1) { result.Score = value; } } } return(result); }
/// <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> /// 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; }