Exemplo n.º 1
0
        public void DeleteClassworkAndGradeTest()
        {
            string   name        = "className";
            string   instructor  = "class instructor";
            int      creditHours = 3;
            Uri      email       = new Uri("mailto:[email protected]");
            Uri      website     = new Uri("https://www.sc.edu");
            Syllabus syllabus    = null;
            int      classType   = 1;
            string   notes       = "These are some notes for the class";
            ObservableCollection <MeetingTime> meetingTimes = new ObservableCollection <USurvive.MeetingTime>();
            GradeScale gradeScale = null; //We don't use this
            Class      tempClass  = new Class(name, instructor, creditHours, email, website, syllabus, classType, notes, meetingTimes, gradeScale);
            string     cl         = tempClass.Name;

            Globals.cwList    = new ClassworkList();
            Globals.gradebook = new GradeList();
            Globals.clList    = new ClassList();
            Globals.clList.AddClass(tempClass);
            Grade     tempGrade     = new Grade(cl, dueDate);
            Classwork tempClasswork = new Classwork(
                name, cl, dueDate, priority, tempGrade.gradeID, (bool)autoInc, autoIncDays, type, notifTime);

            Globals.gradebook.AddGrade(tempGrade);
            Globals.cwList.AddClasswork(tempClasswork);
            Assert.IsTrue(Globals.gradebook.grades.Contains(tempGrade));
            Assert.IsTrue(Globals.cwList.classwork.Contains(tempClasswork));
            Globals.cwList.DeleteClasswork(tempClasswork);
            Assert.IsFalse(Globals.gradebook.grades.Contains(tempGrade));
            Assert.IsFalse(Globals.cwList.classwork.Contains(tempClasswork));
        }
        private View CreateGradeScaleItemView(ViewGroup parent, GradeScale scale)
        {
            var view = new ListItemEditingGradeScaleView(parent, scale);

            view.OnRequestRemove += GradeScale_OnRequestRemove;
            return(view);
        }
Exemplo n.º 3
0
        public List <GradeScale> Load()
        {
            try
            {
                List <GradeScale> grades  = new List <GradeScale>();
                DataSet           dsGrade = gradeScaleDb.SelectAllGradeScale();
                if (dsGrade != null)
                {
                    if (dsGrade.Tables[0].Rows.Count > 0)
                    {
                        for (int i = 0; i < dsGrade.Tables[0].Rows.Count; i++)
                        {
                            GradeScale grade = new GradeScale();
                            grade.Id   = Convert.ToByte(dsGrade.Tables[0].Rows[i][gradeScaleDb.FIELD_GRADE_SCALE_ID]);
                            grade.From = Convert.ToDecimal(dsGrade.Tables[0].Rows[i][gradeScaleDb.FIELD_FROM]);
                            grade.To   = Convert.ToDecimal(dsGrade.Tables[0].Rows[i][gradeScaleDb.FIELD_TO]);

                            grades.Add(grade);
                        }
                    }
                }

                return(grades);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Writes a collection of <see cref="Student"/> objects to a file.
        /// </summary>
        /// <param name="writer">The type of <see cref="FileWriter"/> to use.</param>
        /// <param name="scale">The type of <see cref="GradeScale"/> to use for grade conversions.</param>
        /// <seealso cref="FileWriter"/>
        public void WriteStudentsToFile(FileWriter writer, GradeScale scale)
        {
            using (writer)
            {
                foreach (var student in Students)
                {
                    var studentRecord = new List <string>();

                    studentRecord.Add(student.LastName);
                    studentRecord.Add(student.FirstName);

                    int quizGradeTotal = 0;

                    foreach (var grade in student.QuizGrades)
                    {
                        quizGradeTotal += grade;
                        studentRecord.Add(grade.ToString());
                    }

                    double numericalQuizGrade = quizGradeTotal / 10.0;
                    studentRecord.Add(Math.Round(numericalQuizGrade, 1).ToString());
                    studentRecord.Add(scale.GetLetterGrade(Math.Round(numericalQuizGrade)).ToString());

                    writer.WriteRecord(studentRecord);
                }
            }
        }
Exemplo n.º 5
0
        public async Task <IActionResult> StudentIndex(int id, int SubId)
        {
            if (HttpContext.Session.GetString("Role") == "User" && HttpContext.Session.GetString("Id") != id.ToString())
            {
                return(RedirectToAction("AccessDenied", "Account"));
            }

            var stt = await _db.Users.FindAsync(id);

            IEnumerable <lista_7.Models.Grade> grades;

            if (SubId == 0)
            {
                grades = await _db.Grades.Where(g => g.StudentId == id).ToListAsync();
            }
            else
            {
                grades = await _db.Grades.Where(g => g.StudentId == id && g.SubjectId == SubId).ToListAsync();
            }

            var subj = await _db.Subjects.ToListAsync();

            String subids   = "";
            String subnames = "";

            foreach (var s in subj)
            {
                subids   += s.Id + ",";
                subnames += s.Name + ",";
            }
            ViewData["Subids"]   = subids;
            ViewData["Subnames"] = subnames;
            ViewData["Student"]  = stt.Name + " " + stt.LastName;

            foreach (var grade in grades)
            {
                User student = await _db.Users.FindAsync(grade.StudentId);

                ViewData["Student" + grade.Id] = student.Name + " " + student.LastName;
                User teacher = await _db.Users.FindAsync(grade.TecherId);

                ViewData["Teacher" + grade.Id] = teacher.Name + " " + teacher.LastName;
                Subject subject = await _db.Subjects.FindAsync(grade.SubjectId);

                ViewData["Subject" + grade.Id] = subject.Name;
                GradeScale gradeScale = await _db.GradeScales.FindAsync(grade.gradeScaleId);

                ViewData["Scale" + grade.Id] = gradeScale.DownBorder + "-" + grade.gradeScale.UpBorder;
            }

            return(View(grades));
        }
        public async Task <IActionResult> Create(GradeScale gs, int allowHalf)
        {
            if (ModelState.IsValid)
            {
                gs.AllowHalfGrades = allowHalf;
                await _db.GradeScales.AddAsync(gs);

                await _db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Create"));
            }
        }
Exemplo n.º 7
0
        public double GetGPAForGrade(double grade)
        {
            GradeScale[] gradeScales;

            //if they have a custom grade scale
            if (this.GradeScales != null && this.GradeScales.Length != 0)
            {
                gradeScales = this.GradeScales;
            }


            //use default grade scale
            else
            {
                gradeScales = GradeScale.GenerateDefaultScaleWithoutLetters();
            }



            //if the grade percents are rounded up
            if (this.DoesRoundGradesUp)
            {
                int roundedGrade = (int)MyMath.Round(grade * 100);

                for (int i = 0; i < gradeScales.Length; i++)
                {
                    if (roundedGrade >= (gradeScales[i]).StartGrade)
                    {
                        return((gradeScales[i]).GPA);
                    }
                }
            }

            else
            {
                for (int i = 0; i < gradeScales.Length; i++)
                {
                    if (grade * 100 >= (gradeScales[i]).StartGrade)
                    {
                        return((gradeScales[i]).GPA);
                    }
                }
            }

            return(gradeScales.Last().GPA);
        }
        public async Task <IActionResult> Edit(GradeScale gs, int allowHalf)
        {
            if (ModelState.IsValid)
            {
                GradeScale actgs = await _db.GradeScales.FindAsync(gs.Id);

                actgs.AllowHalfGrades = allowHalf;
                actgs.DownBorder      = gs.DownBorder;
                actgs.UpBorder        = gs.UpBorder;
                await _db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Edit"));
            }
        }
Exemplo n.º 9
0
        protected override void PopulateFromDataItemOverride(BaseDataItem dataItem)
        {
            base.PopulateFromDataItemOverride(dataItem);

            DataItemClass i = dataItem as DataItemClass;

            CourseNumber             = i.CourseNumber;
            ShouldAverageGradeTotals = i.ShouldAverageGradeTotals;
            DoesRoundGradesUp        = i.DoesRoundGradesUp;
            Color        = i.RawColor;
            Position     = i.Position;
            GradeScales  = i.GetGradeScales() ?? GradeScale.GenerateDefaultScaleWithoutLetters();
            Credits      = i.Credits;
            StartDate    = DateTime.SpecifyKind(i.StartDate, DateTimeKind.Local);
            EndDate      = DateTime.SpecifyKind(i.EndDate, DateTimeKind.Local);
            GpaType      = i.GpaType;
            PassingGrade = i.PassingGrade;

            _needsRecalc = true;
        }
Exemplo n.º 10
0
        public GradeScale GetGrade(int score)
        {
            try
            {
                GradeScale grade   = new GradeScale();
                DataSet    dsGrade = gradeScaleDb.SelectGradeScaleByFromAndTo(score);
                if (dsGrade != null)
                {
                    if (dsGrade.Tables[0].Rows.Count > 0)
                    {
                        grade.Id = Convert.ToByte(dsGrade.Tables[0].Rows[0][gradeScaleDb.FIELD_GRADE_SCALE_ID]);
                    }
                }

                return(grade);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 11
0
        public void TestAssignment()
        {
            using (var sw = new StringWriter())
            {
                Console.SetOut(sw);
                string   name            = "Name";
                string   instructor      = "Inst";
                int      creditHours     = 5;
                Uri      instructorEmail = null;
                Uri      classWebsite    = null;
                Syllabus syllabus        = null;
                int      classType       = 0;
                string   notes           = "notes";
                ObservableCollection <MeetingTime> meetingTimes = null;
                GradeScale gradeScale = new GradeScale(7, 0);

                //USurvive.Assignment assignment = new USurvive.Assignment(name, new USurvive.Class("Class name", null, 0, null, null, null, 0, "", null), new DateTime(), new DateTime(), 0, null, false, 0);
                Class UClass = new Class(name, instructor, creditHours, instructorEmail, classWebsite, syllabus, classType, notes, meetingTimes, gradeScale);

                Assert.IsTrue(UClass.Name.Equals(name));
            }
        }
Exemplo n.º 12
0
        public async Task <IActionResult> Index()
        {
            var grades = await _db.Grades.ToListAsync();

            foreach (var grade in grades)
            {
                User student = await _db.Users.FindAsync(grade.StudentId);

                ViewData["Student" + grade.Id] = student.Name + " " + student.LastName;
                User teacher = await _db.Users.FindAsync(grade.TecherId);

                ViewData["Teacher" + grade.Id] = teacher.Name + " " + teacher.LastName;
                Subject subject = await _db.Subjects.FindAsync(grade.SubjectId);

                ViewData["Subject" + grade.Id] = subject.Name;
                GradeScale gradeScale = await _db.GradeScales.FindAsync(grade.gradeScaleId);

                ViewData["Scale" + grade.Id] = gradeScale.DownBorder + "-" + grade.gradeScale.UpBorder;
            }

            return(View(grades));
        }
 private void GradeScale_OnRequestRemove(object sender, GradeScale e)
 {
     ViewModel.RemoveGradeScale(e);
 }
 public void RemoveGradeScale(GradeScale scale)
 {
     scale.PropertyChanged -= GradeScale_PropertyChanged;
     GradeScales.Remove(scale);
     UpdateSelectedSavedGradeScale();
 }
        private async System.Threading.Tasks.Task ReloadSavedGradeScalesPicker()
        {
            var account            = MainScreenViewModel.CurrentAccount;
            var savedScalesManager = await SavedGradeScalesManager.GetForAccountAsync(account);

            var savedScales = await savedScalesManager.GetSavedGradeScalesAsync();

            if (!savedScales.Any(i => i.Name.Equals("United States")))
            {
                savedScales.Add(new SavedGradeScale()
                {
                    Name        = "United States",
                    GradeScales = GradeScale.GenerateDefaultScaleWithoutLetters()
                });
            }

            if (!savedScales.Any(i => i.Name.Equals("Eleven-Point System")))
            {
                savedScales.Add(new SavedGradeScale()
                {
                    Name        = "Eleven-Point System",
                    GradeScales = GradeScale.GenerateElevenPointScale()
                });
            }

            if (!savedScales.Any(i => i.Name.Equals("Twelve-Point System")))
            {
                savedScales.Add(new SavedGradeScale()
                {
                    Name        = "Twelve-Point System",
                    GradeScales = GradeScale.GenerateTwelvePointScale()
                });
            }

            if (!savedScales.Any(i => i.Name.Equals("Mexico - 100 Point")))
            {
                savedScales.Add(new SavedGradeScale()
                {
                    Name        = "Mexico - 100 Point",
                    GradeScales = GradeScale.GenerateMexico100PointScale()
                });
            }

            if (!savedScales.Any(i => i.Name.Equals("Mexico - 10 Point")))
            {
                savedScales.Add(new SavedGradeScale()
                {
                    Name        = "Mexico - 10 Point",
                    GradeScales = GradeScale.GenerateMexico10PointScale()
                });
            }

            savedScales.Add(new SavedGradeScale()
            {
                Name = PowerPlannerResources.GetString("String_GradeScaleCustom")
            });

            SavedGradeScales = savedScales;

            UpdateSelectedSavedGradeScale();
        }
Exemplo n.º 16
0
        public ListItemEditingGradeScaleView(ViewGroup root, GradeScale gradeScale) : base(Resource.Layout.ListItemEditingGradeScale, root)
        {
            DataContext = gradeScale;

            FindViewById <ImageButton>(Resource.Id.ImageButtonRemoveItem).Click += RemoveItem_Click;
        }