public static void UpdateStats(Models.TestSolving.TestResults testResults, Models.Test test) { if (App.CurrentUser != null) { App.CurrentUser.Stats.UpdateWith(test, testResults); UpdateUser(App.CurrentUser); } }
public ResultsPage(Test test, Models.TestSolving.TestResults testResults) { this.test = test; this.testResults = testResults; Common.UserBase.UpdateStats(testResults, test); InitializeComponent(); var totalTime = (test.Mode == TimeMode.limitForTest ? 1 : test.Count) * test.TimeLimit.Value.TotalSeconds; var usedTime = testResults.UsedTime.TotalSeconds; var userPoints = testResults.TotalPoints; var totalPoints = test.Sum((q) => q.Points); EvaluateResultQuality( usedTime / totalTime, (double)userPoints / totalPoints.Value, (double)testResults.CorrectAnswers / test.Count ); PointsAmountLabel.Text = string.Format( "{0} points of {1}", userPoints.ToString(), totalPoints.ToString() ); TimeLabel.Text = string.Format( "You used {0} seconds of {1}", (int)(usedTime + 0.5), totalTime ); CorrectQLabel.Text = string.Format("Correct answers {0} of {1}", testResults.CorrectAnswers.ToString(), test.Count ); }
public MatchingQuestionPage(Test test, int currentQuestion, Models.TestSolving.TestResults testResults) { this.testResults = testResults; this.test = test; this.curQ = currentQuestion; startTime = DateTime.Now; answered = false; InitializeComponent(); MatchingQuestion question = (MatchingQuestion)test[curQ]; BindingContext = vm = new ViewModels.TestSolving.MatchingQSolveViewModel { Lefts = new ObservableCollection <QPart>( question.Lefts.Select((text) => new QPart { Text = text }) ), Rights = new ObservableCollection <QPart>( question.Rights.Select((text) => new QPart { Text = text }) ), Relation = new ObservableCollection <int?>( question.Relation ) }; QuestionLabel.Text = string.Join("", (curQ + 1).ToString(), ". ", test[curQ].Text ); limit = test.TimeLimit.Value; if (test.Mode == Models.TimeMode.limitForQuestion) { TimeLeftBar.Progress = 1; Device.StartTimer( TimeSpan.FromSeconds(0.1), () => { if (answered) { return(false); } if (PassedTime() >= limit) { TimeExpired(); return(false); } TimeLeftBar.Progress = (limit - PassedTime()).TotalSeconds / limit.TotalSeconds; return(true); } ); } else { TimeLeftBar.Progress = (limit - testResults.UsedTime).TotalSeconds / limit.TotalSeconds; Device.StartTimer( TimeSpan.FromSeconds(0.1), () => { if (answered) { return(false); } if (PassedTime() + testResults.UsedTime >= limit) { TestTimeExpired(); return(false); } TimeLeftBar.Progress = (limit - testResults.UsedTime - PassedTime()).TotalSeconds / limit.TotalSeconds; return(true); } ); } }
public MultipleChoiceQuestionPage(Test test, int currentQuestion, Models.TestSolving.TestResults testResults) { this.testResults = testResults; this.test = test; this.curQ = currentQuestion; startTime = DateTime.Now; answered = false; InitializeComponent(); var clonedList = ((Models.MultipleChoiceQuestion)test[curQ]).Variants.Select(objEntity => (Variant)objEntity.Clone()).ToList(); var Variants = new ObservableCollection <Variant>(clonedList); foreach (var variant in Variants) { variant.IsTrue = false; } BindingContext = vm = new ViewModels.Editor.MultipleChoiceQViewModel { Variants = Variants }; QuestionLabel.Text = string.Join("", (curQ + 1).ToString(), ". ", test[curQ].Text ); limit = test.TimeLimit.Value; if (test.Mode == Models.TimeMode.limitForQuestion) { TimeLeftBar.Progress = 1; Device.StartTimer( TimeSpan.FromSeconds(0.1), () => { if (answered) { return(false); } if (PassedTime() >= limit) { TimeExpired(); return(false); } TimeLeftBar.Progress = (limit - PassedTime()).TotalSeconds / limit.TotalSeconds; return(true); } ); } else { TimeLeftBar.Progress = (limit - testResults.UsedTime).TotalSeconds / limit.TotalSeconds; Device.StartTimer( TimeSpan.FromSeconds(0.1), () => { if (answered) { return(false); } if (PassedTime() + testResults.UsedTime >= limit) { TestTimeExpired(); return(false); } TimeLeftBar.Progress = (limit - testResults.UsedTime - PassedTime()).TotalSeconds / limit.TotalSeconds; return(true); } ); } }
public OpenQuestionPage(Models.Test test, int currentQuestion, Models.TestSolving.TestResults testResults) { this.testResults = testResults; this.test = test; this.curQ = currentQuestion; startTime = DateTime.Now; answered = false; InitializeComponent(); limit = test.TimeLimit.Value; if (test.Mode == Models.TimeMode.limitForQuestion) { TimeLeftBar.Progress = 1; Device.StartTimer( TimeSpan.FromSeconds(0.1), () => { if (answered) { return(false); } if (PassedTime() >= limit) { TimeExpired(); return(false); } TimeLeftBar.Progress = (limit - PassedTime()).TotalSeconds / limit.TotalSeconds; return(true); } ); } else { TimeLeftBar.Progress = (limit - testResults.UsedTime).TotalSeconds / limit.TotalSeconds; Device.StartTimer( TimeSpan.FromSeconds(0.1), () => { if (answered) { return(false); } if (PassedTime() + testResults.UsedTime >= limit) { TestTimeExpired(); return(false); } TimeLeftBar.Progress = (limit - testResults.UsedTime - PassedTime()).TotalSeconds / limit.TotalSeconds; return(true); } ); } QuestionLabel.Text = string.Join("", (currentQuestion + 1).ToString(), ". ", test[currentQuestion].Text ); }