Exemplo n.º 1
0
def test_create_assigment():
    assignment1 = markbook.create_assignment(name="Assignment One",
                                             due="2019-09-21",
                                             points=100)
    expected = {"name": "Assignment One", "due": "2019-09-21", "points": 100}
    assert assignment1 == expected

    assignment2 = markbook.create_assignment(name="Assignment Two",
                                             due=None,
                                             points=1)
    assert assignment2["name"] == "Assignment Two"
    assert assignment2["due"] is None
    assert assignment2["points"] == 1
Exemplo n.º 2
0
def test_remove_assignment():
    assignment = markbook.create_assignment ("Math CPT", "October 21, 1999", 100)
    classroom = markbook.create_classroom("MHF4U", "Advanced Functions", 3, "Mr.Smith", ["Emma", "Ethan", "Nicholas"], [])
    markbook.add_assignment(assignment, classroom)
    assert len(classroom["assignment_list"]) == 1
    markbook.remove_assignment(assignment, classroom)
    assert len(classroom["assignment_list"]) == 0
    assert type(classroom["assignment_list"]) is list
Exemplo n.º 3
0
def test_create_assigment():
    assignment1 = markbook.create_assignment(name="Assignment One",
                                             due="2019-09-21",
                                             points=100,
                                             classcode="ICS4U1")
    expected = {
        "name": "Assignment One",
        "due": "2019-09-21",
        "points": 100,
        "classcode": ICS4U
    }
    assert assignment1 == expected

    assignment2 = main.create_assignment(name="Assignment Two",
                                         due=None,
                                         points=1,
                                         classcode="ICS4U1")
    assert assignment2["name"] == "Assignment Two"
    assert assignment2["due"] is None
    assert assignment2["points"] == 1
    assert assignment2["classcode"] == "ICS4U1"
Exemplo n.º 4
0
def create_assignment_interface():
    classrooms_names = []

    with open("data.json", "r") as data:
        data = json.loads(data.read())
        for classroom in data["classrooms"]:  # Iterates through classroom to print out all classroom names
            course_names = classroom["course_name"]
            classrooms_names.append(course_names)

    print(*classrooms_names, sep=", ")

    while True:
        try:
            # Takes input from user
            desired_classroom = input("Which Classroom: ")
            name = input("* Assignment Name: ")
            due = input("* Due Date: ")
            points = int(input("* Total Score: "))
            break
        except ValueError:
            print(" ---------------------------------------------------------- ")
            print("| Error, please enter a string.                            |")
            print(" ---------------------------------------------------------- ")

    for classroom in data["classrooms"]:  # Iterate through the data files classroom
        if desired_classroom == classroom["course_name"]:  # Check to see if the user's selected classroom is the 
            # current iteration 
            # Gets data from the API function
            added_assignment = create_assignment(name, due, points)

            # Set the classroom as the data returned from the API
            classroom["assignment_list"].append(added_assignment)

            with open("data.json", "w") as writer:
                # Converts the python into json strings
                data = json.dumps(data, indent=4)
                # Overwrite the current data with the new added on data
                writer.write(data)
            break
Exemplo n.º 5
0
    if page == 0:  # exit
        break

    elif page == 1:  # add assignment
        clear_screen()
        print('---ADDING AN ASSIGNMENT---')
        # collecting inputs
        name = input("Please Input the name of the" +
                     " assignment or '0' to go back: ")
        if name == '0':
            clear_screen()
            continue
        due = input('Input the due date: ')
        points = int(input('Input the points: '))
        # making the assignment
        assignment = (create_assignment(name, due, points))
        copy = copy()
        # getting classroom for assignment
        classroom = class_search(copy)

        if classroom is None:
            break
        # appending to assignments list
        assignment_list = classroom["assignment_list"]
        assignment_list.append(assignment)
        print("Just created an assignment with the following details:\n\n",
              assignment)
        print("Here are all the assignments\n\n", assignment_list)
        overwrite(copy)
        break