public static List <MedAttendanceMarking> GetDatasource(int year = -1)
            {
                using (WebhostEntities db = new WebhostEntities())
                {
                    if (db.AcademicYears.Where(y => y.id == year).Count() <= 0)
                    {
                        year = DateRange.GetCurrentAcademicYear();
                    }

                    GradeTable gt = db.GradeTables.Where(g => g.AcademicYearID == year && g.Name.Equals("Attendance")).Single();
                    List <MedAttendanceMarking> mks = new List <MedAttendanceMarking>();
                    foreach (int entry in gt.GradeTableEntries.Select(e => e.id).ToList())
                    {
                        try
                        {
                            mks.Add(new MedAttendanceMarking(entry));
                        }
                        catch
                        {
                            // ignore!
                        }
                    }

                    return(mks);
                }
            }
Beispiel #2
0
        /// <summary>
        /// show the result
        /// </summary>
        private void gradeDispose()
        {
            ableButtonOption();
            if (examCountDown.gameObject.activeSelf)
            {
                examCountDown.gameObject.SetActive(false);
            }
            foreach (GradeDetails item in details)
            {
                if (item.ErrorMsg == null)
                {
                    item.ErrorMsg = "未选择";
                    item.Score    = 0;
                }
                item.Topic3DName = item.TopicCircuitName;
            }
            for (int k = 0; k < details.Count; k++)
            {
                details[k].Topic3DId = k;
            }
            TLGradeManager tl    = gradeManager;
            GradeTable     grade = tl.examCircuitUI(examCountDown.getCurrentTime());

            grade.Grade = 0;
            for (int k = 0; k < details.Count; k++)
            {
                grade.Grade += details[k].Score;
            }

            string json = "{\"Grade\":" + JsonConvert.SerializeObject(grade) + ",\"Details\":" + JsonConvert.SerializeObject(details) + "}";

            examGrade.GetComponent <Camera>().depth = 50;
            CoherentUISystem.Instance.UIViews.Add(examGrade);
            examGrade.GetComponent <UICommunicationsScript>().UnityToWeb("gotoScoreQuery", json);
        }
Beispiel #3
0
        /// <summary>
        /// Look up the <see cref="GradeTableEntry.id"/> given the text value of <see cref="GradeTableEntry.Name"/>.
        /// </summary>
        /// <param name="name"><see cref="GradeTableEntry.Name"/></param>
        /// <returns><see cref="GradeTableEntry.id"/></returns>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if the provided Name is invalid.</exception>
        public static int LookUpAttendanceMarking(String name)
        {
            using (WebhostEntities db = new WebhostAPI.WebhostEntities())
            {
                int        year  = DateRange.GetCurrentAcademicYear();
                GradeTable table = db.GradeTables.Where(t => t.AcademicYearID == year && t.Name.Equals("Attendance")).Single();

                if (table.GradeTableEntries.Where(g => g.Name.Equals(name)).Count() <= 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(name));
                }

                return(table.GradeTableEntries.Where(g => g.Name.Equals(name)).Single().id);
            }
        }
Beispiel #4
0
        public static Dictionary <String, int> MapMarkingToGradeTableEntry()
        {
            int year = DateRange.GetCurrentAcademicYear();
            Dictionary <String, int> data = new Dictionary <string, int>();

            using (WebhostEntities db = new WebhostEntities())
            {
                GradeTable attendance = db.GradeTables.Where(tbl => tbl.AcademicYearID == year && tbl.Name.Equals("Attendance")).Single();

                data.Add("OK", attendance.GradeTableEntries.Where(ent => ent.Name.Equals("Present")).Single().id);
                data.Add("LATE", attendance.GradeTableEntries.Where(ent => ent.Name.Equals("Late")).Single().id);
                data.Add("CUT", attendance.GradeTableEntries.Where(ent => ent.Name.Equals("Cut")).Single().id);
                data.Add("EXC", attendance.GradeTableEntries.Where(ent => ent.Name.Equals("Excused")).Single().id);
            }

            return(data);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                int year = DateRange.GetCurrentAcademicYear();
                using (WebhostEntities db = new WebhostEntities())
                {
                    GradeTable stdaf = db.GradeTables.Where(gt => gt.AcademicYearID == year && gt.Name.Equals("Standard A-F Scale")).Single();

                    AFDefault = stdaf.GradeTableEntries.Where(gte => gte.Value > 500).Single().id;

                    FinalDDL.DataSource     = stdaf.GradeTableEntries.ToList();
                    FinalDDL.DataTextField  = "Name";
                    FinalDDL.DataValueField = "id";
                    FinalDDL.DataBind();

                    FinalDDL.ClearSelection();
                    FinalDDL.SelectedValue = Convert.ToString(AFDefault);

                    ExamDDL.DataSource     = stdaf.GradeTableEntries.ToList();
                    ExamDDL.DataTextField  = "Name";
                    ExamDDL.DataValueField = "id";
                    ExamDDL.DataBind();
                    ExamDDL.ClearSelection();
                    ExamDDL.SelectedValue = Convert.ToString(AFDefault);

                    TrimesterDDL.DataSource     = stdaf.GradeTableEntries.ToList();
                    TrimesterDDL.DataTextField  = "Name";
                    TrimesterDDL.DataValueField = "id";
                    TrimesterDDL.DataBind();
                    TrimesterDDL.ClearSelection();
                    TrimesterDDL.SelectedValue = Convert.ToString(AFDefault);

                    GradeTable effort = db.GradeTables.Where(gt => gt.AcademicYearID == year && gt.Name.Equals("Effort Grades")).Single();

                    EffortDefault = effort.GradeTableEntries.FirstOrDefault().id;

                    EffortDDL.DataSource     = effort.GradeTableEntries.ToList();
                    EffortDDL.DataTextField  = "Name";
                    EffortDDL.DataValueField = "id";
                    EffortDDL.DataBind();
                    EffortDDL.ClearSelection();
                    EffortDDL.SelectedValue = Convert.ToString(EffortDefault);
                }
            }
        }
Beispiel #6
0
        private void gradeDispose()
        {
            if (examCountDown.gameObject.activeSelf)
            {
                examCountDown.gameObject.SetActive(false);
            }
            TLGradeManager tl    = new TLGradeManager();
            GradeTable     grade = tl.exam3DOver(examCountDown.getCurrentTime());

            examCountDown.onStop();
            List <GradeDetails> details = new List <GradeDetails>(TrainingManager.gradeDetails.Values);
            string json = "{\"Grade\":" + JsonConvert.SerializeObject(grade) + ",\"Details\":" + JsonConvert.SerializeObject(details) + "}";

            examGrade.GetComponent <Camera>().depth = 50;
            CoherentUISystem.Instance.UIViews.Add(examGrade);
            examGrade.GetComponent <UICommunicationsScript>().UnityToWeb("gotoScoreQuery", json);
        }
Beispiel #7
0
        private void gradeDispose()
        {
            if (examCountDown.gameObject.activeSelf)
            {
                examCountDown.gameObject.SetActive(false);
            }
            TLGradeManager      tl      = new TLGradeManager();
            GradeTable          grade   = tl.examCircuitUI(examCountDown.getCurrentTime());
            List <GradeDetails> details = new List <GradeDetails>(TrainingManager.circuitUIDetails.Values);

            foreach (GradeDetails item in details)
            {
                item.ErrorMsg    = errorMsg;
                item.Topic3DName = item.TopicCircuitName;
            }
            string json = "{\"Grade\":" + JsonConvert.SerializeObject(grade) + ",\"Details\":" + JsonConvert.SerializeObject(details) + "}";

            Debug.Log(json);
            examGrade.GetComponent <Camera>().depth = 50;
            CoherentUISystem.Instance.UIViews.Add(examGrade);
            examGrade.GetComponent <UICommunicationsScript>().UnityToWeb("gotoScoreQuery", json);
        }
        protected void LoadInfo(int sectionId, DateTime date)
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                int        year        = DateRange.GetCurrentAcademicYear();
                GradeTable attMarkings = db.GradeTables.Where(t => t.AcademicYearID == year && t.Name.Equals("Attendance")).Single();
                AttendanceTable.Rows.Clear();
                Section section = db.Sections.Where(sec => sec.id == sectionId).Single();
                ClassNameLabel.Text = String.Format("[{0}] {1}", section.Block.LongName, section.Course.Name);

                AttendancePageInfo api = new AttendancePageInfo()
                {
                    SectionId   = sectionId,
                    Date        = date,
                    Name        = ClassNameLabel.Text,
                    Attendances = new List <AttendanceData>()
                };

                List <Student> StudentRoster = section.Course.Name.Equals("Morning Meeting") ?
                                               section.Students.OrderBy(s => s.GraduationYear).ThenBy(s => s.LastName).ThenBy(s => s.FirstName).ToList() :
                                               section.Students.OrderBy(s => s.LastName).ThenBy(s => s.FirstName).ToList();

                bool allSubmitted = true;

                foreach (Student student in StudentRoster)
                {
                    AttendanceMarking mark = null;
                    AttendanceData    atd  = new AttendanceData()
                    {
                        StudentId = student.ID, Name = String.Format("{0} {1}", student.FirstName, student.LastName)
                    };

                    if (section.AttendanceMarkings.Where(m => m.StudentID == student.ID && m.AttendanceDate.Equals(date)).Count() > 0)
                    {
                        mark = section.AttendanceMarkings.Where(m => m.StudentID == student.ID && m.AttendanceDate.Equals(date)).Single();
                    }
                    else
                    {
                        allSubmitted = false;
                    }

                    TableRow  row       = new TableRow();
                    TableCell nameCell  = new TableCell();
                    Label     nameLabel = new Label()
                    {
                        Text    = student.FirstName + " " + student.LastName,
                        ToolTip = "Advisor:  " + student.Advisor.FirstName + " " + student.Advisor.LastName,
                        Width   = Unit.Percentage(50)
                    };
                    HiddenField sidf = new HiddenField()
                    {
                        Value = Convert.ToString(student.ID)
                    };

                    nameCell.Controls.Add(sidf);
                    nameCell.Controls.Add(nameLabel);

                    TableCell    markingCell = new TableCell();
                    DropDownList markddl     = new DropDownList();
                    int          presentId   = attMarkings.GradeTableEntries.Where(m => m.Name.Equals("Present")).Single().id;
                    markddl.DataSource     = attMarkings.GradeTableEntries.ToList();
                    markddl.DataTextField  = "Name";
                    markddl.DataValueField = "id";
                    markddl.DataBind();

                    if (mark != null)
                    {
                        markddl.ClearSelection();
                        markddl.SelectedValue = Convert.ToString(mark.MarkingIndex);
                        atd.Marking           = mark.Marking.Name;
                    }
                    else
                    {
                        markddl.ClearSelection();
                        markddl.SelectedValue = Convert.ToString(presentId);
                        atd.Marking           = "Present";
                    }

                    markingCell.Controls.Add(markddl);

                    TableCell noteCell = new TableCell()
                    {
                        Width = Unit.Percentage(25)
                    };
                    TextBox noteinput = new TextBox()
                    {
                        TextMode = TextBoxMode.MultiLine
                    };

                    if (mark != null)
                    {
                        noteinput.Text = mark.Notes;
                    }
                    row.BorderWidth = Unit.Pixel(2);
                    row.BorderStyle = BorderStyle.Solid;
                    noteCell.Controls.Add(noteinput);
                    row.Cells.Add(nameCell);
                    row.Cells.Add(markingCell);
                    row.Cells.Add(noteCell);
                    AttendanceTable.Rows.Add(row);
                }

                if (allSubmitted)
                {
                    SubmittedLabel.Text     = "Successfully Submitted.";
                    SubmittedLabel.CssClass = "success_highlight";
                }
                else
                {
                    SubmittedLabel.Text     = "You have not yet entered attendance data.";
                    SubmittedLabel.CssClass = "incomplete_highlight";
                }

                LogCurrentData(api);
            }
        }
        protected void LoadInfo(int sectionId, DateTime date)
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                int        year        = DateRange.GetCurrentAcademicYear();
                GradeTable attMarkings = db.GradeTables.Where(t => t.AcademicYearID == year && t.Name.Equals("Attendance")).Single();
                AttendanceTable.Rows.Clear();
                Section section = db.Sections.Where(sec => sec.id == sectionId).Single();
                ClassNameLabel.Text = String.Format("[{0}] {1}", section.Block.LongName, section.Course.Name);



                AttendancePageInfo api = new AttendancePageInfo()
                {
                    SectionId   = sectionId,
                    Date        = date,
                    Name        = ClassNameLabel.Text,
                    Attendances = new List <AttendanceData>()
                };

                List <Student> StudentRoster = section.Course.Name.Equals("Morning Meeting") ?
                                               section.Students.OrderBy(s => s.GraduationYear).ThenBy(s => s.LastName).ThenBy(s => s.FirstName).ToList() :
                                               section.Students.OrderBy(s => s.LastName).ThenBy(s => s.FirstName).ToList();

                bool allSubmitted = true;

                foreach (Student student in StudentRoster)
                {
                    AttendanceMarking mark = null;
                    AttendanceData    atd  = new AttendanceData()
                    {
                        StudentId = student.ID, Name = String.Format("{0} {1}", student.FirstName, student.LastName)
                    };

                    if (section.AttendanceMarkings.Where(m => m.StudentID == student.ID && m.AttendanceDate.Equals(date)).Count() == 1)
                    {
                        mark = section.AttendanceMarkings.Where(m => m.StudentID == student.ID && m.AttendanceDate.Equals(date)).Single();
                    }
                    else if (section.AttendanceMarkings.Where(m => m.StudentID == student.ID && m.AttendanceDate.Equals(date)).Count() > 1)
                    {
                        LogError("Multiple Attendance Markings found for {0} {1} in [{2}] {3} on {4}", student.FirstName, student.LastName, section.Block.LongName, section.Course.Name, date.ToString("DDD dd MMM, yyyy"));
                        AttendanceMarking        toKeep   = null;
                        List <AttendanceMarking> toDelete = section.AttendanceMarkings.Where(m => m.StudentID == student.ID && m.AttendanceDate.Equals(date)).ToList();
                        foreach (AttendanceMarking errMark in toDelete)
                        {
                            if (toKeep == null)
                            {
                                toKeep = errMark;
                            }

                            if (toKeep.Marking.Name.Equals("Excused"))
                            {
                                break;
                            }

                            if (errMark.SubmissionTime > toKeep.SubmissionTime)
                            {
                                toKeep = errMark;
                            }
                        }

                        toDelete.Remove(toKeep);

                        db.AttendanceMarkings.RemoveRange(toDelete);
                        db.SaveChanges();
                        foreach (Faculty teacher in section.Teachers.ToList())
                        {
                            MailControler.MailToUser("Attendance Needs Checking.",
                                                     String.Format("There was a problem with the marking for {0} {1} in [{2}] {3} on {4}.  I have attempted to correct the error, but you should double check it.  Currently, they are marked as {5}.", student.FirstName, student.LastName, section.Block.LongName, section.Course.Name, date.ToString("DDD dd MMM, yyyy"), toKeep.Marking.Name),
                                                     String.Format("{0}@dublinschool.org", teacher.UserName),
                                                     String.Format("{0} {1}", teacher.FirstName, teacher.LastName));
                        }
                    }
                    else
                    {
                        allSubmitted = false;
                    }

                    TableRow  row       = new TableRow();
                    TableCell nameCell  = new TableCell();
                    Label     nameLabel = new Label()
                    {
                        Text    = student.FirstName + " " + student.LastName,
                        ToolTip = "Advisor:  " + student.Advisor.FirstName + " " + student.Advisor.LastName,
                        Width   = Unit.Percentage(60)
                    };
                    HiddenField sidf = new HiddenField()
                    {
                        Value = Convert.ToString(student.ID)
                    };

                    nameCell.Controls.Add(sidf);
                    nameCell.Controls.Add(nameLabel);

                    TableCell       markingCell = new TableCell();
                    RadioButtonList markddl     = new RadioButtonList()
                    {
                        Width = Unit.Percentage(100), RepeatLayout = RepeatLayout.Table, RepeatDirection = RepeatDirection.Horizontal, RepeatColumns = 2, CssClass = "table_fixed"
                    };
                    int presentId = attMarkings.GradeTableEntries.Where(m => m.Name.Equals("Present")).Single().id;
                    markddl.DataSource     = attMarkings.GradeTableEntries.ToList();
                    markddl.DataTextField  = "Name";
                    markddl.DataValueField = "id";
                    markddl.DataBind();

                    if (mark != null)
                    {
                        markddl.ClearSelection();
                        markddl.SelectedValue = Convert.ToString(mark.MarkingIndex);
                        atd.Marking           = mark.Marking.Name;
                    }
                    else
                    {
                        markddl.ClearSelection();
                        markddl.SelectedValue = Convert.ToString(presentId);
                        atd.Marking           = "Present";
                    }

                    markingCell.Controls.Add(markddl);
                    ((List <AttendanceData>)api.Attendances).Add(atd);
                    row.BorderWidth = Unit.Pixel(2);
                    row.BorderStyle = BorderStyle.Solid;

                    row.Cells.Add(nameCell);
                    row.Cells.Add(markingCell);
                    AttendanceTable.Rows.Add(row);
                }

                if (section.AttendanceSubmissionStatuses.Where(s => s.Day.Equals(date) && s.AttendanceStatus.Blocking).Count() > 0)
                {
                    AttendanceSubmissionStatus status = section.AttendanceSubmissionStatuses.Where(s => s.Day.Equals(date)).Single();
                    if (status.TimeStamp.AddSeconds(5 * section.Students.Count) < DateTime.Now)
                    {
                        LogError("There was a problem entering attendance for [{0}] {1} at {2}. I will let the user know that there was a problem.",
                                 section.Block.LongName, section.Course.Name, status.TimeStamp.ToString("dddd, dd MM - h:mm:ss"));

                        if (allSubmitted) // calculated manually above!
                        {
                            LogInformation("Attendance was submitted earlier--but may not have been updated correctly.");
                            MailControler.MailToUser("Attendance Problem",
                                                     String.Format("Hello,{0}" +
                                                                   "Your attendance entry for [{1}] {2} had a problem when you tried to submit it at {3}.  There are saved attendance entries, but they may not be correct.  Please double check the entries and resubmit if necessary.{0}{0}Thanks!",
                                                                   Environment.NewLine, section.Block.LongName, section.Course.Name, status.TimeStamp.ToString("dddd, dd MM - h:mm:ss")), user, "*****@*****.**", "Attendance Bot");
                            SubmittedLabel.Text     = "You have not yet entered attendance data.";
                            SubmittedLabel.CssClass = "incomplete_highlight";
                            status.TimeStamp        = DateTime.Now;
                            status.StatusId         = db.AttendanceStatuses.Where(st => st.Name.Equals("Not Submitted")).Single().id;
                        }
                        else
                        {
                            LogInformation("Attendance was not submitted prior to this attempt.");
                            MailControler.MailToUser("Attendance Problem",
                                                     String.Format("Hello,{0}" +
                                                                   "Your attendance entry for [{1}] {2} had a problem when you tried to submit it at {3}.  There are incomplete attendance records right now.  Please double check the entries and resubmit your attendance for this class.{0}{0}Thanks!",
                                                                   Environment.NewLine, section.Block.LongName, section.Course.Name, status.TimeStamp.ToString("dddd, dd MM - h:mm:ss")), user, "*****@*****.**", "Attendance Bot");
                            SubmittedLabel.Text     = "Successfully Submitted.";
                            SubmittedLabel.CssClass = "success_highlight";
                            status.TimeStamp        = DateTime.Now;
                            status.StatusId         = db.AttendanceStatuses.Where(st => st.Name.Equals("Submitted")).Single().id;
                        }
                        db.SaveChanges();
                    }
                    else
                    {
                        LogWarning("The attendance for [{0}] {1} is still processing (less than the alotted {2} seconds have passed).", section.Block.LongName, section.Course.Name, (5 * section.Students.Count));
                        MailControler.MailToUser(String.Format("Attendance Submission Status for [{0}] {1}", section.Block.LongName, section.Course.Name),
                                                 String.Format("Hello,{0}Your attendance for [{1}] {2} is still processing.  Because of the number of students in your class, this may take as long as {3}:{4} minutes.  Wait at least that long and check again to see if it has submitted properly.",
                                                               Environment.NewLine, section.Block.LongName, section.Course.Name, (5 * section.Students.Count) / 60, (5 * section.Students.Count) % 60), user, "*****@*****.**", "Attendance Bot");
                        SubmittedLabel.Text     = "Attendance for this section is Currently Processing.";
                        SubmittedLabel.CssClass = "working_highlight";
                    }
                }
                else if (allSubmitted)
                {
                    SubmittedLabel.Text     = "Successfully Submitted.";
                    SubmittedLabel.CssClass = "success_highlight";
                }
                else
                {
                    SubmittedLabel.Text     = "You have not yet entered attendance data.";
                    SubmittedLabel.CssClass = "incomplete_highlight";
                }

                LogCurrentData(api);
            }
        }
        protected void LoadInfo(int sectionId, DateTime date)
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                int        year        = DateRange.GetCurrentAcademicYear();
                GradeTable attMarkings = db.GradeTables.Where(t => t.AcademicYearID == year && t.Name.Equals("Attendance")).Single();
                AttendanceTable.Rows.Clear();
                Section section = db.Sections.Where(sec => sec.id == sectionId).Single();
                BlockNameLabel.Text = String.Format("{0} Attendance", section.Block.Name);
                foreach (Student student in section.Students.OrderBy(s => s.LastName).ThenBy(s => s.FirstName).ToList())
                {
                    AttendanceMarking mark = null;

                    if (section.AttendanceMarkings.Where(m => m.StudentID == student.ID && m.AttendanceDate.Equals(date)).Count() > 0)
                    {
                        mark = section.AttendanceMarkings.Where(m => m.StudentID == student.ID && m.AttendanceDate.Equals(date)).Single();
                    }

                    TableRow  row       = new TableRow();
                    TableCell nameCell  = new TableCell();
                    Label     nameLabel = new Label()
                    {
                        Text    = student.FirstName + " " + student.LastName,
                        ToolTip = "Advisor:  " + student.Advisor.FirstName + " " + student.Advisor.LastName
                    };
                    HiddenField sidf = new HiddenField()
                    {
                        Value = Convert.ToString(student.ID)
                    };

                    nameCell.Controls.Add(sidf);
                    nameCell.Controls.Add(nameLabel);

                    TableCell       markingCell = new TableCell();
                    RadioButtonList markddl     = new RadioButtonList();
                    markddl.RepeatLayout    = RepeatLayout.Flow;
                    markddl.RepeatDirection = RepeatDirection.Horizontal;
                    markddl.RepeatColumns   = 4;
                    markddl.DataSource      = MedAttendanceMarking.GetDatasource();
                    markddl.DataTextField   = "Text";
                    markddl.DataValueField  = "ID";
                    markddl.DataBind();

                    markddl.ClearSelection();
                    if (mark != null)
                    {
                        markddl.SelectedValue = Convert.ToString(mark.MarkingIndex);
                    }
                    else
                    {
                        markddl.SelectedIndex = 2;
                    }

                    markingCell.Controls.Add(markddl);

                    row.Cells.Add(nameCell);
                    row.Cells.Add(markingCell);
                    AttendanceTable.Rows.Add(row);
                }
            }
        }
Beispiel #11
0
        protected void SelectCR_Click(object sender, EventArgs e)
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                LoadedId = -1;
                int crid = Convert.ToInt32(CourseRequestDDL.SelectedValue);
                WebhostMySQLConnection.CourseRequest courseRequest = db.CourseRequests.Where(cr => cr.id == crid).Single();

                RequestedCourseName.Text = courseRequest.RequestableCourse.Course.Name;


                int     sid     = Convert.ToInt32(StudentSelectDDL.SelectedValue);
                Student student = db.Students.Where(s => s.ID == sid).Single();

                int        termId         = DateRange.GetCurrentOrLastTerm();
                List <int> currentClasses = student.Sections.Where(sec => sec.Terms.Select(t => t.id).Contains(termId)).Select(sec => sec.id).ToList();
                CurrentCourseDDL.DataSource     = SectionListItem.GetDataSource(currentClasses);
                CurrentCourseDDL.DataTextField  = "Text";
                CurrentCourseDDL.DataValueField = "ID";
                CurrentCourseDDL.DataBind();


                SecondaryCourseDDL.DataSource     = SectionListItem.GetDataSource(currentClasses);
                SecondaryCourseDDL.DataTextField  = "Text";
                SecondaryCourseDDL.DataValueField = "ID";
                SecondaryCourseDDL.DataBind();

                int year = DateRange.GetCurrentAcademicYear();

                GradeTable stdaf = db.GradeTables.Where(gt => gt.AcademicYearID == year && gt.Name.Equals("Standard A-F Scale")).Single();

                CurrentCourseGradeDDL.DataSource     = stdaf.GradeTableEntries.ToList();
                CurrentCourseGradeDDL.DataTextField  = "Name";
                CurrentCourseGradeDDL.DataValueField = "id";
                CurrentCourseGradeDDL.DataBind();

                SecondaryCourseGradeDDL.DataSource     = stdaf.GradeTableEntries.ToList();
                SecondaryCourseGradeDDL.DataTextField  = "Name";
                SecondaryCourseGradeDDL.DataValueField = "id";
                SecondaryCourseGradeDDL.DataBind();

                List <int> facultyIds = db.Faculties.Select(f => f.ID).ToList();

                CurrentTeacherDDL.DataSource     = FacultyListItem.GetDataSource(facultyIds);
                CurrentTeacherDDL.DataTextField  = "Text";
                CurrentTeacherDDL.DataValueField = "ID";
                CurrentTeacherDDL.DataBind();

                DeptHeadDDL.DataSource     = FacultyListItem.GetDataSource(facultyIds);
                DeptHeadDDL.DataTextField  = "Text";
                DeptHeadDDL.DataValueField = "ID";
                DeptHeadDDL.DataBind();

                GradeTable approval = db.GradeTables.Where(gt => gt.AcademicYearID == year && gt.Name.Equals("AP Approval")).Single();

                ApprovalDDL.DataSource     = approval.GradeTableEntries.ToList();
                ApprovalDDL.DataTextField  = "Name";
                ApprovalDDL.DataValueField = "id";
                ApprovalDDL.DataBind();

                ApprovalPanel.Visible = true;

                if (courseRequest.APRequests.Count > 0)
                {
                    APRequest apcr = courseRequest.APRequests.FirstOrDefault();
                    LoadedId = apcr.id;
                    if (apcr.Sections.Count > 0)
                    {
                        List <Section> secs = apcr.Sections.ToList();
                        CurrentCourseDDL.ClearSelection();
                        CurrentCourseDDL.SelectedValue = Convert.ToString(secs[0].id);
                        if (student.StudentComments.Where(com => com.CommentHeader.SectionIndex == secs[0].id && com.CommentHeader.TermIndex == termId).Count() > 0)
                        {
                            StudentComment comment = student.StudentComments.Where(com => com.CommentHeader.SectionIndex == secs[0].id && com.CommentHeader.TermIndex == termId).Single();
                            CurrentCourseGradeDDL.ClearSelection();
                            CurrentCourseGradeDDL.SelectedValue = Convert.ToString(comment.FinalGradeID);
                        }
                        if (secs.Count > 1)
                        {
                            SecondaryCourseDDL.ClearSelection();
                            SecondaryCourseDDL.SelectedValue = Convert.ToString(secs[1].id);
                            if (student.StudentComments.Where(com => com.CommentHeader.SectionIndex == secs[1].id && com.CommentHeader.TermIndex == termId).Count() > 0)
                            {
                                StudentComment comment = student.StudentComments.Where(com => com.CommentHeader.SectionIndex == secs[1].id && com.CommentHeader.TermIndex == termId).Single();
                                SecondaryCourseGradeDDL.ClearSelection();
                                SecondaryCourseGradeDDL.SelectedValue = Convert.ToString(comment.FinalGradeID);
                            }
                        }
                    }

                    CurrentTeacherDDL.ClearSelection();
                    CurrentTeacherDDL.SelectedValue = Convert.ToString(apcr.TeacherSignedBy);

                    DeptHeadDDL.ClearSelection();
                    DeptHeadDDL.SelectedValue = Convert.ToString(apcr.DeptHeadSignedBy);

                    ApprovalDDL.ClearSelection();
                    ApprovalDDL.SelectedValue = Convert.ToString(apcr.ApprovalId);
                }
            }
        }