Esempio n. 1
0
 public void SendTests(TestorData testorData, List<int> groupIds)
 {
     SystemStateManager.OnStateChanged(true);
     TreeNode selectedNode = this.SelectedNode;
     SynchronizationContext context = SynchronizationContext.Current;
     _currentThread = new Thread(new ThreadStart(() =>
     {
         byte[] arr = DataCompressor.CompressData(testorData);
         try
         {
             TestorTreeItem[] newItems = StaticServerProvider.TestEdit.SendTests(arr,
                 _selectedItem.ItemId, groupIds.ToArray());
             foreach (var item in newItems)
                 item.ItemOwner = StaticServerProvider.CurrentUser.UserId;
             context.Send(d =>
             {
                 AddTreeNodes(newItems, selectedNode, false);
                 if (selectedNode != null)
                     selectedNode.Expand();
             }, null);
         }
         catch (Exception ex)
         {
             SystemMessage.ShowErrorMessage(ex);
         }
         finally
         {
             context.Send(d =>
             {
                 SystemStateManager.OnStateChanged(false);
             }, null);
         }
     }));
     _currentThread.Start();
 }
Esempio n. 2
0
        public byte[] GetTestSettings(int testId)
        {
            Debug.Assert(testId > 0);

            Provider.TestRoles(TestorUserRole.Administrator, TestorUserRole.Teacher, TestorUserRole.Laboratorian,
                               TestorUserRole.Student, TestorUserRole.Anonymous);

            var data = Helper.GetTestSettingsData(testId);

            return(DataCompressor.CompressData(data));
        }
Esempio n. 3
0
        public byte[] FindUsers(string userInfo, TestorUserRole userRole, TestorUserStatus userStatus, bool getRemoved, int groupId, int takeCount)
        {
            if (Provider.CurrentUser.UserRole == TestorUserRole.NotDefined || Provider.CurrentUser.UserRole == TestorUserRole.Anonymous ||
                Provider.CurrentUser.UserRole == TestorUserRole.Student)
            {
                if (userRole != TestorUserRole.NotDefined && userRole != TestorUserRole.Anonymous &&
                    userRole != TestorUserRole.Student)
                {
                    Provider.ThrowAccessFaultException();
                }
            }

            return(DataCompressor.CompressData <TestorCoreUser[]>(UserSearchHelper.FindUsers(userInfo, userRole, userStatus, groupId, getRemoved, takeCount, true)));
        }
Esempio n. 4
0
 public void SetTestSettings(TestorData testorData)
 {
     SystemStateManager.OnStateChanged(true);
     byte[] data = DataCompressor.CompressData(testorData);
     SynchronizationContext context = SynchronizationContext.Current;
     _currentThread = new Thread(new ThreadStart(() =>
     {
         StaticServerProvider.TestEdit.SetTestSettings(data);
         if ((this.TopLevelControl as Form).IsHandleCreated)
         {
             context.Send(d =>
                 {
                     SystemStateManager.OnStateChanged(false);
                 }, null);
         }
     }));
     _currentThread.Start();
 }
Esempio n. 5
0
        public byte[] GetTestHTML(int testId)
        {
            Debug.Assert(testId > 0);

            Provider.TestRoles(TestorUserRole.Administrator, TestorUserRole.Teacher, TestorUserRole.Laboratorian);
            Provider.TestCoreTestsAccess(testId);

            List <HtmlStore> retValue = new List <HtmlStore>();

            using (DataClassesTestorCoreDataContext dataContext = new DataClassesTestorCoreDataContext(TestorSecurityProvider.ConnectionString))
            {
                var quests = from c in dataContext.CoreQuestions
                             where c.TestId == testId
                             orderby c.QuestionId
                             select c;

                foreach (var quest in quests)
                {
                    HtmlStore store = new HtmlStore();
                    store.Html = quest.Question;
                    foreach (var answer in quest.CoreAnswers)
                    {
                        HtmlStore answerStore = new HtmlStore();
                        answerStore.Html   = answer.Answer;
                        answerStore.IsTrue = answer.IsTrue;
                        store.SubItems.Add(answerStore);
                    }

                    foreach (var blob in quest.CoreBLOBs)
                    {
                        store.Images.Add(blob.BLOBId, blob.BLOBContent.ToArray());
                    }

                    retValue.Add(store);
                }
                return(DataCompressor.CompressData <HtmlStore[]>(retValue.ToArray()));
            }
        }
Esempio n. 6
0
        public byte[] GetQuestion(int questId, bool getBLOBs)
        {
            Debug.Assert(questId > 0);

            return(DataCompressor.CompressData <TestorData>(GetQuestion(questId, false, false, getBLOBs)));
        }