示例#1
0
 public Grade(Assessment assessment, Profile profile)
 {
     IsLate = false;
     Assessment = assessment;
     Student = profile;
     SubmissionRecord record = (from s in assessment.SubmissionRecords
                                    where s.StudentID == profile.MembershipID
                                    orderby s.Score descending
                                    select s).FirstOrDefault();
     if (record == null)
     {
         Points = 0;
         Percentage = 0;
         SubmissionRecord = null;
     }
     else
     {
         Points = record.Score;
         Percentage = (assessment.IsExtraCredit)? 100 : ((record.Score / assessment.Weight) * 100);
         SubmissionRecord = record;
         if (record.SubmissionDate.CompareTo(assessment.DueDate) > 0)
         {
             IsLate = true;
         }
     }
 }
示例#2
0
        public GradeSection(AssessmentType assessmentType, Profile profile, AssessTrackDataRepository repo, bool includeExtraCredit, DateTime date)
        {
            AssessmentType = assessmentType;
            TotalPoints = MaxPoints = 0;
            Grades = new List<Grade>();
            CourseTermMember member = repo.GetCourseTermMemberByMembershipID(assessmentType.CourseTerm, profile.MembershipID);
            List<Assessment> assessments = repo.GetAllNonTestBankAssessments(assessmentType.CourseTerm, includeExtraCredit, assessmentType, member).Where(test => test.DueDate.CompareTo(date) < 0).ToList();
            foreach (Assessment assessment in assessments)
            {
                Grade grade = new Grade(assessment, profile);
                Grades.Add(grade);

                if ((grade.SubmissionRecord != null && grade.SubmissionRecord.GradedBy != null) ||
                    (DateTime.Now.CompareTo(assessment.DueDate) > 0 && grade.SubmissionRecord == null))
                {
                    MaxPoints += assessment.Weight;
                    TotalPoints += grade.Points;
                }
            }
            //if (TotalPoints > 0 && MaxPoints == 0) //if everything is extra credit
            //{
            //    MaxPoints = 1; //to avoid division by zero
            //}

            if (MaxPoints == 0)
            {
                Percentage = 0;
                Weight = 0;
            }
            else
            {
                Percentage = (TotalPoints / MaxPoints) * 100;
                Weight = assessmentType.Weight;
            }
        }
示例#3
0
        public double Score(Profile profile)
        {
            Grade grade = new Grade(this.Assessment, profile);
            if (grade.SubmissionRecord == null)
                return 0.0;
            var responses = from response in grade.SubmissionRecord.Responses where response.Answer.QuestionID == this.QuestionID select response;
            double? score = responses.Sum(response => response.Score);

            return (score.HasValue) ? score.Value : 0.0;
        }
示例#4
0
        public void CreateSite(Profile owner, Site site)
        {
            dc.Sites.InsertOnSubmit(site);

            dc.SiteMembers.InsertOnSubmit(new SiteMember()
            {
                MembershipID = owner.MembershipID,
                Site = site,
                AccessLevel = 10
            });

            dc.SubmitChanges();
        }
示例#5
0
 public void CreateProfile(Profile newProfile)
 {
     newProfile.AccessLevel = 1;
     dc.Profiles.InsertOnSubmit(newProfile);
     dc.SubmitChanges();
 }
 public bool IsCourseTermMember(CourseTerm courseTerm, Profile profile)
 {
     CourseTermMember ctMember = (from ctm in dc.CourseTermMembers
                                  where ctm.CourseTerm == courseTerm
                                  && ctm.Profile == profile
                                  select ctm).SingleOrDefault();
     return (ctMember != null);
 }
示例#7
0
 double ITaggable.Score(Profile profile)
 {
     Grade grade = new Grade(this, profile);
     return grade.Points;
 }
        public ActionResult Register(string userName, string email, string password, string confirmPassword)
        {
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;

            if (ValidateRegistration(userName, email, password, confirmPassword))
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus = MembershipService.CreateUser(userName, password, email);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    Guid membershipID = UserHelpers.GetIDFromUsername(userName);
                    Profile profile = new Profile();
                    UpdateModel(profile);
                    if (ModelState.IsValid)
                    {
                        try
                        {
                            profile.MembershipID = membershipID;
                            dataRepository.CreateProfile(profile);
                            FormsAuth.SignIn(userName, false /* createPersistentCookie */);
                            return RedirectToAction("Index", "Home");
                        }
                        catch
                        {
                            ModelState.AddModelErrors(profile.GetRuleViolations());
                        }

                    }
                }
                else
                {
                    ModelState.AddModelError("_FORM", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return View();
        }
        public ActionResult AcceptInvite(Guid id, string userName, string password, string confirmPassword)
        {
            Invitation invite = dataRepository.Single<Invitation>(inv => inv.InvitationID == id);

            if (invite == null)
            {
                FlashMessageHelper.AddMessage("Invite not found.");
                return RedirectToRoute(new { action = "Index", controller = "Home" });
            }
            using (TransactionScope scope = new TransactionScope())
            {
                string email = invite.Email;
                ViewData["PasswordLength"] = MembershipService.MinPasswordLength;

                if (ValidateRegistration(userName, email, password, confirmPassword))
                {
                    // Attempt to register the user
                    MembershipCreateStatus createStatus = MembershipService.CreateUser(userName, password, email);

                    if (createStatus == MembershipCreateStatus.Success)
                    {
                        Guid membershipID = UserHelpers.GetIDFromUsername(userName);
                        Profile profile = new Profile();
                        UpdateModel(profile);
                        if (ModelState.IsValid)
                        {
                            try
                            {
                                profile.MembershipID = membershipID;
                                dataRepository.CreateProfile(profile);

                                //Create site membership
                                SiteMember sitemember = new SiteMember()
                                {
                                    AccessLevel = invite.SiteAccessLevel,
                                    Site = invite.Site,
                                    Profile = profile
                                };

                                //Create courseterm member
                                if (invite.CourseTerm != null)
                                {
                                    CourseTermMember ctmember = new CourseTermMember()
                                    {
                                        AccessLevel = invite.CourseTermAccessLevel.Value,
                                        CourseTerm = invite.CourseTerm,
                                        Profile = profile
                                    };
                                }

                                invite.Accepted = true;
                                dataRepository.Save();
                                FormsAuth.SignIn(userName, false /* createPersistentCookie */);
                                scope.Complete();
                                return RedirectToAction("Index", "Home");
                            }
                            catch
                            {
                                ModelState.AddModelErrors(profile.GetRuleViolations());
                            }

                        }
                    }
                    else
                    {
                        ModelState.AddModelError("_FORM", ErrorCodeToString(createStatus));
                    }
                }

            }
            // If we got this far, something failed, redisplay form
            return View(invite);
        }
示例#10
0
        public double GetStudentScoreForTag(Tag tag, Profile profile)
        {
            double totalweight = 0.0;
            double totalpoints = 0.0;

            List<ITaggable> items = GetTaggedItems(tag);
            foreach (var taggeditem in items)
            {
                totalpoints += taggeditem.Score(profile);
                totalweight += taggeditem.Weight;
            }
            double avg = totalpoints / totalweight * 100;

            if (double.IsNaN(avg))
            {
                avg = -100.0;
            }

            return avg;
        }
示例#11
0
        public double GetStudentPfmeForTag(Tag tag, Profile profile)
        {
            double totalweight = 0.0;
            double totalpoints = 0.0;

            List<ITaggable> items = GetTaggedItems(tag);
            foreach (var taggeditem in items)
            {
                totalpoints += taggeditem.Score(profile);
                totalweight += taggeditem.Weight;
            }
            double avg = totalpoints / totalweight * 100;
            double pfme = GradeHelpers.GetPfme(avg);

            return pfme;
        }
示例#12
0
 public List<TagViewModel> GetStrugglingTags(Profile p, CourseTerm t)
 {
     var tags = from tag in t.Tags
                let score = GetStudentScoreForTag(tag, p)
                where score <= 65.0 && score >= 0.0
                select new TagViewModel() { Tag = tag, Score = GetStudentScoreForTag(tag, p) };
     return tags.ToList();
 }
示例#13
0
 public bool IsSiteMember(Site site, Profile profile)
 {
     return IsSiteMember(site, profile.MembershipID);
 }
示例#14
0
 public PerformanceReportModel(List<GradeSection> sections, Profile profile)
 {
     GradeSections = sections;
     Profile = profile;
 }
示例#15
0
 public GradeSnapshotModel(StudentGradeDistribution g, Profile p)
 {
     gradeDist = g;
     profile = p;
 }
示例#16
0
 public double Score(Profile profile)
 {
     Grade grade = new Grade(this.Assessment, profile);
     if (grade.SubmissionRecord == null || grade.SubmissionRecord.Responses.Count == 0)
         return 0.0;
     var response = (from resp in grade.SubmissionRecord.Responses where resp.AnswerID == this.AnswerID select resp).FirstOrDefault();
     if (response == null)
     {
         return 0.0;
     }
     return (response.Score.HasValue)? response.Score.Value : 0.0;
 }