/// <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); } }
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()); }
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)); }
/// <summary> Загружает лабораторные работы </summary> protected override LabModel[] LoadItems() { return(_query.OfEntities <LabWork>() .ToArray() .Select(l => _modelLoader.Load(l)) .ToArray()); }
/// <summary> Загружает группы </summary> protected override GroupModel[] LoadItems() { return(_query.OfEntities <Group>() .ToArray() .Select(_modelLoader.Load) .ToArray()); }
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); }
/// <summary> Загружает тестпулы</summary> protected override TestPoolModel[] LoadItems() { return(_query.OfEntities <DomainModel.TestPool>() .ToArray() .Select(_modelLoader.Load) .ToArray()); }
/// <summary> Загружает вопросы </summary> protected override QuestionModel[] LoadItems() { return(_query.OfEntities <TestQuestion>() .ToArray() .Select(l => _modelLoader.Load(l)) .OrderBy(i => i.Category.Name) .ToArray()); }
/// <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()); }
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); }
protected override LabScheduleModel[] LoadItems() { return(_query .OfEntities <AbstractLabSchedule>() .OrderBy(m => m.DateFrom) .ThenBy(m => m.DateTill) .ToArray() .Select(_modelLoader.Load) .ToArray()); }
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()); }
/// <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); }
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); }
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()); }