public ClassHours(LtpCourse course, DateTimeOffset startHours, DateTimeOffset endHours, DayOfWeek day)
     : base(course)
 {
     _startHours = startHours;
     _endHours   = endHours;
     _day        = day;
 }
        public Attendance(LtpCourse course, ushort totalClasses, ushort attendedClasses, double percentage)
            : base(course)
        {
            TotalClasses    = totalClasses;
            AttendedClasses = attendedClasses;
            Percentage      = percentage;

            _details = new SortedDictionary <DateTimeOffset, AttendanceStub>();
            Details  = new ReadOnlyDictionary <DateTimeOffset, AttendanceStub>(_details);
        }
Ejemplo n.º 3
0
 public PBLMarkInfo(LtpCourse parent, string marksTitle, int maxMarks, int weightage, DateTimeOffset?conductedDate, double?marks, string status)
     : base(parent)
 {
     _marksTitle    = marksTitle;
     _maxMarks      = maxMarks;
     _weightage     = weightage;
     _conductedDate = conductedDate;
     _marks         = marks;
     _status        = status;
 }
Ejemplo n.º 4
0
        public Attendance(LtpCourse course, ushort totalClasses, ushort attendedClasses, double percentage, int singleClassLength)
            : base(course)
        {
            TotalClasses      = totalClasses;
            AttendedClasses   = attendedClasses;
            Percentage        = percentage;
            SingleClassLength = singleClassLength;

            _details = new AttendanceDetails();
            Details  = new ReadOnlyCollection <AttendanceGroup>(_details);
        }
Ejemplo n.º 5
0
        public MarkInfo(LtpCourse parent, string marksTitle, int maxMarks, int weightage, DateTimeOffset?conductedDate, double?marks, string status)
            : base(parent)
        {
            _title         = marksTitle;
            _maxMarks      = maxMarks;
            _weightage     = weightage;
            _conductedDate = conductedDate;
            _marks         = marks;
            _status        = status;

            if (_marks != null)
            {
                _weightedMarks = Math.Round((double)_marks * _weightage / _maxMarks, 2);
            }
        }
        /// <summary>
        /// Constructs the week's timetable for the specified courses and returns the timetable object on success.
        /// </summary>
        /// <param name="courses">
        /// The list of courses for which to generate the timetable.
        /// </param>
        /// <returns></returns>
        public static Timetable GetTimetable(IEnumerable <Course> courses)
        {
            try
            {
                Timetable timetable = new Timetable();

                foreach (Course c in courses)
                {
                    LtpCourse course = c as LtpCourse;
                    if (course != null)
                    {
                        BitArray punchCard = new BitArray(7);
                        // Adding the schedule of regular classes of the current courses.
                        foreach (ClassHours classHours in course.Timings)
                        {
                            int i = (int)classHours.Day;
                            timetable._weekRegularClasses[i].Add(classHours);
                            punchCard[i] = true;
                        }
                        // Adding the course to those days which do not have a regular class of the current course.
                        for (int i = 0; i < 7; i++)
                        {
                            if (punchCard[i] == false)
                            {
                                timetable._weekNeglectedCourses[i].Add(course);
                            }
                        }
                    }
                }
                foreach (var daySchedule in timetable._weekRegularClasses)
                {
                    daySchedule.Sort(ClassHoursComparision);
                }

                return(timetable);
            }
            catch
            {
                return(null);
            }
        }
 public LtpCourseComponent(LtpCourse parent)
 {
     _parent = parent;
 }
 public LtpCourseComponent(LtpCourse parent)
 {
     _parent = parent;
 }
 private static void AssignTimings(LtpCourse course, JsonArray timingsArray)
 {
     foreach (JsonValue classHoursValue in timingsArray)
     {
         JsonObject classHoursObject = classHoursValue.GetObject();
         DateTimeOffset start = GetIST(classHoursObject.GetNamedString("start_time"));
         DateTimeOffset end = GetIST(classHoursObject.GetNamedString("end_time"));
         DayOfWeek day = (DayOfWeek)((int)classHoursObject.GetNamedNumber("day") + 1);
         course.AddClassHoursInstance(new ClassHours(course, start, end, day));
     }
 }
        private static void AssignMarks(LtpCourse course, JsonObject marksObject)
        {
            if (marksObject.GetNamedBoolean("supported") == false)
            {
                course.InternalMarksScored = 0;
                course.TotalMarksTested = 0;
                return;
            }

            double marksScored = 0;
            JsonArray marksArray = marksObject.GetNamedArray("assessments");
            foreach (JsonValue marksValue in marksArray)
            {
                JsonObject markStubObject = marksValue.GetObject();
                string title = markStubObject.GetNamedString("title").ToUpper();
                int maxMarks = (int)markStubObject.GetNamedNumber("max_marks");
                int weightage = (int)markStubObject.GetNamedNumber("weightage");

                MarkInfo markInfo;
                if (markStubObject.GetNamedValue("scored_marks").ValueType == JsonValueType.Null)
                    markInfo = new MarkInfo(course, title, maxMarks, weightage, null, null, "");
                else
                {
                    markInfo = new MarkInfo(course, title, maxMarks, weightage,
                                    null, // currently, 'conducted date' is being skipped.
                                    markStubObject.GetNamedNumber("scored_marks"),
                                    markStubObject.GetNamedString("status").ToUpper());

                    marksScored += (double)markInfo.WeightedMarks;
                    course.TotalMarksTested += markInfo.Weightage;
                }
                course.AddMarkInfo(markInfo);
            }

            course.InternalMarksScored = Math.Round(marksScored, 2);
        }
        // Depth 1 Assignment (Ltp and NonLtp)
        private static void AssignBaseTypeDetails(LtpCourse ltpCourse, JsonObject courseObject)
        {
            ltpCourse.Slot = courseObject.GetNamedString("slot");
            ltpCourse.Venue = courseObject.GetNamedString("venue");

            AssignTimings(ltpCourse, courseObject.GetNamedArray("timings"));
            AssignAttendance(ltpCourse, courseObject.GetNamedObject("attendance"));

            JsonObject marksObject = courseObject.GetNamedObject("marks");
            AssignMarks(ltpCourse, marksObject);
        }
        private static void AssignAttendance(LtpCourse course, JsonObject attendanceObject)
        {
            int classLength = 1;
            if (course as LBCCourse != null)
            {
                classLength = (int)Char.GetNumericValue(course.Ltpjc[2]);
            }

            if (attendanceObject.GetNamedBoolean("supported") == false)
            {
                course.Attendance = new Attendance(course, 0, 0, 0, classLength);
                return;
            }

            ushort total = (ushort)attendanceObject.GetNamedNumber("total_classes");
            ushort attended = (ushort)attendanceObject.GetNamedNumber("attended_classes");
            double percentage = attendanceObject.GetNamedNumber("attendance_percentage");
            course.Attendance = new Attendance(course, total, attended, percentage, classLength);

            JsonArray detailsArray = attendanceObject.GetNamedArray("details");
            foreach (JsonValue stubValue in detailsArray)
            {
                JsonObject stubObject = stubValue.GetObject();
                DateTimeOffset classDate = new DateTimeOffset(DateTime.ParseExact(stubObject.GetNamedString("date"), "yyyy-MM-dd", CultureInfo.InvariantCulture), new TimeSpan(5, 30, 0));

                course.Attendance.AddStubToDetails(classDate, new AttendanceStub(
                                                                    stubObject.GetNamedString("slot"),
                                                                    stubObject.GetNamedString("status"),
                                                                    stubObject.GetNamedString("reason")));
            }
        }
 public MarksInfo(LtpCourse parent, double?marks, string status)
     : base(parent)
 {
     _marks  = marks;
     _status = status;
 }