コード例 #1
0
        protected int GetStudentWorkProcProgress(StudentWorkProc studentWorkProc)
        {
            Work work = studentWorkProc.WorkProc.Work;

            if (studentWorkProc.CurrentValue.Completion != 0)
            {
                return 100;
            }
            else
            {
                int completedStages = 0;
                int allRequiredStages = 0;

                foreach (var studentStageProc in studentWorkProc.StudentStageProcs)
                {
                    allRequiredStages++;

                    if (studentStageProc.CurrentValue.Completed)
                        completedStages++;
                }

                if (allRequiredStages == 0)
                    return 0;
                else if (completedStages == allRequiredStages)
                    return 100;
                else
                {
                    if (completedStages == 0)
                        return 0;

                    int progress = (int)(((float)completedStages / (float)allRequiredStages) * 100);
                    return progress;
                }
            }
        }
コード例 #2
0
        public void AddUserToGroup(HomeServerContext context, int studentId, int groupId, DateTime date)
        {
            Student student = context.Students.Find(studentId);
            Group group = context.Groups.Find(groupId);

            if (student == null)
                return;

            if (group == null)
                return;

            if(group.Students.Contains(student))
                return;

            student.GroupId = group.Id;

            //get active packs for this group
            var temp = context.Packs.Where(p => p.Course.CourseStateId == 2).ToList();

            List<Pack> packs = new List<Pack>();

            foreach(var t in temp)
            {
                foreach(var g in t.Groups)
                {
                    if (g.Id == groupId)
                    {
                        packs.Add(t);
                    }
                }
            }

            //add visits and studentProcs for each packs
            foreach(var pack in packs)
            {
                foreach(var lesson in pack.Lessons)
                {
                    if(lesson.Date < date)
                        continue;

                    lesson.Visits.Add(new Visit()
                    {
                        StudentId = student.Id,
                        Values = new List<VisitValue>()
                        {
                            new VisitValue()
                            {
                                Value = VisitValue.DEFAULT_VALUE,
                                Version = 1
                            }
                        }
                    });
                }

                foreach(var workProc in pack.WorkProcs)
                {
                    var work = context.Works.Find(workProc.WorkId);
                    work.WorkStages = context.WorkStages.Where(ws => ws.WorkId == workProc.WorkId).ToList();

                    StudentWorkProc studentProc = new StudentWorkProc()
                    {
                        StudentId = student.Id,
                        Values = new List<StudentWorkProcValue>() { new StudentWorkProcValue() { Version = 1 } },
                        StudentStageProcs = new List<StudentStageProc>()
                    };

                    foreach (var workStage in work.WorkStages)
                    {
                        studentProc.StudentStageProcs.Add(new StudentStageProc()
                        {
                            WorkStageId = workStage.Id,
                            Values = new List<StudentStageProcValue>() { new StudentStageProcValue() { Version = 1 } }
                        });
                    }

                    workProc.StudentWorkProcs.Add(studentProc);
                }
            }

            StudentTransaction studentTransaction = new StudentTransaction()
            {
                Student = student,
                Group = group,
                Date = date
            };

            context.StudentTransaction.Add(studentTransaction);

            context.SaveChanges();
        }
コード例 #3
0
        protected string GetStudentWorkProcTitle(StudentWorkProc studentWorkProc)
        {
            Work work = studentWorkProc.WorkProc.Work;

            if (studentWorkProc.CurrentValue.Completion != 0)
            {
                if (work.WorkControlTypeId == 1)
                {
                    return "+";
                }
                else
                {
                    return studentWorkProc.CurrentValue.Completion.ToString();
                }
            }
            else
            {
                int completedStages = 0;
                int allRequiredStages = 0;

                foreach (var studentStageProc in studentWorkProc.StudentStageProcs)
                {
                    allRequiredStages++;

                    if (studentStageProc.CurrentValue.Completed)
                        completedStages++;
                }

                if (allRequiredStages == 0)
                    return "";
                else if (completedStages == allRequiredStages)
                    return "100%";
                else
                {
                    if (completedStages == 0)
                        return "";

                    int progress = (int)(((float)completedStages / (float)allRequiredStages) * 100);
                    return progress.ToString() + "%";
                }
            }
        }