Ejemplo n.º 1
0
        private void LoadClass()
        {
            var classId = ClassId;

            using (var helper = new DbHelper.Classes())
            {
                List <StudentReportViewModel> reports;
                List <IdAndName> activityHeading;
                var cls = helper.GetSubjectClassReport(classId, out reports, out activityHeading);
                if (cls != null)
                {
                    LoadSitemap(cls);

                    LoadOptions(classId, activityHeading);


                    lblClassName.Text = cls.IsRegular ? cls.GetName : cls.Name;
                    var from = Request.QueryString["from"] ?? "";

                    lnkCourseName.Text = cls.IsRegular
                        ? cls.SubjectStructure.Subject.FullName
                        : cls.Subject.FullName;
                    lnkCourseName.NavigateUrl = "~/Views/Course/Section/?SubId=" + cls.GetCourseId + "&from=" + from;


                    if (reports != null && reports.Any())
                    {
                        #region Heading

                        var initRow = new TableRow();
                        if (chkImage.Checked)
                        {
                            initRow.Cells.Add(new TableCell()
                            {
                                Text = "Image", CssClass = "data-list-header"
                            });
                        }
                        if (chkRoll.Checked)
                        {
                            initRow.Cells.Add(new TableCell()
                            {
                                Text = "Roll", CssClass = "data-list-header"
                            });
                        }
                        if (chkName.Checked)
                        {
                            initRow.Cells.Add(new TableCell()
                            {
                                Text = "Name", CssClass = "data-list-header", Width = 100
                            });
                        }

                        //chkActivities.DataSource = activityHeading;
                        //chkActivities.DataBind();


                        foreach (var head in activityHeading)
                        {
                            var actResSelected = chkActivities.Items.FindByValue(head.Id.ToString());
                            if (actResSelected != null && actResSelected.Selected)
                            {
                                initRow.Cells.Add(new TableCell()
                                {
                                    Text     = head.Name + " (Wt.: " + head.Value + ")",
                                    CssClass = "data-list-header"
                                });
                            }


                            //pnlActivityCheck.Controls.Add(new CheckBox()
                            //{
                            //    Text = head.Name
                            //    ,
                            //    Checked = true
                            //    ,
                            //    ID = "chk_" + head.Id + "_" + head.Name
                            //    ,
                            //    CssClass = "span-padding"
                            //});
                        }
                        if (chkTotal.Checked)
                        {
                            initRow.Cells.Add(new TableCell()
                            {
                                Text = "Total", CssClass = "data-list-header"
                            });
                        }
                        tblStudents.Rows.Add(initRow);

                        #endregion


                        #region Each data populate



                        foreach (var r in reports)
                        {
                            var newRow = new TableRow();
                            if (chkImage.Checked)
                            {
                                var img = new Image()
                                {
                                    ImageUrl = r.ImageUrl
                                    ,
                                    Height = 20
                                    ,
                                    Width = 20
                                };
                                var cell = new TableCell();

                                cell.Controls.Add(img);
                                newRow.Cells.Add(cell);//new TableCell() { Text = "Image" }
                            }
                            if (chkRoll.Checked)
                            {
                                newRow.Cells.Add(new TableCell()
                                {
                                    Text = r.CRN
                                });
                            }
                            if (chkName.Checked)
                            {
                                newRow.Cells.Add(new TableCell()
                                {
                                    Text = r.StudentName
                                });
                            }
                            foreach (var activity in r.ActivityViewModels)
                            {
                                ////var chkbox = (CheckBox)pnlActivityCheck.FindControl("chk_" + head.Id + "_" + head.Name);
                                //var checkedValue = true;
                                ////if (chkbox != null)
                                //{
                                //    //checkedValue = chkbox.Checked;
                                //}
                                //if (checkedValue)
                                var actResSelected = chkActivities.Items.FindByValue(activity.Id.ToString());
                                if (actResSelected != null && actResSelected.Selected)
                                {
                                    if (string.IsNullOrEmpty(activity.ObtainedMarks))
                                    {
                                        //give link to assign grade
                                    }
                                    else
                                    {
                                        newRow.Cells.Add(new TableCell()
                                        {
                                            Text = activity.ObtainedMarks
                                        });
                                    }
                                }
                            }
                            if (chkTotal.Checked)
                            {
                                newRow.Cells.Add(new TableCell()
                                {
                                    Text = r.TotalMarks
                                });
                            }

                            tblStudents.Rows.Add(newRow);
                        }

                        #endregion
                    }



                    //ListView1.DataSource = helper.ListSubjectSessionEnrolledUsers(classId);
                    //ListView1.DataBind();
                }
            }
        }