Ejemplo n.º 1
0
        public static async Task GetSubmitAssessment(AssessmentData data, Action <SubmitAssessmentResponse> successCallback, Action <ResponseBase> errorCallback)
        {
            RestRequest             request = new RestRequest("/lms/api/submitassessment", Method.PUT);
            SubmitAssessmentRequest _SubmitAssessmentRequest = new SubmitAssessmentRequest()
            {
                UniqueAppId = App.UniqueAppId,
                Data        = data
            };

            request.AddBody(_SubmitAssessmentRequest);
            Debug.WriteLine(JsonConvert.SerializeObject(_SubmitAssessmentRequest));

            SubmitAssessmentResponse response = await APIServiceProvider.ServiceProvider.Execute <SubmitAssessmentResponse> (request);

            if ((response != null) && (response.ResponseCode == "1000"))
            {
                successCallback?.Invoke(response);
            }
            else
            {
                errorCallback?.Invoke((ResponseBase)response);
            }
        }
        public async void DoSubmit()
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                IsBusy                       = true;
                _AssessmentData              = new AssessmentData();
                _AssessmentData.CourseId     = _SelectedActivity.CourseId;
                _AssessmentData.UserName     = App.UserName;
                _AssessmentData.ActivityID   = _SelectedActivity.ActivityId;
                _AssessmentData.ActivityName = _SelectedActivity.ActivityName;
                _AssessmentData.AnswerList   = new List <Result> ();
                foreach (AssessmentViewModel vm in AssessmentQuestionList)
                {
                    _AssessmentData.AnswerList.Add(new Result()
                    {
                        Answer     = vm.Answer,
                        QuestionID = vm.Id
                    });
                }

                CourseHandler.GetSubmitAssessment(_AssessmentData,
                                                  (responseSubmitAssessment) => {
                    Debug.WriteLine("Success" + responseSubmitAssessment.ResponseCode + "/nMessage:" + responseSubmitAssessment.Status);
                    MessagingCenter.Send <AssessmentSubmitViewModel>(this, "AssessmentCompleted");
                    MessagingCenter.Send <AssessmentSubmitViewModel>(this, "ActivityCompleted");
                    NavigationHandler.GlobalNavigator.Navigation.PopModalAsync(true);
                    NavigationHandler.GlobalNavigator.Navigation.PopModalAsync(true);
                    NavigationHandler.GlobalNavigator.Navigation.PopModalAsync(false);
                    IsBusy = false;
                },
                                                  (errorSubmitAssessment) => {
                    NavigationHandler.GlobalNavigator.DisplayAlert(Constants.APP_NAME, Constants.ServerUnSuccess, Constants.OK_TEXT);
                    IsBusy = false;
                });
            }
        }