Example #1
0
        public void fillStatistic()
        {
            double totalstudntresoult = 0;
            double totalstagerank     = 0;

            user       = ServerModel.DB.Load <TblUsers>(UserId);
            curriculum = ServerModel.DB.Load <TblCurriculums>(CurriculumID);
            foreach (TblStages stage in TeacherHelper.StagesOfCurriculum(curriculum))
            {
                foreach (TblThemes theme in TeacherHelper.ThemesOfStage(stage))
                {
                    double           result       = 0; Name_Stage.Add(theme.Name);
                    double           totalresult  = 0;
                    int              learnercount = TeacherHelper.GetLastIndexOfAttempts(user.ID, theme.ID);
                    TblOrganizations organization;
                    organization = ServerModel.DB.Load <TblOrganizations>(theme.OrganizationRef);
                    foreach (TblItems items in TeacherHelper.ItemsOfOrganization(organization))
                    {
                        totalresult += Convert.ToDouble(items.Rank);
                    }

                    foreach (TblLearnerAttempts attempt in TeacherHelper.AttemptsOfTheme(theme))
                    {
                        if (attempt.ID == TeacherHelper.GetLastLearnerAttempt(user.ID, theme.ID))
                        {
                            foreach (TblLearnerSessions session in TeacherHelper.SessionsOfAttempt(attempt))
                            {
                                CmiDataModel cmiDataModel = new CmiDataModel(session.ID, user.ID, false);
                                List <TblVarsInteractions> interactionsCollection = cmiDataModel.GetCollection <TblVarsInteractions>("interactions.*.*");

                                for (int i = 0, j = 0; i < int.Parse(cmiDataModel.GetValue("interactions._count")); i++)
                                {
                                    for (; j < interactionsCollection.Count && i == interactionsCollection[j].Number; j++)
                                    {
                                        if (interactionsCollection[j].Name == "result")
                                        {
                                            TblItems itm = ServerModel.DB.Load <TblItems>(session.ItemRef);
                                            if (interactionsCollection[j].Value == "correct")
                                            {
                                                result += Convert.ToDouble(itm.Rank);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    totalstudntresoult += result;
                    totalstagerank     += totalresult;
                    Student_Stage_Count.Add(result);
                    Total_Stage_Count.Add(totalresult);
                }
            }

            Name_Stage.Add("Total");
            Student_Stage_Count.Add(totalstudntresoult);
            Total_Stage_Count.Add(totalstagerank);


            Saveto_Excel_Click();
        }
Example #2
0
        private void fillStatisticTable()
        {
            IList <TblUsers> ilistusers;

            ilistusers = TeacherHelper.GetStudentsOfGroup(group);
            if (UserId > 0)
            {
                user = ServerModel.DB.Load <TblUsers>(UserId);
                ilistusers.Clear();
                ilistusers.Add(user);
            }
            StatisticTable.Rows.Clear();

            TableHeaderRow headerRow = new TableHeaderRow();

            TableHeaderCell headerCell = new TableHeaderCell();

            headerCell.Text = studentStr;
            headerRow.Cells.Add(headerCell);

            foreach (TblStages stage in TeacherHelper.StagesOfCurriculum(curriculum))
            {
                foreach (TblThemes theme in TeacherHelper.ThemesOfStage(stage))
                {
                    headerCell      = new TableHeaderCell();
                    headerCell.Text = theme.Name;
                    headerRow.Cells.Add(headerCell);
                }
            }
            headerCell      = new TableHeaderCell();
            headerCell.Text = totalStr;
            headerRow.Cells.Add(headerCell);

            headerCell      = new TableHeaderCell();
            headerCell.Text = Translations.StatisticShowController_fillStatisticTable_Percent;
            headerRow.Cells.Add(headerCell);

            headerCell      = new TableHeaderCell();
            headerCell.Text = "ECTS";
            headerRow.Cells.Add(headerCell);

            StatisticTable.Rows.Add(headerRow);
            foreach (TblUsers student in ilistusers)
            {
                var       studentRow  = new TableRow();
                TableCell studentCell = new TableHeaderCell {
                    HorizontalAlign = HorizontalAlign.Center
                };
                studentCell.Controls.Add(new HyperLink
                {
                    Text        = student.DisplayName,
                    NavigateUrl = ServerModel.Forms.BuildRedirectUrl(new StatisticShowGraphController
                    {
                        GroupID      = GroupID,
                        CurriculumID = curriculum.ID,
                        UserId       = student.ID,
                        BackUrl      = RawUrl
                    })
                });


                studentRow.Cells.Add(studentCell);

                double pasedCurriculum = 0;
                double totalCurriculum = 0;
                foreach (TblStages stage in TeacherHelper.StagesOfCurriculum(curriculum))
                {
                    foreach (TblThemes theme in TeacherHelper.ThemesOfStage(stage))
                    {
                        double           result       = 0;
                        double           totalresult  = 0;
                        int              learnercount = TeacherHelper.GetLastIndexOfAttempts(student.ID, theme.ID);
                        TblOrganizations organization;
                        organization = ServerModel.DB.Load <TblOrganizations>(theme.OrganizationRef);
                        foreach (TblItems items in TeacherHelper.ItemsOfOrganization(organization))
                        {
                            totalresult += Convert.ToDouble(items.Rank);
                        }

                        foreach (TblLearnerAttempts attempt in TeacherHelper.AttemptsOfTheme(theme))
                        {
                            if (attempt.ID == TeacherHelper.GetLastLearnerAttempt(student.ID, theme.ID))
                            {
                                foreach (TblLearnerSessions session in TeacherHelper.SessionsOfAttempt(attempt))
                                {
                                    CmiDataModel cmiDataModel = new CmiDataModel(session.ID, student.ID, false);
                                    List <TblVarsInteractions> interactionsCollection = cmiDataModel.GetCollection <TblVarsInteractions>("interactions.*.*");

                                    for (int i = 0, j = 0; i < int.Parse(cmiDataModel.GetValue("interactions._count")); i++)
                                    {
                                        for (; j < interactionsCollection.Count && i == interactionsCollection[j].Number; j++)
                                        {
                                            if (interactionsCollection[j].Name == "result")
                                            {
                                                TblItems itm = ServerModel.DB.Load <TblItems>(session.ItemRef);
                                                if (interactionsCollection[j].Value == "correct")
                                                {
                                                    result += Convert.ToDouble(itm.Rank);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }



                        string attmpt = "";
                        if (learnercount > 0)
                        {
                            attmpt = "(" + learnercount.ToString() + " attempt )";
                        }
                        else if (learnercount == 0)
                        {
                            attmpt = "";
                        }

                        studentCell = new TableCell {
                            HorizontalAlign = HorizontalAlign.Center
                        };
                        studentCell.Controls.Add(new HyperLink
                        {
                            Text        = result + "/" + totalresult + attmpt,
                            NavigateUrl = ServerModel.Forms.BuildRedirectUrl(new ThemeResultController
                            {
                                BackUrl          = string.Empty,
                                LearnerAttemptId = TeacherHelper.GetLastLearnerAttempt(student.ID, theme.ID),
                            })
                        });

                        if (learnercount == 0)
                        {
                            studentCell.Enabled   = false;
                            studentCell.BackColor = Color.Yellow;
                        }
                        else if (learnercount > 0)
                        {
                            studentCell.BackColor = Color.YellowGreen;
                        }

                        pasedCurriculum += result;
                        totalCurriculum += totalresult;
                        studentRow.Cells.Add(studentCell);
                    }
                }

                studentCell = new TableCell
                {
                    HorizontalAlign = HorizontalAlign.Center,
                    Text            = pasedCurriculum + "/" + totalCurriculum
                };
                studentRow.Cells.Add(studentCell);
                studentCell = new TableCell {
                    HorizontalAlign = HorizontalAlign.Center
                };
                double temp_total;
                if (totalCurriculum != 0)
                {
                    temp_total = pasedCurriculum / totalCurriculum * 100;
                }
                else
                {
                    temp_total = 0;
                }
                studentCell.Text = (temp_total).ToString("F2");
                studentRow.Cells.Add(studentCell);
                studentCell = new TableCell {
                    HorizontalAlign = HorizontalAlign.Center
                };
                studentCell.Text = TeacherHelper.ECTS_code(temp_total);

                studentRow.Cells.Add(studentCell);
                StatisticTable.Rows.Add(studentRow);
            }

            if (StatisticTable.Rows.Count == 1)
            {
                StatisticTable.Visible = false;
                Message.Value          = noStudents;
            }
        }