def test_get_num_students_in_program(self): """ 060A - Valid Get Number of Student in Program """ test_student_1 = Student("Bill", "Smith", "A0100000000", "CIT") test_student_1.add_course("ACIT2515") test_student_2 = Student("Ken", "Rodgers", "A0100000001", "CSD") test_student_2.add_course("COMP1510") test_student_3 = Student("Sally", "Jones", "A0100000002", "CSD") test_student_3.add_course("COMP1510") test_student_4 = Student("Julie", "Wong", "A0100000003", "CSD") test_student_4.add_course("COMP1510") test_school = School("Computing and Academic Studies") test_school.add_student(test_student_1) test_school.add_student(test_student_2) test_school.add_student(test_student_3) test_school.add_student(test_student_4) self.assertEqual(test_school.get_num_students_in_program("CIT"), 1, "Must be only 1 CIT student") self.assertEqual(test_school.get_num_students_in_program("CSD"), 3, "Must be 3 CSD students") self.assertEqual(test_school.get_num_students_in_program("SSD"), 0, "Must be no SSD students")
def decode_object(json_dict): if "__student__" in json_dict: new_student = Student(json_dict["name"]) json_dict.pop("__student__") for course, info in json_dict["work"].items(): new_student.add_course(course) for type, progress in info.items(): progress_obj = Progress(type) for lg, attempts in progress.items(): progress_obj.add_lg(lg) for attempt in attempts: progress_obj.add_attempt(attempt["lg"], \ Attempt(attempt["score"], attempt["outof"], \ attempt["date"], attempt["lg"], attempt["comment"])) new_student.add_progress(course, type, progress_obj)
def test_get_non_existent_student(self): """ 050C - Invalid Get Student Non-Existent """ test_student_1 = Student("Bill", "Smith", "A0100000000", "CIT") test_student_1.add_course("ACIT2515") test_student_2 = Student("Ken", "Rodgers", "A0100000001", "CIT") test_student_2.add_course("ACIT2515") test_student_2.add_course("COMP1409") test_school = School("Computing and Academic Studies") test_school.add_student(test_student_1) test_school.add_student(test_student_2) self.assertIsNone(test_school.get_student("AXXXYYYZZZ"), "No student should exists for AXXXYYYZZZ")
def add_student(): """adds a student to the school and attaches the courses""" content = request.json try: student = Student(content['first_name'], content['last_name'], content['student_number'], content['program']) if (school.student_exists(content['student_number']) == True): raise ValueError('Student Exists') else: school.add_student(student) for course in content['courses']: student.add_course(course) response = app.response_class(status=200) except ValueError as e: response = app.response_class(response=str(e), status=400) return response
def update_student(student_number): """updates a student by student number""" content = request.json try: if (school.student_exists(content['student_number']) == False): raise ValueError('No student found with this number') else: student = Student(content['first_name'], content['last_name'], student_number, content['program']) school.remove_student(student_number) school.add_student(student) for course in content['courses']: student.add_course(course) response = app.response_class(status=200) except ValueError as e: response = app.response_class(status=404) return response
def test_student_exists(self): """ 030A - Valid Student Exists """ test_student_1 = Student("Bill", "Smith", "A0100000000", "CIT") test_student_1.add_course("ACIT2515") test_student_2 = Student("Ken", "Rodgers", "A0100000001", "CIT") test_student_2.add_course("ACIT2515") test_student_2.add_course("COMP1409") test_school = School("Computing and Academic Studies") test_school.add_student(test_student_1) test_school.add_student(test_student_2) self.assertTrue(test_school.student_exists("A0100000000"), "Student A0100000000 must exist") self.assertTrue(test_school.student_exists("A0100000001"), "Student A0100000001 must exist")
def test_add_student_already_exists(self): """ 020C - Student Already Exists """ test_student_1 = Student("Bill", "Smith", "A0100000000", "CIT") test_student_1.add_course("ACIT2515") test_school = School("Computing and Academic Studies") self.assertEqual(test_school.get_num_students(), 0, "School must have no students") test_school.add_student(test_student_1) self.assertEqual(test_school.get_num_students(), 1, "School must have 1 student") # Add the same student again test_school.add_student(test_student_1) self.assertEqual(test_school.get_num_students(), 1, "School must have 1 student")
def test_get_student(self): """ 050A - Valid Get Student """ test_student_1 = Student("Bill", "Smith", "A0100000000", "CIT") test_student_1.add_course("ACIT2515") test_student_2 = Student("Ken", "Rodgers", "A0100000001", "CIT") test_student_2.add_course("ACIT2515") test_student_2.add_course("COMP1409") test_school = School("Computing and Academic Studies") test_school.add_student(test_student_1) test_school.add_student(test_student_2) retrieved_student = test_school.get_student("A0100000001") self.assertEqual(retrieved_student.get_student_number(), "A0100000001", "Student must have student number A0100000001") self.assertEqual(retrieved_student.get_program(), "CIT", "Student must be in CIT program")
def test_student_exists_not_existent_student(self): """ 030C - Valid Student Does Not Exist """ test_student_1 = Student("Bill", "Smith", "A0100000000", "CIT") test_student_1.add_course("ACIT2515") test_student_2 = Student("Ken", "Rodgers", "A0100000001", "CIT") test_student_2.add_course("ACIT2515") test_student_2.add_course("COMP1409") test_school = School("Computing and Academic Studies") test_school.add_student(test_student_1) test_school.add_student(test_student_2) self.assertFalse(test_school.student_exists("B0100000000"), "Student B0100000000 must NOT exist") self.assertFalse(test_school.student_exists("A0100000002"), "Student A0100000002 must NOT exist")
def test_add_student(self): """ 020A - Valid Add Student """ test_student_1 = Student("Bill", "Smith", "A0100000000", "CIT") test_student_1.add_course("ACIT2515") test_student_2 = Student("Ken", "Rodgers", "A0100000001", "CIT") test_student_2.add_course("ACIT2515") test_student_2.add_course("COMP1409") test_school = School("Computing and Academic Studies") self.assertEqual(test_school.get_num_students(), 0, "School must have no students") test_school.add_student(test_student_1) self.assertEqual(test_school.get_num_students(), 1, "School must have 1 student") test_school.add_student(test_student_2) self.assertEqual(test_school.get_num_students(), 2, "School must have 2 students")
def test_remove_non_existent_student(self): """ 040C - Invalid Remove Student Non-Existent """ test_student_1 = Student("Bill", "Smith", "A0100000000", "CIT") test_student_1.add_course("ACIT2515") test_student_2 = Student("Ken", "Rodgers", "A0100000001", "CIT") test_student_2.add_course("ACIT2515") test_student_2.add_course("COMP1409") test_school = School("Computing and Academic Studies") test_school.add_student(test_student_1) test_school.add_student(test_student_2) self.assertEqual(test_school.get_num_students(), 2, "School must have 2 students") self.assertTrue(test_school.student_exists("A0100000000")) self.assertTrue(test_school.student_exists("A0100000001")) test_school.remove_student("B0100000001") self.assertEqual(test_school.get_num_students(), 2, "School must have 2 students")
import flask from student import Student from flask import request from flask_cors import cross_origin import json app = flask.Flask("__main__") #########################SAMPLE DATA########################## stu1 = Student("Tedrick") EnglishCats = ["Midterm", "Final", "Project"] EnglishWeights = [.25, .5, .25] stu1.add_course("English", EnglishCats, EnglishWeights) stu1.add_grade("English", "Amazing midterm", "Midterm", 98, 100) stu1.add_grade("English", "Amazing final", "Final", 86, 100) stu1.add_grade("English", "Kernel assignment", "Project", 107, 100) stu1.add_task("English", "Reading Assignment 1", 2, 18, 2019) stu1.add_task("English", "Reading Assignment 2", 2, 19, 2019) MathCats = ["Exam", "Quiz", "Assignment", "Lab"] MathWeights = [.4, .3, .2, .1] stu1.add_course("Math", MathCats, MathWeights) stu1.add_grade("Math", "q 1", "Quiz", 98, 100) stu1.add_grade("Math", "Ass 1", "Assignment", 86, 100) stu1.add_grade("Math", "e 1", "Exam", 65, 100) stu1.add_grade("Math", "lab 1", "Lab", 80, 100) stu1.add_task("Math", "Chem Reading 3", 2, 18, 2019)
from student import Student """Creating an instance of the Student class for myself""" print('<--- Student #0 --->') myself = Student('josh', 'w', 'BCIT School of Computing', 'CIT') myself.add_course('ACIT2420') myself.add_course('ACIT2515') myself.add_course('ACIT2520') myself.add_course('ACIT2620') myself.add_course('ACIT2831') myself.add_course('COMM2216') myself.add_course('MATH1350') myself.remove_course('ACIT2515') if myself.confirm_enrollment('ACIT2515') is False: print('I should be enrolled in ACIT2515!') print(myself.student_summary()) """Creating an instance of the Student class for classmate 1""" print('<--- Student #1 --->') classmate1 = Student('jim', 'bob', 'BCIT School of Computing', 'CIT') classmate1.add_course('ACIT2515') classmate1.add_course('ACIT2420') classmate1.add_course('ACIT2520') classmate1.add_course('ACIT2620') classmate1.add_course('ACIT2831') classmate1.add_course('COMM2216') classmate1.add_course('MATH1350') classmate1.add_course('ACIT2420') classmate1.add_course('ACIT2515') classmate1.remove_course('ACIT2520') classmate1.remove_course('ACIT2620') classmate1.remove_course('ACIT2831') classmate1.remove_course('COMM2216')
from course import Course from student import Student math = Course("Algebra I") language = Course("Spanish I") science = Course("Earth Science") history = Course("U.S. History I") phys_ed = Course("Physical Education I") computer_science = Course("Computer Science I") nerd = Course("Becoming An Introvert I") test_student1 = Student("Jill", "Sample") test_student1.add_course(math) test_student1.add_course(language) test_student1.add_course(science) test_student1.add_course(history) test_student2 = Student("Bill", "Sample") test_student2.add_course(math) test_student2.add_course(phys_ed) test_student2.add_course(science) test_student2.add_course(history) test_student3 = Student("Ligma", "Sample") test_student3.add_course(nerd) test_student3.add_course(science) test_student3.add_course(computer_science) test_student3.add_course(history) # TODO print student_list print(Student.student)
from student import Student student1 = Student("Sadman", "Hiya", 3.9, "123") print(student1.cgpa) if student1.cgpa < Student.PROBATION_LIMIT: print("You are in probation") student1.add_money(20000) student1.add_course() student1.add_course()
from course import Course from student import Student math = Course("Algebra I") language = Course("Spanish I") science = Course("Earth Science") history = Course("U.S. History I") phys_ed = Course("Physical Education I") comp_sci = Course("Python Programming") home_ec = Course("Home Ecomics") # TODO: Add two more courses of your choosing - done test_student = Student("Jill", "Sample") test_student.add_course(math) test_student.add_course(language) test_student.add_course(science) test_student.add_course(history) test_student2 = Student("Bill", "Sample") test_student2.add_course(math) test_student2.add_course(phys_ed) test_student2.add_course(science) test_student2.add_course(history) test_student3 = Student("Bill", "Sample") test_student3.add_course(math) test_student3.add_course(phys_ed) test_student3.add_course(science) test_student3.add_course(history) # TODO Add a third test student and assign them four classes - done