public ThemeInfoModel(int groupId, int curriculumId, ILmsService lmsService) { _LastAttempts = new List <AttemptResult>(); CurriculumId = curriculumId; Group group = lmsService.FindService <IUserService>().GetGroup(groupId); SelectGroupStudents = lmsService.FindService <IUserService>().GetUsersByGroup(group); SelectCurriculumThemes = lmsService.FindService <ICurriculumService>().GetThemesByCurriculumId(CurriculumId); foreach (var temp in from student in SelectGroupStudents from theme in SelectCurriculumThemes select lmsService.FindService <ITestingService>().GetResults(student, theme) into temp where temp != null select temp) { var filteredTemp = temp//.Where(attempt => attempt.CompletionStatus == CompletionStatus.Completed) .OrderBy(attempt => attempt.StartTime); if (filteredTemp.Count() != 0) { _LastAttempts.Add(filteredTemp.First()); } } }
private IEnumerable <UserAnswers> StudentsAnswers(ILmsService iLmsService, int[] selectGroupIds, CurriculumChapterTopic selectedCurriculumChapterTopic) { List <UserAnswers> listOfUserAnswers = new List <UserAnswers>(); //Creation of list of all students in selected groups IEnumerable <User> studentsFromSelectedGroups = new List <User>(); foreach (var groupId in selectGroupIds) { Group temp = iLmsService.FindService <IUserService>().GetGroup(groupId); studentsFromSelectedGroups = studentsFromSelectedGroups.Union(iLmsService.FindService <IUserService>().GetUsersByGroup(temp)); } // foreach (User student in studentsFromSelectedGroups) { IEnumerable <AttemptResult> temp = iLmsService.FindService <ITestingService>().GetResults(student, selectedCurriculumChapterTopic); if (temp != null & temp.Count() != 0) { temp = temp//.Where(attempt => attempt.CompletionStatus == CompletionStatus.Completed) .OrderBy(attempt => attempt.StartTime); if (temp.Count() != 0) { listOfUserAnswers.Add(new UserAnswers(student, temp.First(), iLmsService)); } } } return(listOfUserAnswers); }
public ThemeInfoModel(int groupId, int curriculumId, ILmsService lmsService) { LmsService = lmsService; CurriculumId = curriculumId; SelectStudents = LmsService.FindService <IUserService>().GetUsersByGroup ( LmsService.FindService <IUserService>().GetGroup(groupId) ); SelectCurriculumThemes = LmsService.FindService <ICurriculumService>().GetThemesByCurriculumId ( CurriculumId ); //LastAttempts = LmsService.FindService<ITestingService>().GetLastCompleteAttemptsForThemes // ( // LmsService.FindService<IUserService>().GetGroup(groupId), // SelectCurriculumThemes // ); LastAttempts = new List <AttemptResult>(); foreach (User student in SelectStudents) { foreach (Theme theme in SelectCurriculumThemes) { IEnumerable <AttemptResult> temp = LmsService.FindService <ITestingService>().GetResults(student, theme); if (temp != null) { LastAttempts.Add(temp.First()); } } } }
public TopicModel(ILmsService ilmsService, long selectDisciplineId) { IEnumerable <Topic> temp_allowedTopics = ilmsService.FindService <IDisciplineService>().GetTopicsByDisciplineId((int)selectDisciplineId); this.disciplineName = ilmsService.FindService <IDisciplineService>().GetDiscipline((int)selectDisciplineId).Name; if (temp_allowedTopics != null & temp_allowedTopics.Count() != 0) { double tempDisciplineQuality = 0; var temp = new List <KeyValuePair <Topic, double> >(); foreach (var topic in temp_allowedTopics) { List <double> quality = new List <double>(); quality.Add(0); tempDisciplineQuality += quality.Sum() / quality.Count; temp.Add(new KeyValuePair <Topic, double>(topic, quality.Sum() / quality.Count)); } this.disciplineQuality = tempDisciplineQuality / temp.Count; this.allowedTopics = temp; } else { this.disciplineQuality = 0; this.allowedTopics = null; } }
public CurrentTopicTestResultsModel(int topicId, ILmsService lmsService) { User currenUser = lmsService.FindService <IUserService>().GetCurrentUser(); Topic topic = lmsService.FindService <ICurriculumService>().GetTopic(topicId); if (currenUser != null & topic != null) { IEnumerable <AttemptResult> attemptResults = lmsService.FindService <ITestingService>().GetResults(currenUser, topic); if (attemptResults != null & attemptResults.Count() >= 1) { _Attempt = attemptResults.Last(); if (_Attempt != null) { _UserAnswers = lmsService.FindService <ITestingService>().GetAnswers(_Attempt); if (_UserAnswers != null) { _NoData = false; } else { _NoData = true; } } } else { _NoData = true; } } else { _NoData = true; } }
public TopicInfoModel(int groupId, int curriculumId, ILmsService lmsService) { this.lastAttempts = new List<AttemptResult>(); this.lmsService = lmsService; this.curriculumId = curriculumId; var group = lmsService.FindService<IUserService>().GetGroup(groupId); this.selectedGroupStudents = lmsService.FindService<IUserService>().GetUsersByGroup(group); this.selectedCurriculumChapterTopics = lmsService.FindService<ICurriculumService>().GetCurriculumChapterTopicsByCurriculumId(this.curriculumId); foreach (var temp in from student in this.selectedGroupStudents from curriculumChapterTopic in this.selectedCurriculumChapterTopics select lmsService.FindService<ITestingService>().GetResults(student, curriculumChapterTopic) into temp where temp != null select temp) { // hotfix: added checking of Course id var attempt = temp.Where(x => x.CurriculumChapterTopic.Topic.TestCourseRef == x.IudicoCourseRef); if (attempt.Any()) { this.lastAttempts.Add(attempt.First()); } } }
public CurrentTopicTestResultsModel(int curriculumChapterTopicId, TopicTypeEnum topicType, ILmsService lmsService) { var currenUser = lmsService.FindService <IUserService>().GetCurrentUser(); var curriculumChapterTopic = lmsService.FindService <ICurriculumService>().GetCurriculumChapterTopicById(curriculumChapterTopicId); if (currenUser != null & curriculumChapterTopic != null) { var attemptResults = lmsService.FindService <ITestingService>().GetResults(currenUser, curriculumChapterTopic, topicType).ToList(); if (attemptResults.Any()) { // hotfix: added checking of Course id this.attempt = attemptResults.FirstOrDefault(x => x.CurriculumChapterTopic.Topic.TestCourseRef == x.IudicoCourseRef); if (this.attempt != null) { this.courseInfo = lmsService.FindService <ICourseService>().GetCourseInfo(this.attempt.IudicoCourseRef); this.userAnswers = lmsService.FindService <ITestingService>().GetAnswers(this.attempt); this.hasNoData = this.userAnswers == null; } } else { this.hasNoData = true; } } else { this.hasNoData = true; } }
public TopicModel(ILmsService ilmsService, long selectDisciplineId) { IEnumerable<Topic> temp_allowedTopics = ilmsService.FindService<IDisciplineService>().GetTopicsByDisciplineId((int)selectDisciplineId); this.disciplineName = ilmsService.FindService<IDisciplineService>().GetDiscipline((int)selectDisciplineId).Name; if (temp_allowedTopics != null & temp_allowedTopics.Count() != 0) { double tempDisciplineQuality = 0; var temp = new List<KeyValuePair<Topic, double>>(); foreach (var topic in temp_allowedTopics) { List<double> quality = new List<double>(); quality.Add(0); tempDisciplineQuality += quality.Sum() / quality.Count; temp.Add(new KeyValuePair<Topic, double>(topic, quality.Sum() / quality.Count)); } this.disciplineQuality = tempDisciplineQuality / temp.Count; this.allowedTopics = temp; } else { this.disciplineQuality = 0; this.allowedTopics = null; } }
public TopicInfoModel(int groupId, int curriculumId, ILmsService lmsService) { this.lastAttempts = new List <AttemptResult>(); this.lmsService = lmsService; this.curriculumId = curriculumId; var group = lmsService.FindService <IUserService>().GetGroup(groupId); this.selectedGroupStudents = lmsService.FindService <IUserService>().GetUsersByGroup(group); this.selectedCurriculumChapterTopics = lmsService.FindService <ICurriculumService>().GetCurriculumChapterTopicsByCurriculumId(this.curriculumId); foreach (var temp in from student in this.selectedGroupStudents from curriculumChapterTopic in this.selectedCurriculumChapterTopics select lmsService.FindService <ITestingService>().GetResults(student, curriculumChapterTopic) into temp where temp != null select temp) { // hotfix: added checking of Course id var attempt = temp.Where(x => x.CurriculumChapterTopic.Topic.TestCourseRef == x.IudicoCourseRef); if (attempt.Any()) { this.lastAttempts.Add(attempt.First()); } } }
public CurrentTopicTestResultsModel(int topicId, ILmsService lmsService) { User currenUser = lmsService.FindService<IUserService>().GetCurrentUser(); Topic topic = lmsService.FindService<ICurriculumService>().GetTopic(topicId); if (currenUser != null & topic != null) { IEnumerable<AttemptResult> attemptResults = lmsService.FindService<ITestingService>().GetResults(currenUser, topic); if (attemptResults != null & attemptResults.Count() >= 1) { _Attempt = attemptResults.Last(); if (_Attempt != null) { _UserAnswers = lmsService.FindService<ITestingService>().GetAnswers(_Attempt); if (_UserAnswers != null) _NoData = false; else _NoData = true; } } else _NoData = true; } else _NoData = true; }
/// <summary> /// constructor that get all information from Testing System /// </summary> /// <param name="attemptId">id of attempt to show</param> /// <param name="attList">list of attempts from Session Context</param> /// <param name="lmsService">ILmsService for conection to Testing System</param> public TopicTestResultsModel(long attemptId, IEnumerable <AttemptResult> attList, int groupId, ILmsService lmsService) { if (attemptId != -1) { this.group = lmsService.FindService <IUserService>().GetGroup(groupId); // hotfix: added checking of Course id this.attempt = attList.FirstOrDefault( c => c.AttemptId == attemptId && c.CurriculumChapterTopic.Topic.TestCourseRef == c.IudicoCourseRef); if (this.attempt != null) { this.userAnswers = lmsService.FindService <ITestingService>().GetAnswers(this.attempt); this.courseInfo = lmsService.FindService <ICourseService>().GetCourseInfo(this.attempt.IudicoCourseRef); this.hasNoData = this.userAnswers == null; } else { this.hasNoData = true; } } else { this.hasNoData = true; } }
/// <summary> /// constructor that get all information from Testing System /// </summary> /// <param name="attemptId">id of attempt to show</param> /// <param name="attList">list of attempts from Session Context</param> /// <param name="lmsService">ILmsService for conection to Testing System</param> public TopicTestResultsModel(long attemptId, IEnumerable<AttemptResult> attList, int groupId, ILmsService lmsService) { if (attemptId != -1) { this.group = lmsService.FindService<IUserService>().GetGroup(groupId); // hotfix: added checking of Course id this.attempt = attList.FirstOrDefault( c => c.AttemptId == attemptId && c.CurriculumChapterTopic.Topic.TestCourseRef == c.IudicoCourseRef); if (this.attempt != null) { this.userAnswers = lmsService.FindService<ITestingService>().GetAnswers(this.attempt); this.courseInfo = lmsService.FindService<ICourseService>().GetCourseInfo(this.attempt.IudicoCourseRef); this.hasNoData = this.userAnswers == null; } else { this.hasNoData = true; } } else this.hasNoData = true; }
public CurrentTopicTestResultsModel(int curriculumChapterTopicId, TopicTypeEnum topicType, ILmsService lmsService) { var currenUser = lmsService.FindService<IUserService>().GetCurrentUser(); var curriculumChapterTopic = lmsService.FindService<ICurriculumService>().GetCurriculumChapterTopicById(curriculumChapterTopicId); if (currenUser != null & curriculumChapterTopic != null) { var attemptResults = lmsService.FindService<ITestingService>().GetResults(currenUser, curriculumChapterTopic, topicType).ToList(); if (attemptResults.Any()) { // hotfix: added checking of Course id this.attempt = attemptResults.FirstOrDefault(x => x.CurriculumChapterTopic.Topic.TestCourseRef == x.IudicoCourseRef); if (this.attempt != null) { this.courseInfo = lmsService.FindService<ICourseService>().GetCourseInfo(this.attempt.IudicoCourseRef); this.userAnswers = lmsService.FindService<ITestingService>().GetAnswers(this.attempt); this.hasNoData = this.userAnswers == null; } } else this.hasNoData = true; } else this.hasNoData = true; }
public DataPreparer( IDisciplineStorage disciplineStorage, ICurriculumStorage curriculumStorage, ILmsService lmsService) { this.disciplineStorage = disciplineStorage; this.curriculumStorage = curriculumStorage; this.courseService = lmsService.FindService<ICourseService>(); this.userService = lmsService.FindService<IUserService>(); }
public DataPreparer( IDisciplineStorage disciplineStorage, ICurriculumStorage curriculumStorage, ILmsService lmsService) { this.disciplineStorage = disciplineStorage; this.curriculumStorage = curriculumStorage; this.courseService = lmsService.FindService <ICourseService>(); this.userService = lmsService.FindService <IUserService>(); }
public IEnumerable <User> GetCourseUsers(int courseId) { var db = GetDbContext(); var userIds = db.CourseUsers.Where(i => i.CourseRef == courseId); var users = _LmsService.FindService <IUserService>().GetUsers().Where(i => userIds.Any(j => j.UserRef == i.Id)); return(users); }
public IEnumerable <User> GetCourseUsers(int courseId) { using (var db = new CourseManagementDbConext()) { var userIds = db.CourseUsers.Where(i => i.CourseRef == courseId); var users = _LmsService.FindService <IUserService>().GetUsersByExpression(i => userIds.Any(j => j.UserRef == i.Id)); return(users); } }
public IndexModel(ILmsService iLmsService) { IEnumerable<Curriculum> allowedCurriculums; User teacherUser; teacherUser = iLmsService.FindService<IUserService>().GetCurrentUser(); allowedCurriculums = iLmsService.FindService<ICurriculumService>().GetCurriculumsWithThemesOwnedByUser(teacherUser); // if (allowedCurriculums != null & allowedCurriculums.Count() != 0) _AllowedCurriculums = allowedCurriculums; else _AllowedCurriculums = null; _TeacherUser = teacherUser; }
public IndexModel(ILmsService iLmsService) { IEnumerable<Discipline> allowedDisciplines; User teacherUser; teacherUser = iLmsService.FindService<IUserService>().GetCurrentUser(); allowedDisciplines = iLmsService.FindService<ICurriculumService>().GetDisciplinesWithTopicsOwnedByUser(teacherUser); // if (allowedDisciplines != null & allowedDisciplines.Count() != 0) _AllowedDisciplines = allowedDisciplines; else _AllowedDisciplines = null; _TeacherUser = teacherUser; }
public SelectGroupsModel(ILmsService iLmsService, int selectThemeId, String teacherUserName, String curriculumName) { IEnumerable<Group> allowedGroups; Theme selectTheme; selectTheme = iLmsService.FindService<ICurriculumService>().GetTheme(selectThemeId); _ThemeName = selectTheme.Name; _TeacheUserName = teacherUserName; _CurriculumName = curriculumName; allowedGroups = iLmsService.FindService<ICurriculumService>().GetGroupsAssignedToTheme(selectThemeId); // if (allowedGroups != null & allowedGroups.Count() != 0) _AllowedGroups = allowedGroups; else _AllowedGroups = null; }
public SelectGroupsModel(ILmsService iLmsService, int selectTopicId, String teacherUserName, String disciplineName) { IEnumerable<Group> allowedGroups; Topic selectTopic; selectTopic = iLmsService.FindService<ICurriculumService>().GetTopic(selectTopicId); _TopicName = selectTopic.Name; _TeacheUserName = teacherUserName; _DisciplineName = disciplineName; allowedGroups = iLmsService.FindService<ICurriculumService>().GetGroupsAssignedToTopic(selectTopicId); // if (allowedGroups != null & allowedGroups.Count() != 0) _AllowedGroups = allowedGroups; else _AllowedGroups = null; }
public double GetMaxResutForTopic(User student, CurriculumChapterTopic curriculumChapterTopic) { if (this.AllAttempts.Count != 0) { var attemptResult = this.AllAttempts.SingleOrDefault( x => x.User.Id == student.Id && x.CurriculumChapterTopic.Id == curriculumChapterTopic.Id); if (attemptResult != null) { var answerResults = lmsService.FindService <ITestingService>().GetAnswers(attemptResult); var courseId = attemptResult.IudicoCourseRef; var courseInfo = this.lmsService.FindService <ICourseService>().GetCourseInfo(courseId); double maxScore = 0; foreach (var node in courseInfo.NodesInfo) { if (answerResults.Any(answer => int.Parse(answer.PrimaryResourceFromManifest.Replace(".html", "")) == node.Id)) { maxScore += node.MaxScore; } } return(maxScore); } return(0); } return(0); }
public SelectTopicModel(ILmsService iLmsService,long selectDisciplineId, String teacherUserName) { IEnumerable<Topic> allowedTopics; User teacherUser = iLmsService.FindService<IUserService>().GetCurrentUser(); IEnumerable<Course> availableCourses = iLmsService.FindService<ICourseService>().GetCourses(teacherUser); // allowedTopics = iLmsService.FindService<IDisciplineService>().GetTopicsByDisciplineId((int)selectDisciplineId) .Where(topic => availableCourses.Count(course => course.Id == topic.TestCourseRef) != 0); // if (allowedTopics != null & allowedTopics.Count() != 0) _AllowedTopics = allowedTopics; else _AllowedTopics = null; _TeacheUserName = teacherUserName; _DisciplineName = iLmsService.FindService<IDisciplineService>().GetDiscipline((int)selectDisciplineId).Name; }
public SelectThemeModel(ILmsService iLmsService,long selectCurriculumId, String teacherUserName) { IEnumerable<Theme> allowedThemes; User teacherUser = iLmsService.FindService<IUserService>().GetCurrentUser(); IEnumerable<Course> availableCourses = iLmsService.FindService<ICourseService>().GetCourses(teacherUser); // allowedThemes = iLmsService.FindService<ICurriculumService>().GetThemesByCurriculumId((int)selectCurriculumId) .Where(theme => availableCourses.Count(course => course.Id == theme.CourseRef) != 0); // if (allowedThemes != null & allowedThemes.Count() != 0) _AllowedThemes = allowedThemes; else _AllowedThemes = null; _TeacheUserName = teacherUserName; _CurriculumName = iLmsService.FindService<ICurriculumService>().GetCurriculum((int)selectCurriculumId).Name; }
public void DeleteCourse(int id) { var db = GetDbContext(); var course = db.Courses.Single(c => c.Id == id); if (course.Owner != _LmsService.FindService <IUserService>().GetCurrentUser().Username) { return; } course.Deleted = true; db.SubmitChanges(); _LmsService.Inform(CourseNotifications.CourseDelete, course); }
/// <summary> /// constructor that get all information from Testing System /// </summary> /// <param name="attemptId">id of attempt to show</param> /// <param name="attList">list of attempts from Session Context</param> /// <param name="lmsService">ILmsService for conection to Testing System</param> public TopicTestResultsModel(long attemptId, IEnumerable <AttemptResult> attList, ILmsService lmsService) { if (attemptId != -1) { Attempt = attList.First(c => c.AttemptId == attemptId); if (Attempt != null) { UserAnswers = lmsService.FindService <ITestingService>().GetAnswers(Attempt); if (UserAnswers != null) { _NoData = false; } else { _NoData = true; } } else { _NoData = true; } } else { _NoData = true; } }
public IndexModel(ILmsService iLmsService) { IEnumerable <Discipline> allowedDisciplines; User teacherUser; teacherUser = iLmsService.FindService <IUserService>().GetCurrentUser(); allowedDisciplines = iLmsService.FindService <ICurriculumService>().GetDisciplinesWithTopicsOwnedByUser(teacherUser); // if (allowedDisciplines != null & allowedDisciplines.Count() != 0) { _AllowedDisciplines = allowedDisciplines; } else { _AllowedDisciplines = null; } _TeacherUser = teacherUser; }
public IndexModel(ILmsService iLmsService) { IEnumerable <Curriculum> allowedCurriculums; User teacherUser; teacherUser = iLmsService.FindService <IUserService>().GetCurrentUser(); allowedCurriculums = iLmsService.FindService <ICurriculumService>().GetCurriculumsWithThemesOwnedByUser(teacherUser); // if (allowedCurriculums != null & allowedCurriculums.Count() != 0) { _AllowedCurriculums = allowedCurriculums; } else { _AllowedCurriculums = null; } _TeacherUser = teacherUser; }
public double?GetTopicResultScore(ILmsService lmsService) { if (this.AttemptResults.Count() == 0 || this.AttemptResults.First().Score.ScaledScore == null) { this.Res = 0.0; this.ResMax = 0.0; } else { // hotfix: added checking of Course id var attemptResult = this.AttemptResults.FirstOrDefault( x => x.User.Id == this.user.Id & x.CurriculumChapterTopic.Id == this.curriculumChapterTopic.Id & x.CurriculumChapterTopic.Topic.TestCourseRef == x.IudicoCourseRef); if (attemptResult == null) { this.Res = 0.0; this.ResMax = 0.0; return(this.Res); } this.Res = attemptResult.Score.RawScore; var answerResults = lmsService.FindService <ITestingService>().GetAnswers(attemptResult); int iudicoCourseRef = attemptResult.IudicoCourseRef; var courseInfo = lmsService.FindService <ICourseService>().GetCourseInfo(iudicoCourseRef); double maxScore = 0; foreach (var node in courseInfo.NodesInfo) { if (answerResults.Any(answer => int.Parse(answer.PrimaryResourceFromManifest.Replace(".html", string.Empty)) == node.Id)) { maxScore += node.MaxScore; } } this.ResMax = maxScore; } return(this.Res); }
public AllSpecializedResults GetResults(IEnumerable <User> users, int[] selectCurriculumIds, ILmsService ILMS) { _LmsService = ILMS; AllSpecializedResults asr = new AllSpecializedResults(); SpecializedResult specializedResult; CurriculumResult curRes; ThemeResult themeResult; asr.Users = users.ToList(); asr.SelectCurriculumIds = selectCurriculumIds; asr.Curriculums = _LmsService.FindService <ICurriculumService>().GetCurriculums(selectCurriculumIds); IEnumerable <int> ieIds = selectCurriculumIds; foreach (User usr in asr.Users) { specializedResult = new SpecializedResult(); specializedResult.Curriculums = _LmsService.FindService <ICurriculumService>().GetCurriculums(ieIds); foreach (Curriculum curr in specializedResult.Curriculums) { curRes = new CurriculumResult(); curRes.Themes = _LmsService.FindService <ICurriculumService>().GetThemesByCurriculumId(curr.Id); #region ThemeResult foreach (Theme theme in curRes.Themes) { themeResult = new ThemeResult(usr, theme); themeResult.AttemptResults = _LmsService.FindService <ITestingService>().GetResults(usr, theme); themeResult.Res = themeResult.GetThemeResultScore(); curRes.ThemeResult.Add(themeResult); } #endregion curRes.CalculateSumAndMax(usr, curr); specializedResult.CurriculumResult.Add(curRes); } specializedResult.CalculateSpecializedResult(usr); asr.SpecializedResult.Add(specializedResult); } return(asr); }
public AllSpecializedResults GetResults(IEnumerable <User> users, int[] selectDisciplineIds, ILmsService ILMS) { _LmsService = ILMS; AllSpecializedResults asr = new AllSpecializedResults(); SpecializedResult specializedResult; DisciplineResult curRes; TopicResult topicResult; asr.Users = users.ToList(); asr.SelectDisciplineIds = selectDisciplineIds; asr.Disciplines = _LmsService.FindService <ICurriculumService>().GetDisciplines(selectDisciplineIds); IEnumerable <int> ieIds = selectDisciplineIds; foreach (User usr in asr.Users) { specializedResult = new SpecializedResult(); specializedResult.Disciplines = _LmsService.FindService <ICurriculumService>().GetDisciplines(ieIds); foreach (Discipline curr in specializedResult.Disciplines) { curRes = new DisciplineResult(); curRes.Topics = _LmsService.FindService <ICurriculumService>().GetTopicsByDisciplineId(curr.Id); #region TopicResult foreach (Topic topic in curRes.Topics) { topicResult = new TopicResult(usr, topic); topicResult.AttemptResults = _LmsService.FindService <ITestingService>().GetResults(usr, topic); topicResult.Res = topicResult.GetTopicResultScore(); curRes.TopicResult.Add(topicResult); } #endregion curRes.CalculateSumAndMax(usr, curr); specializedResult.DisciplineResult.Add(curRes); } specializedResult.CalculateSpecializedResult(usr); asr.SpecializedResult.Add(specializedResult); } return(asr); }
public AllSpecializedResults GetResults(IEnumerable<User> users, int[] selectDisciplineIds, ILmsService ILMS) { _LmsService = ILMS; AllSpecializedResults asr = new AllSpecializedResults(); SpecializedResult specializedResult; DisciplineResult curRes; TopicResult topicResult; asr.Users = users.ToList(); asr.SelectDisciplineIds = selectDisciplineIds; asr.Disciplines = _LmsService.FindService<ICurriculumService>().GetDisciplines(selectDisciplineIds); IEnumerable<int> ieIds = selectDisciplineIds; foreach (User usr in asr.Users) { specializedResult = new SpecializedResult(); specializedResult.Disciplines = _LmsService.FindService<ICurriculumService>().GetDisciplines(ieIds); foreach (Discipline curr in specializedResult.Disciplines) { curRes = new DisciplineResult(); curRes.Topics = _LmsService.FindService<ICurriculumService>().GetTopicsByDisciplineId(curr.Id); #region TopicResult foreach (Topic topic in curRes.Topics) { topicResult = new TopicResult(usr, topic); topicResult.AttemptResults = _LmsService.FindService<ITestingService>().GetResults(usr, topic); topicResult.Res = topicResult.GetTopicResultScore(); curRes.TopicResult.Add(topicResult); } #endregion curRes.CalculateSumAndMax(usr, curr); specializedResult.DisciplineResult.Add(curRes); } specializedResult.CalculateSpecializedResult(usr); asr.SpecializedResult.Add(specializedResult); } return asr; }
public AllSpecializedResults GetResults(IEnumerable<User> users, int[] selectCurriculumIds, ILmsService ILMS) { _LmsService = ILMS; AllSpecializedResults asr = new AllSpecializedResults(); SpecializedResult specializedResult; CurriculumResult curRes; ThemeResult themeResult; asr.Users = users.ToList(); asr.SelectCurriculumIds = selectCurriculumIds; asr.Curriculums = _LmsService.FindService<ICurriculumService>().GetCurriculums(selectCurriculumIds); IEnumerable<int> ieIds = selectCurriculumIds; foreach (User usr in asr.Users) { specializedResult = new SpecializedResult(); specializedResult.Curriculums = _LmsService.FindService<ICurriculumService>().GetCurriculums(ieIds); foreach (Curriculum curr in specializedResult.Curriculums) { curRes = new CurriculumResult(); curRes.Themes = _LmsService.FindService<ICurriculumService>().GetThemesByCurriculumId(curr.Id); #region ThemeResult foreach (Theme theme in curRes.Themes) { themeResult = new ThemeResult(usr, theme); themeResult.AttemptResults = _LmsService.FindService<ITestingService>().GetResults(usr, theme); themeResult.Res = themeResult.GetThemeResultScore(); curRes.ThemeResult.Add(themeResult); } #endregion curRes.CalculateSumAndMax(usr, curr); specializedResult.CurriculumResult.Add(curRes); } specializedResult.CalculateSpecializedResult(usr); asr.SpecializedResult.Add(specializedResult); } return asr; }
public SelectGroupsModel(ILmsService iLmsService, int selectTopicId, String teacherUserName, String disciplineName) { IEnumerable <Group> allowedGroups; Topic selectTopic; selectTopic = iLmsService.FindService <IDisciplineService>().GetTopic(selectTopicId); _TopicName = selectTopic.Name; _TeacheUserName = teacherUserName; _DisciplineName = disciplineName; allowedGroups = iLmsService.FindService <IDisciplineService>().GetGroupsAssignedToTopic(selectTopicId); // if (allowedGroups != null & allowedGroups.Count() != 0) { _AllowedGroups = allowedGroups; } else { _AllowedGroups = null; } }
public SelectGroupsModel(ILmsService iLmsService, int selectThemeId, String teacherUserName, String curriculumName) { IEnumerable <Group> allowedGroups; Theme selectTheme; selectTheme = iLmsService.FindService <ICurriculumService>().GetTheme(selectThemeId); _ThemeName = selectTheme.Name; _TeacheUserName = teacherUserName; _CurriculumName = curriculumName; allowedGroups = iLmsService.FindService <ICurriculumService>().GetGroupsAssignedToTheme(selectThemeId); // if (allowedGroups != null & allowedGroups.Count() != 0) { _AllowedGroups = allowedGroups; } else { _AllowedGroups = null; } }
public ThemeInfoModel(int groupId, int curriculumId, ILmsService lmsService) { _LastAttempts = new List<AttemptResult>(); CurriculumId = curriculumId; SelectGroupStudents = lmsService.FindService<IUserService>().GetUsersByGroup(lmsService.FindService<IUserService>().GetGroup(groupId)); SelectCurriculumThemes = lmsService.FindService<ICurriculumService>().GetThemesByCurriculumId(CurriculumId); foreach (var temp in from student in SelectGroupStudents from theme in SelectCurriculumThemes select lmsService.FindService<ITestingService>().GetResults(student, theme) into temp where temp != null select temp) { var filteredTemp = temp//.Where(attempt => attempt.CompletionStatus == CompletionStatus.Completed) .OrderBy(attempt => attempt.StartTime); if (filteredTemp.Count() != 0) _LastAttempts.Add(filteredTemp.First()); } }
public SelectThemeModel(ILmsService iLmsService, long selectCurriculumId, String teacherUserName) { IEnumerable <Theme> allowedThemes; User teacherUser = iLmsService.FindService <IUserService>().GetCurrentUser(); IEnumerable <Course> availableCourses = iLmsService.FindService <ICourseService>().GetCourses(teacherUser); // allowedThemes = iLmsService.FindService <ICurriculumService>().GetThemesByCurriculumId((int)selectCurriculumId) .Where(theme => availableCourses.Count(course => course.Id == theme.CourseRef) != 0); // if (allowedThemes != null & allowedThemes.Count() != 0) { _AllowedThemes = allowedThemes; } else { _AllowedThemes = null; } _TeacheUserName = teacherUserName; _CurriculumName = iLmsService.FindService <ICurriculumService>().GetCurriculum((int)selectCurriculumId).Name; }
public SelectTopicModel(ILmsService iLmsService, long selectDisciplineId, String teacherUserName) { IEnumerable <Topic> allowedTopics; User teacherUser = iLmsService.FindService <IUserService>().GetCurrentUser(); IEnumerable <Course> availableCourses = iLmsService.FindService <ICourseService>().GetCourses(teacherUser); // allowedTopics = iLmsService.FindService <IDisciplineService>().GetTopicsByDisciplineId((int)selectDisciplineId) .Where(topic => availableCourses.Count(course => course.Id == topic.TestCourseRef) != 0); // if (allowedTopics != null & allowedTopics.Count() != 0) { _AllowedTopics = allowedTopics; } else { _AllowedTopics = null; } _TeacheUserName = teacherUserName; _DisciplineName = iLmsService.FindService <IDisciplineService>().GetDiscipline((int)selectDisciplineId).Name; }
public ShowQualityTestModel(ILmsService iLmsService, int[] selectGroupIds, String disciplineName, int selectedCurriculumChapterTopicId) { _DisciplineName = disciplineName; var seletedCurriculumChapterTopic = iLmsService.FindService <ICurriculumService>().GetCurriculumChapterTopicById(selectedCurriculumChapterTopicId); _TopicName = seletedCurriculumChapterTopic.Topic.Name; //Creation of list of students answers _ListOfUserAnswers = StudentsAnswers(iLmsService, selectGroupIds, seletedCurriculumChapterTopic); _ListOfQuestionModels = CreationOfQuestionModels(); }
public ShowQualityTestModel(ILmsService iLmsService, int[] selectGroupIds, String curriculumName, int selectThemeId) { _CurriculumName = curriculumName; //Theme object that needs for geting user answers Theme selectTheme = iLmsService.FindService <ICurriculumService>().GetTheme(selectThemeId); _ThemeName = selectTheme.Name; //Creation of list of students answers _ListOfUserAnswers = StudentsAnswers(iLmsService, selectGroupIds, selectTheme); _ListOfQuestionModels = CreationOfQuestionModels(); }
public ShowQualityTestModel(ILmsService iLmsService, int[] selectGroupIds, String disciplineName, int selectTopicId) { _DisciplineName = disciplineName; //Topic object that needs for geting user answers Topic selectTopic = iLmsService.FindService <ICurriculumService>().GetTopic(selectTopicId); _TopicName = selectTopic.Name; //Creation of list of students answers _ListOfUserAnswers = StudentsAnswers(iLmsService, selectGroupIds, selectTopic); _ListOfQuestionModels = CreationOfQuestionModels(); }
public IndexModel(ILmsService iLmsService) { IEnumerable<Discipline> allowedDisciplines; User teacherUser; teacherUser = iLmsService.FindService<IUserService>().GetCurrentUser(); //TODO: review this method allowedDisciplines=new Discipline[]{}; //allowedDisciplines = iLmsService.FindService<IDisciplineService>().GetDisciplinesWithTopicsOwnedByUser(teacherUser); // if (allowedDisciplines != null & allowedDisciplines.Count() != 0) _AllowedDisciplines = allowedDisciplines; else _AllowedDisciplines = null; _TeacherUser = teacherUser; }
public IndexModel(ILmsService iLmsService) { IEnumerable <Discipline> allowedDisciplines; User teacherUser; teacherUser = iLmsService.FindService <IUserService>().GetCurrentUser(); //TODO: review this method allowedDisciplines = new Discipline[] {}; //allowedDisciplines = iLmsService.FindService<IDisciplineService>().GetDisciplinesWithTopicsOwnedByUser(teacherUser); // if (allowedDisciplines != null & allowedDisciplines.Count() != 0) { _AllowedDisciplines = allowedDisciplines; } else { _AllowedDisciplines = null; } _TeacherUser = teacherUser; }
/// <summary> /// constructor that get all information from Testing System /// </summary> /// <param name="attemptId">id of attempt to show</param> /// <param name="attList">list of attempts from Session Context</param> /// <param name="lmsService">ILmsService for conection to Testing System</param> public TopicTestResultsModel(long attemptId, IEnumerable<AttemptResult> attList, ILmsService lmsService) { if (attemptId != -1) { Attempt = attList.First(c => c.AttemptId == attemptId); if (Attempt != null) { UserAnswers = lmsService.FindService<ITestingService>().GetAnswers(Attempt); if (UserAnswers != null) _NoData = false; else _NoData = true; } else { _NoData = true; } } else _NoData = true; }
public double? GetTopicResultScore(ILmsService lmsService) { if (this.AttemptResults.Count() == 0 || this.AttemptResults.First().Score.ScaledScore == null) { this.Res = 0.0; this.ResMax = 0.0; } else { // hotfix: added checking of Course id var attemptResult = this.AttemptResults.FirstOrDefault( x => x.User.Id == this.user.Id & x.CurriculumChapterTopic.Id == this.curriculumChapterTopic.Id & x.CurriculumChapterTopic.Topic.TestCourseRef == x.IudicoCourseRef); if (attemptResult == null) { this.Res = 0.0; this.ResMax = 0.0; return this.Res; } this.Res = attemptResult.Score.RawScore; var answerResults = lmsService.FindService<ITestingService>().GetAnswers(attemptResult); int iudicoCourseRef = attemptResult.IudicoCourseRef; var courseInfo = lmsService.FindService<ICourseService>().GetCourseInfo(iudicoCourseRef); double maxScore = 0; foreach (var node in courseInfo.NodesInfo) { if (answerResults.Any(answer => int.Parse(answer.PrimaryResourceFromManifest.Replace(".html", string.Empty)) == node.Id)) { maxScore += node.MaxScore; } } this.ResMax = maxScore; } return this.Res; }
public TopicInfoModel(int groupId, int disciplineId, ILmsService lmsService) { _LastAttempts = new List<AttemptResult>(); DisciplineId = disciplineId; Group group = lmsService.FindService<IUserService>().GetGroup(groupId); SelectGroupStudents = lmsService.FindService<IUserService>().GetUsersByGroup(group); SelectDisciplineTopics = lmsService.FindService<ICurriculumService>().GetTopicsByDisciplineId(DisciplineId); foreach (var temp in from student in SelectGroupStudents from topic in SelectDisciplineTopics select lmsService.FindService<ITestingService>().GetResults(student, topic) into temp where temp != null select temp) { var filteredTemp = temp//.Where(attempt => attempt.CompletionStatus == CompletionStatus.Completed) .OrderBy(attempt => attempt.StartTime); if (filteredTemp.Count() != 0) _LastAttempts.Add(filteredTemp.First()); } }
public UserAnswers(User user, AttemptResult score, ILmsService iLmsService) { _User = user; _Score = score.Score.ToPercents(); _ListOfAnswers = iLmsService.FindService <ITestingService>().GetAnswers(score); }
public void GenerateMenuUsingRoleNone() { var httpRequest = new HttpRequest(string.Empty, "http://mySomething/", string.Empty); var stringWriter = new StringWriter(); var httpResponce = new HttpResponse(stringWriter); // httpResponce.Filter = new FileStream("asd.pdo",FileMode.CreateNew); var httpConextMock = new HttpContext(httpRequest, httpResponce); HttpContext.Current = httpConextMock; var menu = new Menu(); var menu1 = new Menu(); container = new WindsorContainer(); // HttpContext.Current = new HttpContext(new HttpRequest("", "http://iudico.com", null), new HttpResponse(new StreamWriter("mayBeDeleted.txt"))); InitializeWindsor(ref container); service = container.Resolve<ILmsService>(); PluginController.LmsService = service; var plugins = container.ResolveAll<IPlugin>(); var actions = new Dictionary<IPlugin, IEnumerable<Action>>(); var roles = new List<Role> { Role.None }; var currentRole = from rol in roles select rol; var userServiceMock = new Mock<IUserService>(); userServiceMock.Setup(item => item.GetCurrentUserRoles()).Returns(currentRole); var userServiceVar = service.FindService<IUserService>(); userServiceVar = userServiceMock.Object; var lmsservice = new Mock<ILmsService>(); lmsservice.Setup(item => item.FindService<IUserService>()).Returns(userServiceMock.Object); var acct = new AccountController(new DatabaseUserStorage(service)); lmsservice.Setup(item => item.GetMenu()).Returns(menu); try { service = lmsservice.Object; service.Inform(LMSNotifications.ApplicationRequestStart); } catch (Exception) { } foreach (var plugin in plugins) { menu.Add(plugin.BuildMenuItems().Where(m => this.IsAllowed(m.Controller, m.Action, roles))); } foreach (var plugin in plugins) { var menu11 = plugin.BuildMenuItems(); foreach (var menu2 in menu.Items) { if (menu11.Count(item => item == menu2) == 0) { Assert.Fail("Iterms mismatch"); } } } }
public User GetCurrentUser() { return(_LmsService.FindService <IUserService>().GetCurrentUser()); }
public void GenerateMenuUsingRoleNone() { HttpRequest httpRequest = new HttpRequest("", "http://mySomething/", ""); StringWriter stringWriter = new StringWriter(); HttpResponse httpResponce = new HttpResponse(stringWriter); //httpResponce.Filter = new FileStream("asd.pdo",FileMode.CreateNew); HttpContext httpConextMock = new HttpContext(httpRequest, httpResponce); HttpContext.Current = httpConextMock; Menu menu = new Menu(); Menu menu1 = new Menu(); container = new WindsorContainer(); //HttpContext.Current = new HttpContext(new HttpRequest("", "http://iudico.com", null), new HttpResponse(new StreamWriter("mayBeDeleted.txt"))); InitializeWindsor(ref container); service = container.Resolve <ILmsService>(); PluginController.LmsService = service; var plugins = container.ResolveAll <IPlugin>(); Dictionary <IPlugin, IEnumerable <IUDICO.Common.Models.Action> > actions = new Dictionary <IPlugin, IEnumerable <Common.Models.Action> >(); Dictionary <IPlugin, IEnumerable <IUDICO.Common.Models.Action> > actions1; List <Role> roles = new List <Role>(); roles.Add(Role.None); IEnumerable <Role> currentRole = from rol in roles select rol; Mock <IUserService> userServiceMock = new Mock <IUserService>(); userServiceMock.Setup(item => item.GetCurrentUserRoles()).Returns(currentRole); IUserService userServiceVar = service.FindService <IUserService>(); userServiceVar = userServiceMock.Object; Mock <ILmsService> lmsservice = new Mock <ILmsService>(); lmsservice.Setup(item => item.FindService <IUserService>()).Returns(userServiceMock.Object); AccountController acct = new AccountController(new DatabaseUserStorage(service)); lmsservice.Setup(item => item.GetMenu()).Returns(menu); try { service = lmsservice.Object; service.Inform(LMSNotifications.ApplicationRequestStart); } catch (Exception e) { } foreach (var plugin in plugins) { menu.Add(plugin.BuildMenuItems().Where(m => IsAllowed(m.Controller, m.Action, roles))); } foreach (var plugin in plugins) { IEnumerable <MenuItem> menu11 = plugin.BuildMenuItems(); foreach (var menu2 in menu.Items) { if (menu11.Count(item => item == menu2) == 0) { Assert.Fail("Iterms mismatch"); } } } }
public ThemeInfoModel(int groupId, int curriculumId, ILmsService lmsService) { LmsService = lmsService; CurriculumId = curriculumId; SelectStudents = LmsService.FindService<IUserService>().GetUsersByGroup ( LmsService.FindService<IUserService>().GetGroup(groupId) ); SelectCurriculumThemes = LmsService.FindService<ICurriculumService>().GetThemesByCurriculumId ( CurriculumId ); //LastAttempts = LmsService.FindService<ITestingService>().GetLastCompleteAttemptsForThemes // ( // LmsService.FindService<IUserService>().GetGroup(groupId), // SelectCurriculumThemes // ); LastAttempts = new List<AttemptResult>(); foreach (User student in SelectStudents) { foreach (Theme theme in SelectCurriculumThemes) { IEnumerable<AttemptResult> temp = LmsService.FindService<ITestingService>().GetResults(student, theme); if (temp != null) LastAttempts.Add(temp.First()); } } }