Beispiel #1
0
 protected internal LessonDomain(
     string name,
     string lessonCode,
     int akts,
     LessonType lessonType,
     int weeklyHour,
     SemesterType semesterType,
     int credit
     )
 {
     Name         = name;
     LessonCode   = lessonCode;
     AKTS         = akts;
     LessonType   = lessonType;
     WeeklyHour   = weeklyHour;
     SemesterType = semesterType;
     Credit       = credit;
 }
Beispiel #2
0
 public static char GetNumber(this SemesterType type)
 {
     return((Enum.GetName(typeof(SemesterType), type) ?? "1").Last());
 }
Beispiel #3
0
 public Semester(int year, SemesterType semesterType)
 {
     Year         = year;
     SemesterType = semesterType;
 }
Beispiel #4
0
        public async Task <ServiceResponse <GetCourseDto> > EditCourse(EditCourseDto editCourseDto)
        {
            ServiceResponse <GetCourseDto> serviceResponse = new ServiceResponse <GetCourseDto>();

            User dbUser = await _context.Users
                          .Include(c => c.InstructedCourses)
                          .FirstOrDefaultAsync(c => c.Id == GetUserId());

            if (dbUser == null)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "Current user not found.";
                return(serviceResponse);
            }
            if (editCourseDto.MaxGroupSize < 1 || editCourseDto.MinGroupSize > editCourseDto.MaxGroupSize)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "Minumum maxgroupsize should be 1 and minGroupsize should be less than or equal to maxgroupsize";
                return(serviceResponse);
            }

            Course dbCourse = await _context.Courses
                              .Include(c => c.Instructors).ThenInclude(cs => cs.User)
                              .Include(c => c.Sections)
                              .FirstOrDefaultAsync(c => c.Id == editCourseDto.Id);

            if (dbCourse == null)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "Course not found.";
                return(serviceResponse);
            }
            if (!dbCourse.Instructors.Any(c => c.UserId == dbUser.Id))
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "User does not have authority on this course.";
                return(serviceResponse);
            }

            SemesterType semesterType = SemesterType.Spring;

            if (editCourseDto.CourseSemester.Equals("Spring"))
            {
                semesterType = SemesterType.Spring;
            }
            else if (editCourseDto.CourseSemester.Equals("Summer"))
            {
                semesterType = SemesterType.Summer;
            }
            else if (editCourseDto.CourseSemester.Equals("Fall"))
            {
                semesterType = SemesterType.Fall;
            }
            else
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "Semester type is given wrong.";
                return(serviceResponse);
            }

            dbCourse.Name              = editCourseDto.Name;
            dbCourse.CourseSemester    = semesterType;
            dbCourse.Year              = editCourseDto.Year;
            dbCourse.CourseInformation = editCourseDto.CourseInformation;
            dbCourse.LockDate          = editCourseDto.LockDate;
            dbCourse.MinGroupSize      = editCourseDto.MinGroupSize;
            dbCourse.MaxGroupSize      = editCourseDto.MaxGroupSize;
            dbCourse.IsActive          = editCourseDto.IsActive;
            dbCourse.IsLocked          = editCourseDto.IsLocked;
            dbCourse.CourseDescription = editCourseDto.CourseDescription;

            _context.Courses.Update(dbCourse);
            await _context.SaveChangesAsync();

            serviceResponse.Data = await AddExtraDtos(_mapper.Map <GetCourseDto>(dbCourse));

            return(serviceResponse);
        }
Beispiel #5
0
        public async Task <ServiceResponse <GetCourseDto> > CreateCourse(CreateCourseDto createCourseDto)
        {
            ServiceResponse <GetCourseDto> serviceResponse = new ServiceResponse <GetCourseDto>();

            User dbUser = await _context.Users
                          .Include(c => c.InstructedCourses)
                          .FirstOrDefaultAsync(c => c.Id == GetUserId());



            if (dbUser == null || dbUser.UserType == UserTypeClass.Student)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "User is not in instructor list. If you think this is incorrect, please contact the devs.";
                return(serviceResponse);
            }
            if (createCourseDto.MaxGroupSize < 1 || createCourseDto.MinGroupSize > createCourseDto.MaxGroupSize)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "Minumum maxgroupsize should be 1 and minGroupsize should be less than or equal to maxgroupsize";
                return(serviceResponse);
            }

            SemesterType semesterType = SemesterType.Spring;

            if (createCourseDto.CourseSemester.Equals("Spring"))
            {
                semesterType = SemesterType.Spring;
            }
            else if (createCourseDto.CourseSemester.Equals("Summer"))
            {
                semesterType = SemesterType.Summer;
            }
            else if (createCourseDto.CourseSemester.Equals("Fall"))
            {
                semesterType = SemesterType.Fall;
            }
            else
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "Semester type is given wrong.";
                return(serviceResponse);
            }

            Course newCourse = new Course
            {
                Name              = createCourseDto.Name,
                CourseSemester    = semesterType,
                Year              = createCourseDto.Year,
                CourseInformation = createCourseDto.CourseInformation,
                NumberOfSections  = createCourseDto.NumberOfSections,
                LockDate          = createCourseDto.LockDate,
                MinGroupSize      = createCourseDto.MinGroupSize,
                MaxGroupSize      = createCourseDto.MaxGroupSize,
                StartDate         = DateTime.Now,
                IsSectionless     = createCourseDto.IsSectionless,
                IsActive          = createCourseDto.IsActive,
                IsLocked          = createCourseDto.IsLocked,
                CourseDescription = createCourseDto.CourseDescription
            };

            CourseUser founderInstructor = new CourseUser
            {
                User     = dbUser,
                UserId   = dbUser.Id,
                Course   = newCourse,
                CourseId = newCourse.Id
            };

            newCourse.Instructors.Add(founderInstructor);

            for (int i = 1; i <= createCourseDto.NumberOfSections; i++)
            {
                Section newSection = new Section
                {
                    SectionNo          = i,
                    AffiliatedCourse   = newCourse,
                    AffiliatedCourseId = newCourse.Id
                };
                newCourse.Sections.Add(newSection);
            }

            await _context.Courses.AddAsync(newCourse);

            await _context.SaveChangesAsync();

            serviceResponse.Data = await AddExtraDtos(_mapper.Map <GetCourseDto>(newCourse));

            return(serviceResponse);
        }
Beispiel #6
0
 public Timetable(CalendarType type, SemesterType semester, IEnumerable <WeekDay> weekDays)
 {
     this.Type     = type;
     this.Semester = semester;
     this.WeekDays = new ReadOnlyCollection <WeekDay>(weekDays.ToList());
 }
Beispiel #7
0
        private static void PrintSemester(Employee employee, SemesterType semesterType, StudyYear year, Workbook objWorkBook)
        {
            int descrList  = semesterType == SemesterType.Autumm ? 2 : 3;
            int paramsList = semesterType == SemesterType.Autumm ? 4 : 5;
            List <DisciplineWorkload> workloads = semesterType == SemesterType.Autumm ?
                                                  _service.GetAllEmloyeeWorkloadsByYearAutumm(employee, year.Year) : _service.GetAllEmloyeeWorkloadsByYearSpring(employee, year.Year);

            workloads = workloads.OrderBy(w => w.Semester.Number).ToList();
            if (workloads.Count > 0)
            {
                Worksheet DescrSheet  = (Worksheet)objWorkBook.Sheets[descrList];
                Worksheet ParamsSheet = (Worksheet)objWorkBook.Sheets[paramsList];
                int       currentRow  = IndPlanExport.Default.DisciplinesStartRow;
                foreach (var w in workloads)
                {
                    DescrSheet.Cells[currentRow, IndPlanExport.Default.DisciplineNameColumn] = w.DisciplineYear.Discipline.ToString();
                    if (w.DisciplineYear.Discipline.SpecialType == SpecialDisciplineKind.RUK_KAF)
                    {
                        ParamsSheet.Cells[currentRow - 1, IndPlanExport.Default.DisciplineSettingsStartColumn + 14] = CalculationSettings.Default.RukKaf;
                        currentRow += 2;
                        continue;
                    }
                    int    cource = year.Year - w.Group.EntryYear + 1;
                    string descr  = string.Format("{0},{1},{2} курс", w.Group.Speciality.Faculty, w.Group.Speciality, cource);
                    DescrSheet.Cells[currentRow, IndPlanExport.Default.DisciplineDescrColumn] = descr;
                    DescrSheet.Cells[currentRow, IndPlanExport.Default.StudentsCountColumn]   = w.Group.CountOfStudents;
                    int   weeks     = w.Semester.CountOfWeeks;
                    int   countStud = w.Group.CountOfStudents;
                    float lecFact   = weeks * w.DisciplineYear.CountOfLecture * Properties.CalculationSettings.Default.LectureCost;
                    float pracFact  = weeks * w.DisciplineYear.CountOfPractice * Properties.CalculationSettings.Default.PracticeCost;
                    float labFact   = weeks * w.DisciplineYear.CountOfLabs * Properties.CalculationSettings.Default.LabCost;
                    float ekzFact   = w.DisciplineYear.HasEx ? Properties.CalculationSettings.Default.ExamControlCost * countStud : 0;
                    //float konsFact = Convert.ToBoolean(reader[14]) ? Properties.CalculationSettings.Default.KonsCost * Convert.ToInt32(reader[6]) * weeks  + (ekzFact!=0?2:0) : 0;\
                    float konsFact = Properties.CalculationSettings.Default.KonsCost * w.DisciplineYear.CountOfLecture * weeks + (ekzFact != 0 ? 2 : 0);
                    float zachFact = w.DisciplineYear.HasCR ? Properties.CalculationSettings.Default.ZachCost * countStud : 0;
                    float KPFact   = w.DisciplineYear.HasKP ? Properties.CalculationSettings.Default.KPCost * countStud : 0;
                    float KRFact   = w.DisciplineYear.HasKR ? Properties.CalculationSettings.Default.KRCost * countStud : 0;
                    ParamsSheet.Cells[currentRow - 1, Properties.IndPlanExport.Default.DisciplineSettingsStartColumn]     = lecFact;
                    ParamsSheet.Cells[currentRow - 1, Properties.IndPlanExport.Default.DisciplineSettingsStartColumn + 1] = pracFact;
                    ParamsSheet.Cells[currentRow - 1, Properties.IndPlanExport.Default.DisciplineSettingsStartColumn + 2] = labFact;
                    ParamsSheet.Cells[currentRow - 1, Properties.IndPlanExport.Default.DisciplineSettingsStartColumn + 3] = konsFact;
                    ParamsSheet.Cells[currentRow - 1, Properties.IndPlanExport.Default.DisciplineSettingsStartColumn + 4] = ekzFact;
                    ParamsSheet.Cells[currentRow - 1, Properties.IndPlanExport.Default.DisciplineSettingsStartColumn + 5] = zachFact;
                    ParamsSheet.Cells[currentRow - 1, Properties.IndPlanExport.Default.DisciplineSettingsStartColumn + 6] = KPFact;
                    ParamsSheet.Cells[currentRow - 1, Properties.IndPlanExport.Default.DisciplineSettingsStartColumn + 7] = KRFact;
                    double other     = 0;
                    double geks      = 0;
                    double ruk       = 0;
                    double uchPr     = w.DisciplineYear.CountOfLearnigPracticeWeeks * Properties.CalculationSettings.Default.UchPr;
                    double prPr      = w.DisciplineYear.CountOfManufacturePracticeWeeks * Properties.CalculationSettings.Default.PrPr;
                    double preddipPr = w.DisciplineYear.CountOfUndergraduatePracticeWeeks * Properties.CalculationSettings.Default.PreddipPr;
                    double NIIR      = w.DisciplineYear.CountOfNIIR * Properties.CalculationSettings.Default.NIIR * countStud;                                                     //нир
                    double GEK       = w.DisciplineYear.Discipline.SpecialType == SpecialDisciplineKind.GEK ? (Properties.CalculationSettings.Default.GEK * countStud) : 0;        //ГЭК.
                    double GAKpred   = w.DisciplineYear.Discipline.SpecialType == SpecialDisciplineKind.GAK_PRED ? (Properties.CalculationSettings.Default.GEK * countStud) : 0;
                    double GAK       = w.DisciplineYear.Discipline.SpecialType == SpecialDisciplineKind.GAK ? (Properties.CalculationSettings.Default.GAK * countStud) : 0;        //ГAК
                    double rukMag    = w.DisciplineYear.Discipline.SpecialType == SpecialDisciplineKind.MAG_RUK ? (Properties.CalculationSettings.Default.MAGRuk * countStud) : 0; //рук маг
                    geks   = GEK + GAK + GAKpred;
                    ruk   += w.DisciplineYear.Discipline.SpecialType == SpecialDisciplineKind.ASP_RUK ? (Properties.CalculationSettings.Default.AspRuk * countStud) : 0f;
                    ruk   += rukMag;
                    ruk   += w.DisciplineYear.Discipline.SpecialType == SpecialDisciplineKind.BAK_RUK ? (countStud * Properties.CalculationSettings.Default.DPruk) : 0f;
                    ruk   += w.DisciplineYear.Discipline.SpecialType == SpecialDisciplineKind.MAG_RETZ ? countStud * CalculationSettings.Default.MagRetz : 0f; //MagRetz
                    ruk   += w.DisciplineYear.Discipline.SpecialType == SpecialDisciplineKind.RUK_KAF ? countStud : 0f;                                        //руководство кафедрой
                    other += NIIR;

                    /*string disciplineName = reader[0].ToString();
                     * if (disciplineName.ToLower().Contains("норм") && disciplineName.ToLower().Contains("маг"))
                     *  other += countStud * Properties.CalculationSettings.Default.NormocontrolMag;
                     * if (disciplineName.ToLower().Contains("доп") && disciplineName.ToLower().Contains("маг"))
                     *  other += countStud * Properties.CalculationSettings.Default.DopuskDissMag;*/
                    ParamsSheet.Cells[currentRow - 1, Properties.IndPlanExport.Default.DisciplineSettingsStartColumn + 8]  = 0;
                    ParamsSheet.Cells[currentRow - 1, Properties.IndPlanExport.Default.DisciplineSettingsStartColumn + 9]  = uchPr;     //уч пр.
                    ParamsSheet.Cells[currentRow - 1, Properties.IndPlanExport.Default.DisciplineSettingsStartColumn + 10] = prPr;      //пр пр.
                    ParamsSheet.Cells[currentRow - 1, Properties.IndPlanExport.Default.DisciplineSettingsStartColumn + 11] = preddipPr; //преддип пр.
                    ParamsSheet.Cells[currentRow - 1, Properties.IndPlanExport.Default.DisciplineSettingsStartColumn + 12] = 0;
                    ParamsSheet.Cells[currentRow - 1, Properties.IndPlanExport.Default.DisciplineSettingsStartColumn + 13] = geks;
                    ParamsSheet.Cells[currentRow - 1, Properties.IndPlanExport.Default.DisciplineSettingsStartColumn + 14] = ruk;
                    ParamsSheet.Cells[currentRow - 1, Properties.IndPlanExport.Default.DisciplineSettingsStartColumn + 15] = other;
                    currentRow += 2;
                }
            }
        }
Beispiel #8
0
        public static void ExportSemester(StudyYear year, SemesterType semester)
        {
            string path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Templates\SemesterTemplate.xltx");
            Dictionary <string, int> counts = new Dictionary <string, int>()
            {
                { "ФИТ", 0 }, { "МСФ", 0 }, { "ИДПО", 0 }, { "МАГ", 0 }
            };
            List <DisciplineWorkload> workloads = _service.GetAllDisciplineWorkloadsByYearAndSemesterType(year.Year, semester);

            workloads = workloads.OrderBy(w => w.Semester.Number).ToList();
            if (workloads.Count > 0)
            {
                Microsoft.Office.Interop.Excel.Application ObjExcel = new Microsoft.Office.Interop.Excel.Application();
                Workbook  ObjWorkBook;
                Worksheet ObjWorkSheet;
                ObjWorkBook              = ObjExcel.Workbooks.Add(path);
                ObjWorkSheet             = (Worksheet)ObjWorkBook.Sheets[1];
                ObjWorkBook.Title        = string.Format("Отчет {0} семестр({1} / {2})", semester.ToDescriptionString(), year.Year, year.Year + 1);
                ObjWorkSheet.Cells[3, 1] = string.Format("экзаменационной сессии  за  {0} семестр {1} / {2} учебного года", semester.ToDescriptionString(), year.Year, year.Year + 1);
                foreach (var w in workloads)
                {
                    int rowCounter = SemesterExport.Default.FITStartRow;
                    if (w.DisciplineYear.Discipline.TypeOfDiscipline == DisciplineType.SPECIAL)
                    {
                        rowCounter++;
                        continue;
                    }
                    Group      group      = w.Group;
                    int        cource     = year.Year - group.EntryYear + 1;
                    Discipline discipline = w.DisciplineYear.Discipline;
                    int        countStud  = group.CountOfStudents;
                    int        weeks      = w.Semester.CountOfWeeks;
                    int        lec        = w.DisciplineYear.CountOfLecture;
                    int        prac       = w.DisciplineYear.CountOfPractice;
                    int        lab        = w.DisciplineYear.CountOfLabs;
                    bool       kr         = w.DisciplineYear.HasKR;
                    bool       kp         = w.DisciplineYear.HasKP;
                    bool       ekz        = w.DisciplineYear.HasEx;
                    bool       zach       = w.DisciplineYear.HasCR;

                    float summ  = WorkloadsCalculator.GetWorkloadCost(w);
                    int   index = 0;
                    if (w.Group.StudyForm != StudyForm.FullTime)
                    {
                        rowCounter = counts["ФИТ"] + counts["ИДПО"] + counts["МСФ"] + SemesterExport.Default.IDPOStartRow;
                        counts["ИДПО"]++;
                        index = counts["ИДПО"];
                    }
                    else
                    if (w.Group.Speciality.Faculty.ShortName == "ФИТ")
                    {
                        if (w.Group.Qualification != Qualification.Magistracy)
                        {
                            rowCounter += counts["ФИТ"];
                            counts["ФИТ"]++;
                            index = counts["ФИТ"];
                        }
                        else
                        {
                            rowCounter = counts["ФИТ"] + counts["ИДПО"] + counts["МАГ"] + counts["МСФ"] + SemesterExport.Default.MAGStartRow;
                            counts["МАГ"]++;
                            index = counts["МАГ"];
                        }
                    }
                    else
                    if (w.Group.Speciality.Faculty.ShortName == "МСФ")
                    {
                        rowCounter = counts["ФИТ"] + counts["МСФ"] + SemesterExport.Default.MSFStartRow;
                        counts["МСФ"]++;
                        index = counts["МСФ"];
                    }
                    {
                        Range line = (Range)ObjWorkSheet.Rows[rowCounter];
                        line.Insert();

                        ObjWorkSheet.Cells[rowCounter, SemesterExport.Default.IndexColumn]          = index;
                        ObjWorkSheet.Cells[rowCounter, SemesterExport.Default.GroupColumn]          = group.Speciality.Name;
                        ObjWorkSheet.Cells[rowCounter, SemesterExport.Default.CourceColumn]         = cource;
                        ObjWorkSheet.Cells[rowCounter, SemesterExport.Default.DisciplineColumn]     = w.DisciplineYear.Discipline.Name;
                        ObjWorkSheet.Cells[rowCounter, SemesterExport.Default.DisciplineCostColumn] = summ;
                        ObjWorkSheet.Cells[rowCounter, SemesterExport.Default.LecFactColumn]        = lec * weeks;
                        ObjWorkSheet.Cells[rowCounter, SemesterExport.Default.StudentsColumn]       = countStud;
                        ObjWorkSheet.Cells[rowCounter, SemesterExport.Default.DisciplineColumn].EntireRow.AutoFit(); //применить автовысоту
                    }
                    rowCounter++;
                }

                ObjExcel.Visible     = true;
                ObjExcel.UserControl = true;
            }
        }
Beispiel #9
0
 public List <DisciplineWorkload> GetAllDisciplineWorkloadsByYearAndSemesterType(int year, SemesterType semester)
 {
     using (Db.BeginReadOnlyWork())
     {
         return(_disciplineWorkloadRepository
                .GetMany(w => w.StudyYear.Year == year,
                         w => w.Group, w => w.DisciplineYear, w => w.DisciplineYear.Discipline, w => w.Semester, w => w.Group.Speciality.Faculty, w => w.Group.Speciality)
                .Where(w => w.Semester?.Type == semester).ToList());
     }
 }
Beispiel #10
0
 public Semester(SemesterType type)
 {
     this.SemType = type;
     this.Courses = new List <Course>();
 }