Beispiel #1
0
        public IList <ClassStatsInfo> GetClassesStatsForStudent(int studentId, int gradingPeriodId, ClassSortType?sortType)
        {
            Trace.Assert(Context.SchoolYearId.HasValue);
            if (!(BaseSecurity.IsDistrictOrTeacher(Context) || studentId == Context.PersonId))
            {
                throw new ChalkableSecurityException();
            }

            IList <SectionSummaryForStudent> iNowRes;

            try
            {
                iNowRes = ConnectorLocator.ClassesDashboardConnector.GetSectionSummaryForStudent(Context.SchoolYearId.Value, studentId, gradingPeriodId);
            }
            catch (ChalkableSisNotSupportVersionException)
            {
                var gp           = ServiceLocator.GradingPeriodService.GetGradingPeriodById(gradingPeriodId);
                var chalkableRes = DoRead(u => new ClassDataAccess(u).GetStudentClasses(Context.SchoolYearId.Value, studentId, gp.MarkingPeriodRef));
                return(SortClassesStats(chalkableRes.Select(ClassStatsInfo.Create), sortType).ToList());
            }
            using (var u = Read())
            {
                var classesIds    = iNowRes.Select(x => x.SectionId).ToList();
                var classes       = new ClassDataAccess(u).GetByIds(classesIds);
                var classTeachers = new ClassTeacherDataAccess(u).GetClassTeachers(classesIds);
                var res           = ClassStatsInfo.Create(iNowRes, classes, classTeachers);
                return(SortClassesStats(res, sortType).ToList());
            }
        }
        public void InitLevel(CharacterModel character)
        {
            if (character.Experience != 0)
            {
                EXP = character.Experience;
            }
            if (character.Fame != 0)
            {
                CharFame = character.Fame;
            }
            ClassStatsInfo classStat = Client.Account.Stats.GetClassStats((int)Type);

            NextClassQuestFame = GetNextClassQuestFame(classStat.BestFame > CharFame ? classStat.BestFame : CharFame);
            NextLevelEXP       = GetNextLevelEXP(Level);
            GainEXP(0);
        }
        public static ClassStatsViewData Create(ClassStatsInfo classDetails)
        {
            return(new ClassStatsViewData
            {
                Id = classDetails.Id,
                Name = classDetails.Name,
                DepartmentRef = classDetails.DepartmentRef,

                PrimaryTeacherDisplayName = classDetails.PrimaryTeacherDisplayName,
                StudentsCount = classDetails.StudentsCount,

                AbsenceCount = classDetails.AbsenceCount,
                Presence = classDetails.Presence,
                Average = classDetails.Average,
                DisciplinesCount = classDetails.DisciplinesCount,
                ClassNumber = classDetails.ClassNumber,
                TeacherIds = classDetails.TeacherIds,
                Periods = classDetails.Periods
            });
        }
Beispiel #4
0
        public IList <ClassStatsInfo> GetClassesStats(int schoolYearId, int?start, int?count, string filter, int?teacherId, ClassSortType?sortType)
        {
            start = start ?? 0;
            count = count ?? int.MaxValue;
            var iNowSortType = EnumMapperFactory.GetMapper <ClassSortType, SectionSummarySortOption>().Map(sortType ?? ClassSortType.ClassAsc);

            IList <SectionSummary> iNowRes;

            try
            {
                if (teacherId.HasValue)
                {
                    iNowRes = ConnectorLocator.ClassesDashboardConnector.GetSectionSummariesByTeacher(schoolYearId,
                                                                                                      teacherId.Value, Context.NowSchoolYearTime, start.Value + 1, start.Value + count.Value, filter, iNowSortType);
                }
                else
                {
                    iNowRes = ConnectorLocator.ClassesDashboardConnector.GetSectionsSummaries(schoolYearId,
                                                                                              Context.NowSchoolYearTime, start.Value + 1, start.Value + count.Value, filter, iNowSortType);
                }
            }
            catch (ChalkableSisNotSupportVersionException)
            {
                var chalkableRes = DoRead(u => new ClassDataAccess(u).GetClassesBySchoolYear(schoolYearId, start.Value, count.Value,
                                                                                             filter, teacherId, (int?)sortType));
                return(chalkableRes.Select(ClassStatsInfo.Create).ToList());
            }

            using (var u = Read())
            {
                var classesIds    = iNowRes.Select(x => x.SectionId).ToList();
                var classes       = new ClassDataAccess(u).GetByIds(classesIds);
                var classTeachers = new ClassTeacherDataAccess(u).GetClassTeachers(classesIds);

                return(ClassStatsInfo.Create(iNowRes, classes, classTeachers));
            }
        }
        public bool GainEXP(int exp)
        {
            EXP += exp;

            int newFame = EXP / EXPPerFame;

            if (newFame != CharFame)
            {
                CharFame = newFame;
            }

            ClassStatsInfo classStat         = Client.Account.Stats.GetClassStats((int)Type);
            int            newClassQuestFame = GetNextClassQuestFame(classStat.BestFame > newFame ? classStat.BestFame : newFame);

            if (newClassQuestFame > NextClassQuestFame)
            {
                byte[] notification = GameServer.Notification(Id, "Class Quest Complete!", 0xFF00FF00);
                foreach (Entity en in Parent.PlayerChunks.HitTest(Position, SightRadius))
                {
                    if (en is Player player &&
                        (player.Client.Account.Notifications || player.Equals(this)))
                    {
                        player.Client.Send(notification);
                    }
                }
                NextClassQuestFame = newClassQuestFame;
            }

            bool levelledUp = false;

            if (EXP - GetLevelEXP(Level) >= NextLevelEXP && Level < MaxLevel)
            {
                levelledUp = true;
                Level++;
                NextLevelEXP = GetNextLevelEXP(Level);
                StatDesc[] stats = Resources.Type2Player[Type].Stats;
                for (int i = 0; i < stats.Length; i++)
                {
                    int min = stats[i].MinIncrease;
                    int max = stats[i].MaxIncrease;
                    Stats[i] += MathUtils.NextInt(min, max);
                    if (Stats[i] > stats[i].MaxValue)
                    {
                        Stats[i] = stats[i].MaxValue;
                    }
                }

                HP = Stats[0];
                MP = Stats[1];

                if (Level == 20)
                {
                    byte[] text = GameServer.Text("", 0, -1, 0, "", $"{Name} achieved level 20");
                    foreach (Player player in Parent.Players.Values)
                    {
                        player.Client.Send(text);
                    }
                }

                RecalculateEquipBonuses();
            }

            TrySetSV(StatType.EXP, EXP - GetLevelEXP(Level));
            return(levelledUp);
        }