internal override void ProcessQuestion(bool isNewQuestion) { if (isNewQuestion) { if (_index == _questIds.Count - 1) { _index = -1; } _index++; } try { int qId = _questIds[_index]; AppealResult appeal = TestClient.GetQuestionAppeal(_statistics.TestSessionId, qId, true); var htmlStore = HtmlStore.GetHtmlStore(appeal.TestorData, qId); htmlStore.IsAppeal = true; htmlStore.AppealIsRight = appeal.IsRightAnswer; htmlStore.Answer = appeal.Answer; _currentQuestion = htmlStore; } catch (Exception ex) { SystemMessage.ShowErrorMessage(ex); } }
public TestContentForm(TestorData data) { InitializeComponent(); _data = data; int i = 0; foreach (var test in ProjectState.TestHelpers.OrderBy(c => c.TestName)) { if (test.IsMasterTest) { continue; } if (test.IsTestorDataLoaded && test.TestorData == data) { _index = i; } tscbTests.Items.Add(test); i++; } tscbTests.SelectedIndex = _index; bool canBackForward = ProjectState.TestHelpers.Count > 1; tsbBackTest.Enabled = canBackForward; tsbForwardTest.Enabled = canBackForward; _provider = new EditProvider(HtmlStore.GetHtmlStore(_data, 1)); _provider.ProviderMode = ProviderMode.EditMode; TestingHttpServer.StartServer(_provider); TestingHttpServer.ServerNotStarted.WaitOne(); webBrowserQuestion.Navigate(TestingHttpServer.BaseUrl); }
public QuestAnswerResult ProcessAnswer(int questId, Dictionary <string, List <string> > requestParams) { Debug.Assert(questId > 0); QuestAnswerResult retValue = new QuestAnswerResult(); using (DataClassesTestorCoreDataContext dataContext = new DataClassesTestorCoreDataContext(TestorSecurityProvider.ConnectionString)) { var session = (from c in dataContext.TestSessions join x in dataContext.CoreTests on c.TestId equals x.TestId where c.EndTime == null && c.UserId == Provider.CurrentUser.UserId select new { x.TestId, x.TimeLimit, c.TestSessionId, c.StartTime, c.AdditionalTime }).First(); int timeLimit = session.TimeLimit; if (timeLimit != 0 && session.AdditionalTime.HasValue) { timeLimit += session.AdditionalTime.Value; } if (session.TimeLimit != 0 && (DateTime.Now - session.StartTime).TotalMinutes > timeLimit + 1) { throw new Exception("Время истекло"); } TestorData testorData = GetQuestion(questId, true, false, false); HtmlStore currentQuestion = HtmlStore.GetHtmlStore(testorData, questId); BaseQuestionProvider qp = QuestionsHtmlFactory.GetQuestionProvider(currentQuestion); string message = null; string answer = null; retValue.isRightAnswer = qp.IsRightAnswer(requestParams, ref message, ref answer); retValue.Message = message; retValue.Score = 0; if (!retValue.isRightAnswer.HasValue) { return(retValue); } if (retValue.isRightAnswer.Value) { retValue.Score = testorData.CoreQuestions.Where(c => c.QuestionId == questId).FirstOrDefault().QuestionMark; } var tsq = dataContext.TestSessionQuestions.Where( c => c.QuestionId == questId && c.TestSessionId == session.TestSessionId).First(); tsq.IsRightAnswer = retValue.isRightAnswer; tsq.Answer = answer; dataContext.SubmitChanges(); } return(retValue); }
internal override void ProcessQuestion(bool isNewQuestion) { if (isNewQuestion) { InitNextId(0); } if (State == ProviderState.Results) { return; } int qId = _questIds[_index]; _currentQuestion = HtmlStore.GetHtmlStore(_testorData, qId); }
private void bindingSourceQuest_CurrentItemChanged(object sender, EventArgs e) { if (bindingSourceQuest.CurrencyManager.Position == -1) { return; } TestorData.CoreQuestionsRow currentRow = ((bindingSourceQuest.Current as DataRowView).Row as TestorData.CoreQuestionsRow); tscbMark.SelectedIndex = (int)Math.Round(currentRow.QuestionMark, 0) - 1; try { _provider.SetHtmlStore(HtmlStore.GetHtmlStore(_data, currentRow.QuestionId)); webBrowserQuestion.Navigate(TestingHttpServer.BaseUrl); } catch { } }
internal override void ProcessQuestion(bool isNewQuestion) { if (_webServerProvider == null) { StartTestParams startParams = StaticServerProvider.TestClient.GetNotCommitedSessions(0, false); if (startParams != null && startParams.AdditionalTime.HasValue) { AdditionalTime = startParams.AdditionalTime.Value; OnTimeChanged(); } } if (isNewQuestion) { InitNextId(0); } if (State == ProviderState.Results) { return; } int qId = _questIds[_index]; try { bool getBlobs = _webServerProvider == null; if (_useCompression) { _currentQuestion = HtmlStore.GetHtmlStore(DataCompressor.DecompressData <TestorData>(TestClient.GetQuestion(qId, getBlobs)), qId); } else { _currentQuestion = HtmlStore.GetHtmlStore(TestClient.GetQuestionData(qId, getBlobs), qId); } } catch (TimeoutException) { _currentQuestion = null; } catch { State = ProviderState.Results; } }