public static void AddToDataset(TestorData dataSet, TestorData.CoreTestsRow testRow, HtmlStore[] store) { if (dataSet == null) { return; } foreach (var question in store.OrderBy(c => c.QuestIndex)) { TestorData.CoreQuestionsRow newRow = dataSet.CoreQuestions.NewCoreQuestionsRow(); newRow.QuestionId = question.QuestIndex; newRow.QuestionType = (byte)question.QuestionType; newRow.Question = question.Html; newRow.TestId = testRow.TestId; newRow.QuestionMark = 1; dataSet.CoreQuestions.AddCoreQuestionsRow(newRow); ProcessBLOBs(dataSet, question, newRow.QuestionId); foreach (var answer in question.SubItems) { TestorData.CoreAnswersRow ansRow = dataSet.CoreAnswers.NewCoreAnswersRow(); ansRow.QuestionId = newRow.QuestionId; ansRow.Answer = answer.Html; ansRow.IsTrue = answer.IsTrue; dataSet.CoreAnswers.AddCoreAnswersRow(ansRow); ProcessBLOBs(dataSet, answer, newRow.QuestionId); } } }
public static void CreateMasterTest() { InputBox ib = new InputBox("Имя мастер теста", "Введите имя мастер теста:"); if (ib.ShowDialog() != DialogResult.OK) { return; } if (ProjectState.TestHelpers.Where(c => c.TestName == ib.Input).Count() > 0) { SystemMessage.ShowWarningMessage("Данное имя теста уже используется."); return; } TestorData td = new TestorData(); TestorData.CoreTestsRow testRow = HtmlStore.CreateCoreTest(td, ib.Input); testRow.IsMasterTest = true; td.CoreTests.AddCoreTestsRow(testRow); TestHelper testHelper = new TestHelper(ProjectState.DataPackageManager); testHelper.TestKey = testRow.TestKey.ToString(); testHelper.ConvTime = DateTime.Now; testHelper.FullFileName = String.Empty; testHelper.TestorData = td; testHelper.TestName = ib.Input; testHelper.QuestCount = 0; testHelper.IsMasterTest = true; List <TestHelper> helperList = new List <TestHelper>(); helperList.Add(testHelper); ProjectState.AddTests(helperList); }
public void CreateMasterTest(string testName) { TestorData data = new TestorData(); TestorData.CoreTestsRow row = HtmlStore.CreateCoreTest(data, testName); row.IsMasterTest = true; data.CoreTests.Rows.Add(row); SendTests(data, new List<int>()); }
public static TestorData GetDataSet(HtmlStore[] store, string testName) { TestorData retValue = new TestorData(); TestorData.CoreTestsRow testRow = CreateCoreTest(retValue, testName); retValue.CoreTests.AddCoreTestsRow(testRow); HtmlStore.AddToDataset(retValue, testRow, store); return(retValue); }
public TestorData GetTestSettingsData(int testId) { using (DataClassesTestorCoreDataContext dataContext = new DataClassesTestorCoreDataContext(TestorSecurityProvider.ConnectionString)) { CoreTest test = dataContext.CoreTests.Where(c => c.TestId == testId).FirstOrDefault(); TestorData data = new TestorData(); TestorData.CoreTestsRow coreTestRow = data.CoreTests.NewCoreTestsRow(); coreTestRow.AllowAdmitQuestions = test.AllowAdmitQuestions; coreTestRow.BeginTime = test.BeginTime; coreTestRow.Description = test.Description; coreTestRow.EndTime = test.EndTime; coreTestRow.IsActive = test.IsActive; coreTestRow.IsMasterTest = test.IsMasterTest; coreTestRow.PassagesNumber = test.PassagesNumber; coreTestRow.PassingScore = test.PassingScore; coreTestRow.QuestionsNumber = test.QuestionsNumber; coreTestRow.IsDeleted = test.IsDeleted; if (coreTestRow.QuestionsNumber == 0) { if (test.IsMasterTest) { var masterParts = dataContext.CoreMasterParts.Where(c => c.MasterTestId == testId); if (masterParts.Count() > 0) { coreTestRow.QuestionsNumber = (short)masterParts.Sum(c => c.QuestionsNumber); } else { coreTestRow.QuestionsNumber = 0; } } else { coreTestRow.QuestionsNumber = (short)test.CoreQuestions.Count(); } } coreTestRow.ShowRightAnswersCount = test.ShowRightAnswersCount; coreTestRow.ShowTestResult = test.ShowTestResult; coreTestRow.ShowDetailsTestResult = test.ShowDetailsTestResult; coreTestRow.TestId = test.TestId; coreTestRow.TestKey = test.TestKey; coreTestRow.TestName = test.TestName; coreTestRow.TimeLimit = test.TimeLimit; coreTestRow.VariantsMode = test.VariantsMode; coreTestRow.AdaptiveMode = test.AdaptiveMode; data.CoreTests.AddCoreTestsRow(coreTestRow); return(data); } }
protected void Page_Load(object sender, EventArgs e) { this.LoadComplete += new EventHandler(TestingForm_LoadComplete); warningMessage.Visible = false; RemoteTestingProvider provider = null; StartTestParams startParams = LocalUser.TestClient.GetNotCommitedSessions(0, false); if (Session[SESSIONPROVIDER] == null) { if (startParams == null) { Response.Redirect("~/Default.aspx"); } var testSettings = startParams.TestSettings; TestorData.CoreTestsRow coreTest = testSettings.CoreTests[0]; TestorTreeItem selectedTest = new TestorTreeItem(0, coreTest.TestId, coreTest.TestName, coreTest.IsMasterTest ? TestorItemType.MasterTest : TestorItemType.Test, null); provider = new RemoteTestingProvider(LocalUser.WebServerProvider, selectedTest, testSettings, startParams, false); provider.ProviderMode = ProviderMode.WebMode; Session[SESSIONPROVIDER] = provider; } else { provider = (RemoteTestingProvider)Session[SESSIONPROVIDER]; if (provider == null || provider.State == ProviderState.Results) { Session[SESSIONPROVIDER] = null; if (LocalUser.IsIntranet && provider.CurrentUser.UserRole == TestorUserRole.Student) { FormsAuthentication.SignOut(); } Response.Redirect("~/Default.aspx"); } provider.UnsubscribeWarningMessage(); } provider.CurrentUniqId = (string)Session["UniqId"]; if (startParams != null && startParams.AdditionalTime.HasValue) { provider.AdditionalTime = startParams.AdditionalTime.Value; } if (!IsPostBack) { string testName = String.Format("«{0}»", provider.TestName); (this.Master.FindControl("LabelTest") as Label).Text = testName + " :: <i>" + provider.StudentDisplayName + "</i>"; this.Title = String.Format("Студент - \"{0}\"", provider.StudentDisplayName); } TestingHost.InitTestingProcess(provider, ClientScript); }
public void SetTestSettings(byte[] testSettings) { Debug.Assert(testSettings != null); Provider.TestRoles(TestorUserRole.Administrator, TestorUserRole.Teacher, TestorUserRole.Laboratorian); using (DataClassesTestorCoreDataContext dataContext = new DataClassesTestorCoreDataContext(TestorSecurityProvider.ConnectionString)) { TestorData data = DataCompressor.DecompressData <TestorData>(testSettings); TestorData.CoreTestsRow test = data.CoreTests[0]; Provider.TestCoreTestsAccess(test.TestId); CoreTest coreTest = dataContext.CoreTests.Where(c => c.TestId == test.TestId).FirstOrDefault(); CreateCoreTest(test, coreTest); dataContext.SubmitChanges(); } }
//Не является операцией сервиса private void CreateCoreTest(TestorData.CoreTestsRow coreTest, CoreTest test) { test.TestName = coreTest.TestName; test.Description = coreTest.Description; test.QuestionsNumber = coreTest.QuestionsNumber; test.VariantsMode = coreTest.VariantsMode; test.PassagesNumber = coreTest.PassagesNumber; test.PassingScore = coreTest.PassingScore; test.TimeLimit = coreTest.TimeLimit; test.BeginTime = coreTest.BeginTime; test.EndTime = coreTest.EndTime; test.AllowAdmitQuestions = coreTest.AllowAdmitQuestions; test.ShowTestResult = coreTest.ShowTestResult; test.ShowDetailsTestResult = coreTest.ShowDetailsTestResult; test.ShowRightAnswersCount = coreTest.ShowRightAnswersCount; test.IsActive = coreTest.IsActive; test.AdaptiveMode = coreTest.AdaptiveMode; }
public TestorTreeItem CreateFolder(int parentId, string folderName) { Debug.Assert(parentId >= 0); Debug.Assert(!String.IsNullOrEmpty(folderName)); Provider.TestRoles(TestorUserRole.Administrator, TestorUserRole.Teacher, TestorUserRole.Laboratorian); using (DataClassesTestorCoreDataContext dataContext = new DataClassesTestorCoreDataContext(TestorSecurityProvider.ConnectionString)) { TestorData td = new TestorData(); TestorData.CoreTestsRow testRow = HtmlStore.CreateCoreTest(td, folderName); CoreTest coreTest = new CoreTest(); CreateCoreTest(testRow, coreTest); dataContext.CoreTests.InsertOnSubmit(coreTest); dataContext.SubmitChanges(); int result = dataContext.AddTestTreeItem(GetId(parentId), (int)TestorItemType.Folder, coreTest.TestId, Provider.CurrentUser.UserId); TestorTreeItem retValue = new TestorTreeItem( result, coreTest.TestId, folderName, TestorItemType.Folder, new TestorTreeItem[] { }); retValue.ItemOwner = Provider.CurrentUser.UserId; return(retValue); } }
private CoreTestRowAdapter(TestorData.CoreTestsRow row) { TestId = row.TestId; TestName = row.TestName; TestKey = row.TestKey; Description = row.Description; QuestionsNumber = row.QuestionsNumber; VariantsMode = row.VariantsMode; PassagesNumber = row.PassagesNumber; PassingScore = row.PassingScore; TimeLimit = row.TimeLimit; BeginTime = row.BeginTime; EndTime = row.EndTime; AllowAdmitQuestions = row.AllowAdmitQuestions; ShowTestResult = row.ShowTestResult; ShowDetailsTestResult = row.ShowDetailsTestResult; ShowRightAnswersCount = row.ShowRightAnswersCount; IsActive = row.IsActive; IsMasterTest = row.IsMasterTest; AdaptiveMode = row.AdaptiveMode; IsDeleted = row.IsDeleted; }
public static TestorData.CoreTestsRow CreateCoreTest(TestorData data, string testName) { TestorData.CoreTestsRow testRow = data.CoreTests.NewCoreTestsRow(); testRow.TestKey = Guid.NewGuid(); testRow.TestName = testName; testRow.VariantsMode = true; testRow.IsActive = true; testRow.IsMasterTest = false; testRow.ShowRightAnswersCount = true; testRow.ShowDetailsTestResult = false; testRow.ShowTestResult = true; testRow.AllowAdmitQuestions = true; testRow.Description = String.Empty; testRow.QuestionsNumber = 0; testRow.PassagesNumber = 0; testRow.PassingScore = 0; testRow.TimeLimit = 0; testRow.BeginTime = DateTime.MinValue; testRow.EndTime = DateTime.MinValue; testRow.AdaptiveMode = (short)TestorAdaptiveMode.None; testRow.IsDeleted = false; return(testRow); }
public TestSettingsAdapter(TestorData data) { _data = data; _currentRow = _data.CoreTests[0]; }
public static TestorData.CoreTestsRow AddToDataset(TestorData dataSet, HtmlStore[] store) { TestorData.CoreTestsRow retValue = CreateCoreTest(dataSet, String.Empty); AddToDataset(dataSet, retValue, store); return(retValue); }
public TestSettingsAdapter(TestHelper testHelper) { _testHelper = testHelper; _data = _testHelper.TestorData; _currentRow = _data.CoreTests[0]; }
protected void Page_Load(object sender, EventArgs e) { if (LocalUser.IsIntranet && !Context.User.Identity.IsAuthenticated) { Response.Redirect("~/Login.aspx"); } StartTestParams ncs = LocalUser.TestClient.GetNotCommitedSessions(0, false); if (ncs != null) { Server.Transfer("~/Testing.aspx"); } MultiViewMain.ActiveViewIndex = 0; LabelTestname.Visible = false; requirementsPanel.Visible = false; if (Context.User.Identity.IsAuthenticated) { var currentUser = LocalUser.SecurityProvider.CurrentUser; if (currentUser == null) { FormsAuthentication.SignOut(); Response.Redirect("~/Login.aspx"); } string userName = String.Format(":: {0} {1} {2}", HtmlStore.GetString(currentUser.LastName), HtmlStore.GetString(currentUser.FirstName), HtmlStore.GetString(currentUser.SecondName)); Label lbl = (this.Master.FindControl("userName") as Label); if (String.IsNullOrEmpty(userName.Trim())) { lbl.Text = currentUser.Login; } else { lbl.Text = userName; } } if (InitPageMode()) { InitTree(); } else { InitTestList(); InitNavigator(); if (_currentItem.ItemType == TestorItemType.Test || _currentItem.ItemType == TestorItemType.MasterTest) { MultiViewMain.ActiveViewIndex = 2; postButton.Text = "Приступить к тестированию"; _currentTest = DataCompressor.DecompressData <TestorData>( LocalUser.TestEdit.GetTestSettings(_currentItem.TestId.Value)); testDetails.Text = HttpHandler.GetPreTestingHtml(_currentTest.CoreTests[0]); TestorData.CoreTestsRow test = _currentTest.CoreTests[0]; LabelTestname.Visible = true; RemoteTestingProvider _provider = new RemoteTestingProvider(LocalUser.WebServerProvider, _currentItem, _currentTest, null, false); if (!_provider.IsTestActive) { postButton.Enabled = false; LabelTestname.ForeColor = Color.Red; LabelTestname.Text = _provider.NotActiveMessage; if (_provider.RequirementsTests != null) { postButton.Enabled = false; LabelTestname.Text = "Перед прохлждением данного теста необходимо пройти предыдущие тесты"; LabelTestname.ForeColor = Color.Red; requirementsPanel.Visible = true; requirementsRepeater.DataSource = _provider.RequirementsTests; requirementsRepeater.DataBind(); } return; } if (LocalUser.SecurityProvider.CurrentUser.UserRole == TestorUserRole.Administrator || LocalUser.SecurityProvider.CurrentUser.UserRole == TestorUserRole.Teacher || LocalUser.SecurityProvider.CurrentUser.UserRole == TestorUserRole.Laboratorian) { LabelTestname.Text = String.Format("Тест: <a href=\"/Manage/Statistics.aspx?testId={0}\">{1}</a>", _currentItem.TestId, _currentItem.ItemName.Trim()); } else { LabelTestname.Text = String.Format("Тест: \"{0}\"", _currentItem.ItemName.Trim()); } if (postButton.Attributes[BUTTON_MODE] == NULL_VALUE) { postButton.Attributes[BUTTON_MODE] = NTMODE_VALUE; } else { postButton.Attributes[BUTTON_MODE] = TESTING_VALUE; } postButton.Attributes[BUTTON_VALUE] = _currentItem.ItemId.ToString(); } } }
public static string GetPreTestingHtml(TestorData.CoreTestsRow coreTest) { StringBuilder sb = new StringBuilder(); sb.Append("<table>"); if (!String.IsNullOrEmpty(coreTest.Description)) { sb.AppendFormat("<tr><td>Аннотация к тесту:</td><td><b>{0}</b></td></tr>", coreTest.Description); } else { sb.AppendFormat("<tr><td>Аннотация к тесту:</td><td><b>{0}</b></td></tr>", "нет"); } sb.AppendFormat("<tr><td>Число вопросов в тесте:</td><td><b>{0}</b></td></tr>", coreTest.QuestionsNumber); if (coreTest.TimeLimit != 0) { sb.AppendFormat("<tr><td>Ограничение по времени:</td><td><b>{0} мин.</b></td></tr>", coreTest.TimeLimit); } else { sb.AppendFormat("<tr><td>Ограничение по времени:</td><td><b>{0}</b></td></tr>", "нет"); } if (coreTest.PassagesNumber != 0) { sb.AppendFormat("<tr><td>Число разрешенных прохождений:</td><td><b>{0}</b></td></tr>", coreTest.PassagesNumber); } else { sb.AppendFormat("<tr><td>Число разрешенных прохождений:</td><td><b>{0}</b></td></tr>", "не ограничено"); } if (coreTest.BeginTime != DateTime.MinValue) { sb.AppendFormat("<tr><td>Тест доступен c:</td><td><b>{0}</b></td></tr>", coreTest.BeginTime); } else { sb.AppendFormat("<tr><td>Тест доступен c:</td><td><b>{0}</b></td></tr>", "не ограничено"); } if (coreTest.EndTime != DateTime.MinValue) { sb.AppendFormat("<tr><td>Тест доступен до:</td><td><b>{0}</b></td></tr>", coreTest.EndTime); } else { sb.AppendFormat("<tr><td>Тест доступен до:</td><td><b>{0}</b></td></tr>", "не ограничено"); } if (coreTest.ShowTestResult) { if (coreTest.PassingScore != 0) { sb.AppendFormat("<tr><td>Проходной Балл:</td><td><b>{0}</b></td></tr>", coreTest.PassingScore); } else { sb.AppendFormat("<tr><td>Проходной Балл:</td><td><b>{0}</b></td></tr>", "не задан"); } } sb.Append("</table>"); return(sb.ToString()); }
public static CoreTestRowAdapter GetAdapter(TestorData.CoreTestsRow row) { return(new CoreTestRowAdapter(row)); }
private void buttonOK_Click(object sender, EventArgs e) { _password = textBoxPassword.Text; if (!IsTeacherMode) { if (_resultUser == null) { MessageBox.Show("Для начала тестирования необходимо выбрать пользователя.", "Выбор пользователя", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } SetChildEnable(false); StaticServerProvider.Logout(); LoginProvider loginProvider = LoginProvider.Login(_resultUser.Login, textBoxPassword.Text, LoginHelper.Server, LoginHelper.SEND_TIMEOUT, null, new LoginProvider.LoginResultDelegate((hasPassword, errorMessage) => { this.Invoke((Action)(() => { if (hasPassword) { if (String.IsNullOrEmpty(LoginHelper.Server)) { string[] databases = StaticServerProvider.TestClient.GetDatabaseNamesList(); if (databases.Length > 0) { string dbPassword = StaticServerProvider.TestClient.GetDatabasePassword(databases[0]); using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(String.Format( "Data Source=(local);Initial Catalog={0};User ID=testingUser;Password={1}", databases[0], dbPassword))) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("EXEC InitDbSettings;", conn); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); Console.WriteLine(cmd.ExecuteScalar()); } } } StartTestParams ncs = StaticServerProvider.TestClient.GetNotCommitedSessions(_resultUser.UserId, false); TestorData testSettings = null; if (ncs == null) { SelectSingleItemForm selectTest = new SelectSingleItemForm(_resultUser, TestingServerItemType.ActiveTestTree); if (selectTest.ShowDialog() != DialogResult.OK) { textBoxPassword.Text = String.Empty; StaticServerProvider.Logout(); LoginHelper.AnonymousLogin(); SetChildEnable(true); return; } _selectedTest = selectTest.SelectedItem; if (_selectedTest == null || _selectedTest.ItemType != TestorItemType.Test && _selectedTest.ItemType != TestorItemType.MasterTest) { MessageBox.Show("Для начала тестирования необходимо выбрать тест.", "Выбор теста", MessageBoxButtons.OK, MessageBoxIcon.Warning); _selectedTest = null; StaticServerProvider.Logout(); LoginHelper.AnonymousLogin(); SetChildEnable(true); return; } testSettings = selectTest.TestSettings; } else { testSettings = ncs.TestSettings; TestorData.CoreTestsRow coreTest = testSettings.CoreTests[0]; _selectedTest = new TestorTreeItem(0, coreTest.TestId, coreTest.TestName, coreTest.IsMasterTest ? TestorItemType.MasterTest : TestorItemType.Test, null); } RemoteTestingProvider provider = new RemoteTestingProvider(null, _selectedTest, testSettings, ncs, true); TestForm testForm = new TestForm(provider); testForm.ShowDialog(); comboBoxUserType_SelectedIndexChanged(sender, e); StaticServerProvider.Logout(); LoginHelper.AnonymousLogin(); SetChildEnable(true); } else { SystemMessage.ShowServerErrorMessage(errorMessage); textBoxPassword.Text = String.Empty; StaticServerProvider.Logout(); LoginHelper.AnonymousLogin(); SetChildEnable(true); return; } })); })); } else { SetFormEnableMode(false); _userName = textBoxStudentName.Text; StaticServerProvider.Logout(); LoginProvider loginProvider = LoginProvider.Login(_userName, _password, LoginHelper.Server, LoginHelper.SEND_TIMEOUT, null, new LoginProvider.LoginResultDelegate((hasPassword, errorMessage) => { this.Invoke((Action)(() => { SetFormEnableMode(true); if (hasPassword) { StatisticsForm statistics = new StatisticsForm(false); statistics.MdiParent = this.MdiParent; statistics.Dock = DockStyle.Fill; statistics.ControlBox = false; statistics.Show(); comboBoxUserType.SelectedIndex = 0; textBoxStudentName.Focus(); SetChildEnable(true); } else { SystemMessage.ShowServerErrorMessage(errorMessage); StaticServerProvider.Logout(); LoginHelper.AnonymousLogin(); SetChildEnable(true); return; } })); })); } }