예제 #1
0
def test_create_course():
    teacher = pkg.Teacher("Mr-m")
    teacher.create_course("quantum-mechanics")

    course = pkg.Course("quantum-mechanics", teacher, [])
    assert isinstance(teacher.teaches(), list)
    assert course in teacher.teaches()
예제 #2
0
def test_teacher():
    courses = [
        pkg.Course("physics", None, []),
        pkg.Course("quantum", None, [])
    ]
    teacher = pkg.Teacher("Mr-m", courses)
    assert teacher.teaches() == courses
예제 #3
0
def test_student_quiz():
    """
    A student should be able to answer questions in a quiz and to marked it as
    done (submit it).
    """
    teacher = pkg.Teacher("Mr-m")
    course = teacher.create_course("quantum-mechanics")
    quiz = teacher.create_quiz("quantum-mechanics-quiz", course)

    questions = [
        pkg.MultipleChoice([1, 2, 3]),
        pkg.MultipleChoice(["a", "b", "c"])
    ]
    for q in questions:
        teacher.add_question_to_quiz("quantum-mechanics-quiz", q)

    teacher.assign_quiz_to_course("quantum-mechanics-quiz", course)

    student = pkg.Student("R")
    student.signup_for_course(course)

    questions = student.get_quiz("quantum-mechanics-quiz").list_questions()
    questions[0].choose_options(1)
    questions[1].choose_options("a")
    student.finished_quiz("quantum-mechanics-quiz")

    answered_quiz = course.look_for_students_quiz(student,
                                                  "quantum-mechanics-quiz")
    assert answered_quiz is not None
    assert isinstance(answered_quiz, pkg.Quiz)
    assert answered_quiz.is_finished() == True
    assert answered_quiz.list_questions()[0].get_answer() == 1
    assert answered_quiz.list_questions()[1].get_answer() == "a"
예제 #4
0
def test_assign_quiz():
    """
    A teacher should be able to create a course, create a quiz with questions,
    and to assign the quiz to students.
    """
    teacher = pkg.Teacher("Mr-m")
    course = teacher.create_course("quantum-mechanics")
    quiz = teacher.create_quiz("quantum-mechanics-quiz", course)

    questions = [
        pkg.MultipleChoice([1, 2, 3]),
        pkg.MultipleChoice(["a", "b", "c"])
    ]
    for q in questions:
        teacher.add_question_to_quiz("quantum-mechanics-quiz", q)

    teacher.assign_quiz_to_course("quantum-mechanics-quiz", course)

    student = pkg.Student("R")
    student.signup_for_course(course)

    teachers_question = teacher.get_quiz(
        "quantum-mechanics-quiz").list_questions()
    students_questions = student.get_quiz(
        "quantum-mechanics-quiz").list_questions()
    assert set(teachers_question) == set(students_questions)
예제 #5
0
def test_grade_student_quiz():
    """                                                                         
    A student should be able to answer a quiz, submit it, and have it graded. 
    """
    teacher = pkg.Teacher("Mr-n")
    course = teacher.create_course("qm")
    quiz = teacher.create_quiz("qm-quiz", course)

    questions = [
        pkg.MultipleChoice([1, 2, 3], 1),
        pkg.MultipleChoice(["a", "b", "c"], "b")
    ]
    for q in questions:
        teacher.add_question_to_quiz("qm-quiz", q)

    teacher.save_answer_key_for_course("qm-quiz", course)
    teacher.assign_quiz_to_course("qm-quiz", course)

    student = pkg.Student("R")
    student.signup_for_course(course)

    questions = student.get_quiz("qm-quiz").list_questions()
    questions[0].choose_options(1)
    print("1. ", course.get_answer_keys())
    questions[1].choose_options("a")
    print("1. ", course.get_answer_keys())
    student.finished_quiz("qm-quiz")

    grades = course.grade_student_quizzes(student)
    assert grades == [0.5]
예제 #6
0
def test_course():
    """
    A course should be able to hold information about the teacher and the
    students.
    """
    course = pkg.Course("physics", None, [])

    teacher = pkg.Teacher("Mr-m")
    students = [pkg.Student("bobby")]
    course = pkg.Course("physics", teacher, students)
    assert course.get_teacher() == teacher
    assert course.get_students() == students
예제 #7
0
def test_course_signup():
    """
    A teacher should be able to create a course for which a student can sign
    up.
    """
    teacher = pkg.Teacher("Mr-m")
    student = pkg.Student("bobby")
    course = teacher.create_course("quantum-mechanics")
    student.signup_for_course(course)

    assert teacher.get_name() == course.get_teacher().get_name()
    assert student in course.get_students()
예제 #8
0
def test_create_quiz():
    """
    A teacher should be able to create a quiz and add questions to it.
    """
    teacher = pkg.Teacher("Mr-m")
    course = teacher.create_course("quantum-mechanics")
    teacher.create_quiz("quantum-mechanics-quiz", course)

    questions = [
        pkg.MultipleChoice([1, 2, 3]),
        pkg.MultipleChoice(["a", "b", "c"])
    ]
    for q in questions:
        teacher.add_question_to_quiz("quantum-mechanics-quiz", q)

    quiz_questions = teacher.get_quiz("quantum-mechanics-quiz")
    assert set(quiz_questions.list_questions()) == set(questions)
예제 #9
0
def step_impl(context, name):
    context.teacher = pkg.Teacher(name)