예제 #1
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
예제 #2
0
def get_first_feedback():
    feedback_option1 = FeedbackOption(id=1,
                                      problem_id=20,
                                      text='text',
                                      description='desc',
                                      score=1)
    feedback_option2 = FeedbackOption(id=2,
                                      problem_id=20,
                                      text='text',
                                      description='desc',
                                      score=1)
    return [feedback_option1, feedback_option2]
예제 #3
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
예제 #4
0
def get_second_feedback():
    feedback_option3 = FeedbackOption(id=3,
                                      problem_id=20,
                                      text='text',
                                      description='desc',
                                      score=1)
    return [feedback_option3]
예제 #5
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
예제 #6
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()
예제 #7
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
예제 #8
0
def feedback_option():
    return FeedbackOption(text='')