コード例 #1
0
 public void GroupCreateGroup()
 {
     var group = new Group { Name = "group1" };
     var result = this.groupController.Create(group) as RedirectToRouteResult;
     
     Assert.IsNotNull(result);
     Assert.AreEqual("Index", result.RouteValues["action"]);
 }
コード例 #2
0
ファイル: SeeGroupsDetails.cs プロジェクト: supermuk/iudico
        public void GetGroup()
        {
            var group = new Group { Deleted = false, Id = 323, Name = "pmp41" };
            
            _Tests.Storage.CreateGroup(group);

            Assert.AreEqual(group.Name, _Tests.Storage.GetGroup(group.Id).Name);
        }
コード例 #3
0
ファイル: DeleteGroup.cs プロジェクト: supermuk/iudico
        public void DeleteGroupSuccess()
        {
            var group = new Group { Deleted = false, Id = 333123456, Name = "pma31" };
            
            _Tests.Storage.CreateGroup(group);
            _Tests.Storage.DeleteGroup(group.Id);

            Assert.IsTrue(_Tests.Storage.GetGroup(group.Id) == null);
        }
コード例 #4
0
ファイル: DeleteGroup.cs プロジェクト: supermuk/iudico
        public void DeleteGroupExisting()
        {
            var group = new Group { Id = 123, Name = "pmi31" };

            this.tests.Storage.CreateGroup(group);
            this.tests.Storage.DeleteGroup(group.Id);

            Assert.IsTrue(this.tests.Storage.GetGroup(group.Id) == null);
        }
コード例 #5
0
ファイル: CreateNewGroup.cs プロジェクト: supermuk/iudico
        public void CreateGroup()
        {
            var group = new Group { Deleted = false, Id = 12345678, Name = "pmi31" };
            
            _Tests.Storage.CreateGroup(group);

            Assert.AreEqual(group.Name, _Tests.Storage.GetGroup(group.Id).Name);
            
            _Tests.Storage.DeleteGroup(group.Id);
        }
コード例 #6
0
ファイル: SeeGroupsDetails.cs プロジェクト: supermuk/iudico
        public void GetGroupExisting()
        {
            var group = new Group { Id = 12, Name = "pmi31" };

            this.tests.Storage.CreateGroup(group);

            Assert.AreEqual(group, this.tests.Storage.GetGroup(group.Id));

            this.tests.Storage.DeleteGroup(group.Id);
        }
コード例 #7
0
ファイル: CreateNewGroup.cs プロジェクト: supermuk/iudico
        public void CreateGroupInvalid()
        {
            var group = new Group { Id = 4567, Name = "pma51" };

            _Tests.Storage.CreateGroup(group);

            Assert.IsTrue(group.Name == _Tests.Storage.GetGroup(group.Id).Name && group.Id == _Tests.Storage.GetGroup(group.Id).Id);
            
            _Tests.Storage.DeleteGroup(group.Id);
        }
コード例 #8
0
        public void RemoveNonExistingUserFromNonExistingGroup()
        {
            var group = new Group { Id = 345678, Name = "pmi31" };
            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };

            this.tests.Storage.AddUserToGroup(group, temp);
            this.tests.Storage.RemoveUserFromGroup(group, temp);

            Assert.AreEqual(null, this.tests.Storage.GetUser(u => u.Username == temp.Username));
            Assert.AreEqual(0, this.tests.Storage.GetGroupsByUser(temp).Count());
        }
コード例 #9
0
ファイル: AddUserToGroup.cs プロジェクト: supermuk/iudico
        public void AddNonExistingUserToNonExistingGroup()
        {
            tests = UserManagementTests.Update();
            var group = new Group { Id = 12366, Name = "pmp51" };
            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };

            this.tests.Storage.AddUserToGroup(group, temp);

            Assert.IsFalse(this.tests.Storage.GetUsersInGroup(group).Contains(temp));
            Assert.AreEqual(0, this.tests.Storage.GetGroupsByUser(temp).Count());
        }
コード例 #10
0
ファイル: EditGroup.cs プロジェクト: supermuk/iudico
        public void EditGroupExistingValid()
        {
            var group = new Group { Id = 1254, Name = "pmp41" };

            _Tests.Storage.CreateGroup(group);
            group = new Group { Id = 1254, Name = "pmp51" };
            _Tests.Storage.EditGroup(group.Id,group);
            Assert.IsTrue(group.Name == _Tests.Storage.GetGroup(group.Id).Name && group.Id == _Tests.Storage.GetGroup(group.Id).Id);

            _Tests.Storage.DeleteGroup(group.Id);
        }
コード例 #11
0
        public void RemoveExistingUserFromNonExistingGroup()
        {
            var group = new Group { Id = 12677, Name = "pmi31" };
            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };

            this.tests.Storage.CreateUser(temp);
            temp = this.tests.Storage.GetUser(u => u.Username == temp.Username);

            this.tests.Storage.RemoveUserFromGroup(group, temp);
            Assert.IsFalse(this.tests.Storage.GetGroupsByUser(temp).Contains(group));

            this.tests.Storage.DeleteUser(u => u.Username == "name");
        }
コード例 #12
0
ファイル: AddUserToGroup.cs プロジェクト: supermuk/iudico
        public void AddNonExistingUserToNonExistingGroup()
        {
            _Tests.MockStorage.Setup(s => s.GetCurrentUser()).Returns(_Tests.Storage.GetUser(u => u.Username == "panza"));

            var group = new Group { Id = 12366, Name = "pmp51" };

            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };

            _Tests.Storage.AddUserToGroup(group, temp);

            Assert.AreEqual(null, _Tests.Storage.GetUser(u => u.Username == temp.Username));
            Assert.AreEqual(0,_Tests.Storage.GetGroupsByUser(temp).Count());
        }
コード例 #13
0
ファイル: AddUserToGroup.cs プロジェクト: supermuk/iudico
        public void AddExistingUserToNonExistingGroup()
        {
            tests = UserManagementTests.Update();
            var group = new Group { Id = 12366, Name = "pmp51" };
            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };

            this.tests.Storage.CreateUser(temp);
            temp = this.tests.Storage.GetUser(u => u.Username == temp.Username);

            this.tests.Storage.AddUserToGroup(group, temp);
            Assert.IsFalse(this.tests.Storage.GetGroupsByUser(temp).Contains(group));

            this.tests.Storage.DeleteUser(u => u.Username == "name");
        }
コード例 #14
0
ファイル: CreateNewGroup.cs プロジェクト: supermuk/iudico
        public void CreateGroupInvalid()
        {
            tests = UserManagementTests.Update();

            var group = new Group { Id = 4567, Name = "pma51" };

            this.tests.Storage.CreateGroup(group);

            Assert.IsTrue(
                group.Name == this.tests.Storage.GetGroup(group.Id).Name
                && group.Id == this.tests.Storage.GetGroup(group.Id).Id);

            this.tests.Storage.DeleteGroup(group.Id);
        }
コード例 #15
0
ファイル: AddUserToGroup.cs プロジェクト: supermuk/iudico
        public void AddNonExistingUserToExistingGroup()
        {
            tests = UserManagementTests.Update();
            var group = new Group { Id = 1266678, Name = "pmi31" };
            this.tests.Storage.CreateGroup(group);
            group = this.tests.Storage.GetGroup(group.Id);
            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };

            this.tests.Storage.AddUserToGroup(group, temp);
            Assert.IsTrue(this.tests.Storage.GetGroupsByUser(temp).Contains(group));
            Assert.IsFalse(this.tests.Storage.GetUsersInGroup(group).Contains(temp));// this.tests.Storage.GetUser(temp.Username));

            this.tests.Storage.DeleteGroup(group.Id);
        }
コード例 #16
0
        public void GroupCreateGroupFail()
        {
            this.groupController.RouteData.Values["action"] = "Create";

            var group = new Group();
            
            this.groupController.ModelState.AddModelError("key", "error");
            
            var result = this.groupController.Create(group) as ViewResult;

            Assert.IsNotNull(result);

            var p = Path.GetFileNameWithoutExtension(result.ViewName);
            Assert.AreEqual("Create", Path.GetFileNameWithoutExtension(result.ViewName));
        }
コード例 #17
0
ファイル: AddUserToGroup.cs プロジェクト: supermuk/iudico
        public void AddExistingUserToNonExistingGroup()
        {
            _Tests.MockStorage.Setup(s => s.GetCurrentUser()).Returns(_Tests.Storage.GetUser(u => u.Username == "panza"));

            var group = new Group { Id = 12366, Name = "pmp51" };

            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };
            _Tests.Storage.CreateUser(temp);
            temp = _Tests.Storage.GetUser(u => u.Username == temp.Username);

            _Tests.Storage.AddUserToGroup(group, temp);
            Assert.IsFalse(_Tests.Storage.GetGroupsByUser(temp).Contains(group));

            _Tests.Storage.DeleteUser(u => u.Username == "name");
        }
コード例 #18
0
ファイル: AddUserToGroup.cs プロジェクト: supermuk/iudico
        public void AddNonExistingUserToExistingGroup()
        {
            _Tests.MockStorage.Setup(s => s.GetCurrentUser()).Returns(_Tests.Storage.GetUser(u => u.Username == "panza"));

            var group = new Group { Id = 1266678, Name = "pmi31" };
            _Tests.Storage.CreateGroup(group);
            group = _Tests.Storage.GetGroup(group.Id);
            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };

            _Tests.Storage.AddUserToGroup(group, temp);
            Assert.IsTrue(_Tests.Storage.GetGroupsByUser(temp).Contains(group));
            Assert.AreEqual(null, _Tests.Storage.GetUser(u => u.Username == temp.Username));

            _Tests.Storage.DeleteGroup(group.Id);
        }
コード例 #19
0
ファイル: AddUserToGroup.cs プロジェクト: supermuk/iudico
        public void GetGroupsAvailableToExistingUser()
        {
            tests = UserManagementTests.Update();
            var group = new Group { Id = 12345678, Name = "pmi31" };
            this.tests.Storage.CreateGroup(group);
            group = this.tests.Storage.GetGroup(group.Id);

            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };
            this.tests.Storage.CreateUser(temp);
            temp = this.tests.Storage.GetUser(temp.Username);

            Assert.IsTrue(this.tests.Storage.GetGroupsAvailableToUser(temp).Contains(group));

            this.tests.Storage.DeleteUser(u => u.Username == "name");

            this.tests.Storage.DeleteGroup(group.Id);
        }
コード例 #20
0
ファイル: AddUserToGroup.cs プロジェクト: supermuk/iudico
        public void GetGroupsAvailableToExistingUser()
        {
            _Tests.MockStorage.Setup(s => s.GetCurrentUser()).Returns(_Tests.Storage.GetUser(u => u.Username == "panza"));

            var group = new Group { Id = 12345678, Name = "pmi31" };
            _Tests.Storage.CreateGroup(group);
            group = _Tests.Storage.GetGroup(group.Id);
            
            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };
            _Tests.Storage.CreateUser(temp);
            temp = _Tests.Storage.GetUser(u => u.Username == temp.Username);

            Assert.IsTrue(_Tests.Storage.GetGroupsAvailableToUser(temp).Contains(group));

            _Tests.Storage.DeleteGroup(group.Id);
            _Tests.Storage.DeleteUser(u => u.Username == "name");
        }
コード例 #21
0
        public void RemoveNonExistingUserFromExistingGroup()
        {
            var group = new Group { Id = 12345678, Name = "pmi31" };

            this.tests.Storage.CreateGroup(group);

            group = this.tests.Storage.GetGroup(group.Id);

            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };

            this.tests.Storage.AddUserToGroup(group, temp);
            this.tests.Storage.RemoveUserFromGroup(group, temp);

            Assert.IsFalse(this.tests.Storage.GetGroupsByUser(temp).Contains(group));
            Assert.AreEqual(null, this.tests.Storage.GetUser(u => u.Username == temp.Username));

            this.tests.Storage.DeleteGroup(group.Id);
        }
コード例 #22
0
ファイル: Cache.cs プロジェクト: supermuk/iudico
        public void InvalidateGroup()
        {
            // original caching
            //this.tests.Storage.GetGroups();
            tests = UserManagementTests.Update();

            var group = new Group { Id = 1254, Name = "pmp41" };

            this.tests.Storage.CreateGroup(group);

            group = new Group { Id = 1254, Name = "pmp51" };

            this.tests.Storage.EditGroup(group.Id, group);

            Assert.IsTrue(
                group.Name == this.tests.Storage.GetGroup(group.Id).Name
                && group.Id == this.tests.Storage.GetGroup(group.Id).Id);

            this.tests.Storage.DeleteGroup(group.Id);
        }
コード例 #23
0
ファイル: CurriculumTests.cs プロジェクト: supermuk/iudico
 public void GetDisciplinesByGroupId()
 {
     List<Discipline> disciplines = CreateDefaultData();
     disciplines.ForEach(item => _Storage.AddDiscipline(item));
     Group group = new Group {Id = 1, Name = "Group1"};
     var curriculums = disciplines.Select(item => new Curriculum {Discipline = item, UserGroupRef = group.Id})
         .ToList();
     curriculums.ForEach(i => _Storage.AddCurriculum(i));
     Assert.AreEqual(disciplines, _Storage.GetDisciplinesByGroupId(group.Id).ToList());
 }
コード例 #24
0
 public IEnumerable<Group> AvailebleGroups(int topicId)
 {
     //User teacherUser = _LmsService.FindService<IUserService>().GetCurrentUser();
     //return _LmsService.FindService<ICurriculumService>().GetTopicsOwnedByUser(teacherUser);
     Group i41 = new Group();
     i41.Id = 1;
     i41.Name = "PMI 41";
     Group i42 = new Group();
     i42.Id = 2;
     i42.Name = "PMI 42";
     Group i43 = new Group();
     i43.Id = 3;
     i43.Name = "PMI 43";
     List<Group> res = new List<Group>();
     res.Add(i41);
     res.Add(i42);
     res.Add(i43);
     return res;
 }
コード例 #25
0
        public GroupTopicStat GetGroupTopicStatistic(Topic topic, Group group)
        {
            var results = GetResults(topic);

            var groupResults = results.Where(r => r.User.GroupUsers.Select(g => g.GroupRef)
                                      .Contains(group.Id))
                                      .Select(r => new UserRating(r.User, r.Score.ToPercents().Value))
                                      .ToList();
            
            var usersParticipated = groupResults.Select(g => g.User);
            var n = usersParticipated.Count();

            if (n == 0)
            {
                return new GroupTopicStat(0, 0);
            }

            var usersIds = usersParticipated.Select(u => u.Id);

            var groupRatings = group.GroupUsers
                                    .Select(gu => new UserRating(gu.User, 1.0 * gu.User.TestsSum / gu.User.TestsTotal))
                                    .Where(gu => usersIds.Contains(gu.User.Id))
                                    .ToList();

            groupResults.Sort();
            groupRatings.Sort();

            var ratResults = groupResults.Select((r, i) => new { User = r.User, Index = i }).ToDictionary(a => a.User, a => a.Index);
            var ratRatings = groupRatings.Select((r, i) => new { User = r.User, Index = i }).ToDictionary(a => a.User, a => a.Index);

            var ratingDifference = 1.0 * usersParticipated.Sum(u => Math.Abs(ratResults[u] - ratRatings[u]));
            var ratingMax = 2*((n + 1)/2)*(n/2);
            var ratingNormalized = ratingDifference/ratingMax;

            var diffResults = groupResults.ToDictionary(a => a.User, a => a.Score);
            var diffRatings = groupRatings.ToDictionary(a => a.User, a => a.Score);

            var scoreDifference = 1.0 * usersParticipated.Sum(u => Math.Abs(diffResults[u] - diffRatings[u]));
            var scoreMax = n*100;
            var scoreNormalized = scoreDifference / scoreMax;

            return new GroupTopicStat(ratingNormalized, scoreNormalized);
        }
コード例 #26
0
ファイル: EditGroup.cs プロジェクト: supermuk/iudico
        public void EditGroupNonExisting()
        {
            var group = new Group { Id = 1253, Name = "pmp51" };

            this.tests.Storage.EditGroup(group.Id, group);
        }
コード例 #27
0
        public GroupTopicStat GetGroupTopicStatistic(Topic topic, Group group)
        {
            //Всі результати по топіку
            var results = this.GetResults(topic);

            //Результати учнів тільки даної групи
            var groupResults = results.Where(r => r.User.GroupUsers.Select(g => g.GroupRef)
                                      .Contains(group.Id))
                                      .Where(s => s.Score.ToPercents()!=null)
                                      .Select(r => new UserRating(r.User, r.Score.ToPercents().Value))
                                      .ToList();
            
            var usersParticipated = groupResults.Select(g => g.User).ToList();
            var n = usersParticipated.Count();

            if (n == 0)
            {
                return new GroupTopicStat(0, 0);
            }

            var usersIds = usersParticipated.Select(u => u.Id);

            var groupRatings = group.GroupUsers
                                    .Select(gu => new UserRating(gu.User, (gu.User.TestsTotal > 0 ? 1.0 * gu.User.TestsSum / gu.User.TestsTotal : 0)))
                                    .Where(gu => usersIds.Contains(gu.User.Id))
                                    .ToList();

            groupResults.Sort();
            groupRatings.Sort();

            var ratResults = groupResults.Select((r, i) => new { User = r.User, Index = i }).ToDictionary(a => a.User.Id, a => a.Index);
            var ratRatings = groupRatings.Select((r, i) => new { User = r.User, Index = i }).ToDictionary(a => a.User.Id, a => a.Index);

            var ratingDifference = 1.0 * usersParticipated.Sum(u => Math.Abs(ratResults[u.Id] - ratRatings[u.Id]));
            
            var ratingMax = (n * n + n) / 2;
            var ratingNormalized = 1 - (ratingDifference / ratingMax);

            var diffResults = groupResults.ToDictionary(a => a.User.Id, a => a.Score);
            var diffRatings = groupRatings.ToDictionary(a => a.User.Id, a => a.Score);

            var scoreDifference = 1.0 * usersParticipated.Sum(u => Math.Abs(diffResults[u.Id] - diffRatings[u.Id]));
            var scoreMax = n * 100;
            var scoreNormalized = 1 - (scoreDifference / scoreMax);

            return new GroupTopicStat(ratingNormalized, scoreNormalized);
        }
コード例 #28
0
ファイル: DBDataContext.cs プロジェクト: supermuk/iudico
 partial void UpdateGroup(Group instance);
コード例 #29
0
ファイル: DBDataContext.cs プロジェクト: supermuk/iudico
 partial void InsertGroup(Group instance);
コード例 #30
0
ファイル: DBDataContext.cs プロジェクト: supermuk/iudico
 partial void DeleteGroup(Group instance);