Ejemplo n.º 1
0
def test_is_misaligned(config_app, coords, student_misaligned, reference):
    problem = Problem(name='Problem')
    problem.widget = ProblemWidget(x=coords[0],
                                   y=coords[1],
                                   width=coords[2],
                                   height=coords[2])

    assert pregrader.is_problem_misaligned(problem, student_misaligned,
                                           reference)
Ejemplo n.º 2
0
def test_is_blank(config_app, coords, result, student_aligned, reference):
    problem = Problem(name='Problem')
    problem.widget = ProblemWidget(x=coords[0],
                                   y=coords[1],
                                   width=coords[2],
                                   height=coords[3])

    assert not pregrader.is_problem_misaligned(problem, student_aligned,
                                               reference)
    assert pregrader.is_solution_blank(problem, student_aligned,
                                       reference) == result
Ejemplo n.º 3
0
def test_threshold(config_app, datadir):
    dir = os.path.join(datadir, 'thresholds')
    files = os.listdir(dir)
    for filename in files:
        img = Image.open(os.path.join(dir, filename))
        problem = Problem(name='Problem')
        problem.widget = ProblemWidget(x=0,
                                       y=0,
                                       width=img.size[0],
                                       height=img.size[1])

        data = np.array(img)
        reference = np.full_like(data, 255)

        assert not pregrader.is_solution_blank(problem, data, reference)
Ejemplo n.º 4
0
def add_test_data(app):
    for layout in ExamLayout:
        id = layout.value
        exam = Exam(id=id,
                    name=f'exam {layout.name}',
                    finalized=True,
                    layout=layout)
        db.session.add(exam)

        problem = Problem(id=id, name=f'Problem {layout.name}', exam_id=id)
        db.session.add(problem)

        problem_widget = ProblemWidget(id=id,
                                       name=f'problem widget {layout.name}',
                                       problem_id=id,
                                       page=2,
                                       width=100,
                                       height=150,
                                       x=40,
                                       y=200,
                                       type='problem_widget')
        db.session.add(problem_widget)
        db.session.commit()

        feedback_option = FeedbackOption(id=id,
                                         problem_id=id,
                                         text='text',
                                         description='desc',
                                         score=1)
        db.session.add(feedback_option)
        db.session.commit()

    yield app
Ejemplo n.º 5
0
def add_test_data(app):
    exam = Exam(id=42, name='exam f', finalized=True, layout="unstructured")
    db.session.add(exam)

    problem = Problem(id=20, name='Problem sad', exam_id=42)
    db.session.add(problem)
    db.session.commit()
    yield app
Ejemplo n.º 6
0
def test_submission_from_different_exam(test_client, add_test_data,
                                        add_test_submissions):
    exam = Exam(id=43, name='exam g', finalized=True, layout="unstructured")
    db.session.add(exam)
    problem = Problem(id=21, name='Problem sadder', exam_id=43)
    db.session.add(problem)

    res = test_client.get('/api/submissions/43/25')
    assert res.status_code == 400
Ejemplo n.º 7
0
def add_test_data(app):
    exam1 = Exam(name='exam 1', finalized=False)
    exam2 = Exam(name='exam 2', finalized=True)

    db.session.add(exam1)
    db.session.add(exam2)

    problem1 = Problem(name='Problem 1', exam=exam1)
    problem2 = Problem(name='Problem 2', exam=exam2)

    db.session.add(problem1)
    db.session.add(problem2)

    problem_widget_1 = ProblemWidget(name='problem widget', problem=problem1, page=2,
                                     width=100, height=150, x=40, y=200, type='problem_widget')
    db.session.add(problem_widget_1)

    db.session.commit()
    return [(exam1, exam2), (problem1, problem2), (problem_widget_1)]
Ejemplo n.º 8
0
def add_test_data(app):
    """Adds test data to the db.

    The feedback tree for problem 1 is (+: non-exlcusive; -: exclusive):
    + root(id=0)
        + A(id=1)
            + A1(id=11)
            + A2(id=12)
        + B(id=2)
            - B1(id=21)
            - B2(id=22)
    """
    exam = Exam(id=1, name='exam', finalized=True, layout="unstructured")
    db.session.add(exam)

    problem = Problem(id=1, name='Problem', exam=exam)
    db.session.add(problem)

    student = Student(id=1, first_name='Harry', last_name='Lewis')
    db.session.add(student)

    grader = Grader(id=1, name='Zesje', oauth_id='Zesje')
    db.session.add(grader)

    sub = Submission(id=1, student=student, exam=exam)
    db.session.add(sub)

    sol = Solution(id=1, submission=sub, problem=problem)
    db.session.add(sol)
    db.session.commit()

    root = problem.root_feedback

    for i in range(2):
        fo_parent = FeedbackOption(id=i + 1,
                                   problem=problem,
                                   text=chr(i + 65),
                                   description='',
                                   score=i,
                                   parent=root,
                                   mut_excl_children=i == 1)
        db.session.add(fo_parent)
        db.session.commit()
        for j in range(1, 3):
            fo = FeedbackOption(id=(i + 1) * 10 + j,
                                problem=problem,
                                text=chr(i + 65) + chr(j + 65),
                                description='',
                                score=-1 * i * j,
                                parent_id=i + 1)
            db.session.add(fo)

    db.session.commit()

    yield app
Ejemplo n.º 9
0
def add_test_data(app):
    exam1 = Exam(id=1, name='exam 1', finalized=False)
    db.session.add(exam1)
    db.session.commit()

    problem1 = Problem(id=1, name='Problem 1', exam_id=1)
    db.session.add(problem1)
    db.session.commit()

    problem_widget_1 = ProblemWidget(id=1, name='problem widget', problem_id=1, page=2,
                                     width=100, height=150, x=40, y=200, type='problem_widget')
    db.session.add(problem_widget_1)
    db.session.commit()
Ejemplo n.º 10
0
def add_test_data(app):
    exam = Exam(name='exam 1', finalized=True)
    db.session.add(exam)

    problem1 = Problem(name='Problem 1', exam=exam)
    problem2 = Problem(name='Problem 2', exam=exam)
    db.session.add(problem1)
    db.session.add(problem2)

    feedback_option = FeedbackOption(problem=problem1,
                                     text='text',
                                     description='desc',
                                     score=5)
    db.session.add(feedback_option)

    student = Student(id=1000001, first_name='', last_name='')
    db.session.add(student)

    sub = Submission(exam=exam, student=student, copies=[], validated=True)
    db.session.add(sub)
    db.session.commit()

    yield app, exam
Ejemplo n.º 11
0
def app_with_data(app):
    exam = Exam(name='', layout=ExamLayout.unstructured)
    problem = Problem(exam=exam, name='Problem')
    widget = ProblemWidget(problem=problem, x=0, y=0, width=0, height=0)
    students = [
        Student(id=i + 1000000, first_name='', last_name='') for i in range(2)
    ]
    db.session.add(exam)
    db.session.add(problem)
    db.session.add(widget)
    for student in students:
        db.session.add(student)
    db.session.commit()
    yield app, exam, students
Ejemplo n.º 12
0
def add_test_data(app):
    exam1 = Exam(id=1, name='exam 1', finalized=False)
    db.session.add(exam1)

    problem1 = Problem(id=1, name='Problem 1', exam_id=1)
    db.session.add(problem1)

    problem_widget_1 = ProblemWidget(id=1, name='problem widget', problem_id=1, page=2,
                                     width=100, height=150, x=40, y=200, type='problem_widget')
    db.session.add(problem_widget_1)
    db.session.commit()

    fo1 = FeedbackOption(id=5, problem_id=1, text='fully incorrect', score=2, parent=problem1.root_feedback)
    db.session.add(fo1)
    db.session.commit()

    yield problem1.root_feedback.id
Ejemplo n.º 13
0
def add_test_data(app):
    exam1 = Exam(id=1, name='exam 1', finalized=True)
    db.session.add(exam1)

    problem1 = Problem(id=1, name='Problem 1', exam_id=1)
    db.session.add(problem1)

    problem_widget_1 = ProblemWidget(id=1, name='problem widget', problem_id=1, page=2,
                                     width=100, height=150, x=40, y=200, type='problem_widget')
    db.session.add(problem_widget_1)
    db.session.commit()

    feedback_option = FeedbackOption(id=1, problem_id=1, text='text', description='desc', score=1)
    db.session.add(feedback_option)
    db.session.commit()

    mc_option = MultipleChoiceOption(id=2, label='a', feedback_id=1, x=10, y=30, name='mco', type='mcq_widget')
    db.session.add(mc_option)
    db.session.commit()
Ejemplo n.º 14
0
def problem():
    return Problem(name='')