private async Task <LmsQuizDTO> SendQuiz(string token, bool isSurvey, string json, Dictionary <string, object> licenseSettings) { json = json.Replace("\"", "\""); var pairs = new Dictionary <string, string> { { "wsfunction", isSurvey ? "local_edugamecloud_save_external_survey_report" : "local_edugamecloud_save_external_quiz_report" }, { "wstoken", token }, { "reportObject", json } }; var url = GetServicesUrl(licenseSettings); var xmlDoc = await UploadValues(url, pairs); string errorMessage = string.Empty; string err = string.Empty; var result = MoodleQuizParser.Parse(xmlDoc, ref errorMessage, ref err); if (!string.IsNullOrWhiteSpace(errorMessage) || !string.IsNullOrWhiteSpace(err)) { Logger.ErrorFormat("[EGCEnabledMoodleApi.SendAnswers.Parsing] LmsUserParametersId:{0}. IsSurvey:{1}. ErrorMessage:{2};{3}. JSON:{4}.", licenseSettings[LmsUserSettingNames.SessionId], isSurvey, errorMessage, err, json); } return(result); }
private async Task <LmsQuizDTO> GetQuiz(string token, bool isSurvey, int courseId, Dictionary <string, object> licenseSettings) { var pairs = new Dictionary <string, string> { { "wsfunction", isSurvey ? "local_edugamecloud_get_survey_by_id" : "local_edugamecloud_get_quiz_by_id" }, { "wstoken", token }, { isSurvey ? "surveyId" : "quizId", courseId.ToString(CultureInfo.InvariantCulture) } }; var url = GetServicesUrl(licenseSettings); var xmlDoc = await UploadValues(url, pairs); string errorMessage = string.Empty; string err = string.Empty; return(MoodleQuizParser.Parse(xmlDoc, ref errorMessage, ref err)); }