Skip to content

Commit

Permalink
Add: Parsons's tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
bjones1 committed Apr 12, 2021
1 parent 3aae348 commit 61819b2
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
21 changes: 21 additions & 0 deletions tests/test_course_1/_sources/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,27 @@ Multiple Choice
- Not gray.


Parsons
=======
.. parsonsprob:: test_parsons_1
:adaptive:
:order: 0 1 2 3 4

need some text ?
-----
def fib(num):
=====
if num == 0:
return 0:
=====
if num == 1:
return 1:
=====
return fib(num - 1) + fib(num - 2)
=====
return fib(num - 1) * fib(num - 2) #paired


Poll
====
.. poll:: test_poll_1
Expand Down
4 changes: 4 additions & 0 deletions tests/test_course_1/_sources/selectquestion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,9 @@ The following spreadsheet ``selectquestion`` components are commented out, since
:fromid: test_fitb_regex_3


.. selectquestion:: select_question_13
:fromid: test_parsons_1


.. selectquestion:: select_question_20
:fromid: test_short_answer_1
38 changes: 36 additions & 2 deletions tests/test_runestone_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from runestone.clickableArea.test import test_clickableArea
from runestone.fitb.test import test_fitb
from runestone.mchoice.test import test_assess
from runestone.parsons.test import test_parsons
from runestone.poll.test import test_poll
from runestone.shortanswer.test import test_shortanswer
from runestone.spreadsheet.test import test_spreadsheet
Expand All @@ -34,10 +35,10 @@
# Utilities
# =========
# Poll the database waiting for the client to perform an update via Ajax.
def get_answer(db, expr, expected_len):
def get_answer(db, expr, minimum_len):
return poll(
lambda: db(expr).select(),
check_success=lambda s: len(s) == expected_len,
check_success=lambda s: len(s) >= minimum_len,
step=0.1,
timeout=10,
)
Expand Down Expand Up @@ -231,6 +232,35 @@ def mc_check_common_fields(index):
# TODO: There are a lot more multiple choice tests that could be easily ported!


# Parsons's problems
# =================
def test_parsons_1(selenium_utils_user_1, runestone_db):
su = selenium_utils_user_1
db = runestone_db

def pp_check_common_fields(index, div_id):
row = check_common_fields_raw(
su, db, db.parsons_answers.div_id == div_id, index, div_id
)
return row.answer, row.correct, row.percent, row.source

test_parsons.test_general(selenium_utils_user_1)
assert pp_check_common_fields(0, "test_parsons_1") == (
"-",
False,
None,
"0_0-1_2_0-3_4_0-6_0-5_0",
)
assert pp_check_common_fields(1, "test_parsons_1") == (
"0_0-1_2_1-3_4_1-5_1",
True,
1.0,
"6_0",
)

# TODO: There are several more Parsons's problems tests that could be easily ported.


# Poll
# ----
def test_poll_1(selenium_utils_user_1, runestone_db):
Expand Down Expand Up @@ -296,6 +326,10 @@ def test_selectquestion_5(selenium_utils_user_2, runestone_db):
test_mchoice_1(selenium_utils_user_2, runestone_db)


def test_selectquestion_6(selenium_utils_user_2, runestone_db):
test_parsons_1(selenium_utils_user_2, runestone_db)


def test_selectquestion_20(selenium_utils_user_2, runestone_db):
test_short_answer_1(selenium_utils_user_2, runestone_db)

Expand Down

0 comments on commit 61819b2

Please sign in to comment.