예제 #1
0
        /// <summary> Загрузить задание </summary>
        private TaskPoco UploadTaskInternal(Stream stream, bool appendTimestamp)
        {
            var info = _xapProcessor.Parse(stream);

            if (info == null)
            {
                throw new ArgumentException("Не удалось распознать модуль-задание.");
            }

            var name = appendTimestamp
                ? $"{info.Name} ({DateTime.Now:u})"
                : info.Name;

            var sameTaskExists = _query.OfEntities <Task>().Any(t => t.Name == name && t.Version == info.Version);

            if (!sameTaskExists)
            {
                var newTask = new TaskPoco
                {
                    Name             = name,
                    Sections         = info.Sections,
                    VariantGenerator = null,
                    Note             = null,
                    Version          = info.Version,
                    Xap = stream.ReadToEnd()
                };

                return(newTask);
            }
            else
            {
                //TODO: здесь кидать исключение о дубликате (лучше ResultOrError)
                return(null);
            }
        }
예제 #2
0
 protected override LabScheduleModel[] LoadItems()
 {
     return(_query
            .OfEntities <AbstractLabSchedule>()
            .OrderBy(m => m.DateFrom)
            .ThenBy(m => m.DateTill)
            .Where(m =>
                   (!_dateFrom.HasValue || _dateFrom <= m.DateTill) &&
                   (!_dateTill.HasValue || _dateTill >= m.DateFrom))
            .Where(m => (((m is IndividualLabSchedule) &&
                          ((string.IsNullOrEmpty(_user0)) ||
                           (((m as IndividualLabSchedule).Student.Name.ToLower().Contains(_user0) && (m as IndividualLabSchedule).Student.FatherName.ToLower().Contains(_user1) &&
                             (m as IndividualLabSchedule).Student.Surname.ToLower().Contains(_user2)) ||
                            (((m as IndividualLabSchedule).Student.Name.ToLower().Contains(_user0) && (m as IndividualLabSchedule).Student.FatherName.ToLower().Contains(_user2) &&
                              (m as IndividualLabSchedule).Student.Surname.ToLower().Contains(_user1)) ||
                             ((m as IndividualLabSchedule).Student.Name.ToLower().Contains(_user1) && (m as IndividualLabSchedule).Student.FatherName.ToLower().Contains(_user0) &&
                              (m as IndividualLabSchedule).Student.Surname.ToLower().Contains(_user2)) ||
                             ((m as IndividualLabSchedule).Student.Name.ToLower().Contains(_user1) && (m as IndividualLabSchedule).Student.FatherName.ToLower().Contains(_user2) &&
                              (m as IndividualLabSchedule).Student.Surname.ToLower().Contains(_user0)) ||
                             ((m as IndividualLabSchedule).Student.Name.ToLower().Contains(_user2) && (m as IndividualLabSchedule).Student.FatherName.ToLower().Contains(_user0) &&
                              (m as IndividualLabSchedule).Student.Surname.ToLower().Contains(_user1)) ||
                             ((m as IndividualLabSchedule).Student.Name.ToLower().Contains(_user2) && (m as IndividualLabSchedule).Student.FatherName.ToLower().Contains(_user1) &&
                              (m as IndividualLabSchedule).Student.Surname.ToLower().Contains(_user0))))))
                         ||
                         ((m is GroupLabSchedule) && ((m as GroupLabSchedule).Group.Name.Contains(_user1) && (m as GroupLabSchedule).Group.Name.Contains(_user1) || (string.IsNullOrEmpty(_user0))))))
            .Where(m => (m.LabWork.Name.Equals(_labname) || string.IsNullOrEmpty(_labname)))
            .ToArray()
            .Select(_modelLoader.Load)
            .ToArray());
 }
예제 #3
0
        protected override Expression <Func <AbstractLabSchedule, bool> > GetAdditionalScheduleFilter(IEntityQuery query, Student currentStudent)
        {
            var allSchedules = query.OfEntities <AbstractLabSchedule>();
            var allResults   = query.OfEntities <Result>();

            return(currentSchedule =>
                   allSchedules
                   .Count(sch => sch.LabWork == currentSchedule.LabWork &&
                          sch.Mode == LabExecutionMode.TestMode &&
                          ((sch as IndividualLabSchedule).Student.Id == currentStudent.Id || (sch as GroupLabSchedule).Group.Id == currentStudent.Group.Id))
                   >
                   allResults
                   .Count(res => res.LabVariant.LabWork == currentSchedule.LabWork &&
                          res.Student.Id == currentStudent.Id &&
                          res.Status != ExecutionStatus.Complete));
        }
예제 #4
0
 /// <summary> Загружает лабораторные работы </summary>
 protected override LabModel[] LoadItems()
 {
     return(_query.OfEntities <LabWork>()
            .ToArray()
            .Select(l => _modelLoader.Load(l))
            .ToArray());
 }
예제 #5
0
 /// <summary> Загружает группы </summary>
 protected override GroupModel[] LoadItems()
 {
     return(_query.OfEntities <Group>()
            .ToArray()
            .Select(_modelLoader.Load)
            .ToArray());
 }
예제 #6
0
        private TaskVariantPreviewModel CreateTaskVariantPreviewModel(int taskId)
        {
            long variantId;

            try
            {
                variantId = _entityQuery.OfEntities <TaskVariant>().First(t => t.Task.Id == taskId).Id;
            }
            catch (InvalidOperationException ex)
            {
                throw new GraphLabsException(ex,
                                             "Не удалось загрузить вариант для предпросмотра. Вероятно, для выбранного модуля в системе нет ни одного доступного варианта.");
            }

            var initParams = InitParams.ForDemoMode(
                _authService.GetSessionInfo().SessionGuid,
                taskId,
                variantId,
                -1,
                null);

            var model = new TaskVariantPreviewModel
            {
                TaskId     = taskId,
                InitParams = _initParamsProvider.GetInitParamsString(initParams)
            };

            return(model);
        }
예제 #7
0
 /// <summary> Загружает тестпулы</summary>
 protected override TestPoolModel[] LoadItems()
 {
     return(_query.OfEntities <DomainModel.TestPool>()
            .ToArray()
            .Select(_modelLoader.Load)
            .ToArray());
 }
예제 #8
0
 /// <summary> Загружает вопросы </summary>
 protected override QuestionModel[] LoadItems()
 {
     return(_query.OfEntities <TestQuestion>()
            .ToArray()
            .Select(l => _modelLoader.Load(l))
            .OrderBy(i => i.Category.Name)
            .ToArray());
 }
예제 #9
0
 /// <summary> Реализация этого метода должна загружать список моделей </summary>
 protected override NewsModel[] LoadItems()
 {
     return(_query.OfEntities <DomainModel.News>()
            .OrderByDescending(n => n.LastModificationTime.HasValue ? n.LastModificationTime : n.PublicationTime)
            .Take(MaxNewsCount)
            .ToArray()
            .Select(n => _modelLoader.Load(n))
            .ToArray());
 }
예제 #10
0
        private void FillGroups(object selectedValue = null)
        {
            var groups = _query.OfEntities <Group>()
                         .Where(g => g.IsOpen)
                         .ToArray()
                         .Select(t => new NameValueModel(t.Id, t.Name))
                         .ToArray();

            ViewBag.GroupsList = new SelectList(groups, "Id", "Name", selectedValue);
        }
예제 #11
0
 protected override LabScheduleModel[] LoadItems()
 {
     return(_query
            .OfEntities <AbstractLabSchedule>()
            .OrderBy(m => m.DateFrom)
            .ThenBy(m => m.DateTill)
            .ToArray()
            .Select(_modelLoader.Load)
            .ToArray());
 }
예제 #12
0
 protected override ResultModel[] LoadItems()
 {
     return(_query
            .OfEntities <Result>()
            .Where(r => r.Student.Email == _email)
            .Where(r => (_from == null || r.StartDateTime >= _from) && (_till == null || r.StartDateTime <= _till))
            .ToArray()
            .Select(r => _resultLoader.Load(r))
            .ToArray());
 }
예제 #13
0
        /// <summary> Загружает демонстрационные лабораторные работы </summary>
        protected override TAvalilableLab[] LoadItems()
        {
            var currentStudent = _query.OfEntities <Student>().SingleOrDefault(s => s.Email == _currentUser.Identity.Name);

            if (currentStudent == null)
            {
                throw new GraphLabsException("Данная страница имеет смысл только для залогиненных студентов.");
            }

            var currentTime = _dateService.Now();
            var models      = _query.OfEntities <IndividualLabSchedule>()
                              .Where(s => s.Student.Id == currentStudent.Id)
                              .Cast <AbstractLabSchedule>()
                              .Union(_query.OfEntities <GroupLabSchedule>().Where(g => g.Group.Id == currentStudent.Group.Id))
                              .Where(sch => sch.Mode == ExecutionMode &&
                                     sch.DateFrom <= currentTime && sch.DateTill >= currentTime)
                              .Where(GetAdditionalScheduleFilter(_query, currentStudent))
                              .ToArray()
                              .Select(l => _modelLoader.Load(l))
                              .ToArray();

            return(models);
        }
예제 #14
0
        private Session FindSession(IEntityQuery query, string email, Guid sessionGuid, string clientIp)
        {
            var session = query
                          .OfEntities <Session>()
                          .Where(s => s.Guid == sessionGuid)
                          .Include(s => s.User)
                          .SingleOrDefault();

            if (session != null && SessionIsValid(session, email, clientIp))
            {
                return(session);
            }

            return(null);
        }
예제 #15
0
 private Result GetCurrentResultLog(IEntityQuery query, Session session)
 {
     return(query.OfEntities <Result>()
            .Where(result => result.Student.Id == session.User.Id && result.Status == ExecutionStatus.Executing)
            .ToArray().First());
 }