Skip to content
This repository was archived by the owner on Jun 30, 2024. It is now read-only.

Commit eb79218

Browse files
committed
Merge branch 'bjones1-q_secnum'
2 parents aad42e5 + 11009b1 commit eb79218

File tree

6 files changed

+36
-39
lines changed

6 files changed

+36
-39
lines changed

controllers/admin.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,20 +1700,20 @@ def _get_toc_and_questions():
17001700

17011701
# chapters are associated base_course.
17021702
chapters_query = db((db.chapters.course_id == base_course)).select(
1703-
orderby=db.chapters.id
1703+
orderby=db.chapters.chapter_num
17041704
)
1705-
ids = {row.chapter_name: row.id for row in chapters_query}
1705+
ids = {row.chapter_name: row.chapter_num for row in chapters_query}
17061706
practice_picker.sort(key=lambda d: ids[d["text"]])
17071707

17081708
for ch in chapters_query:
17091709
q_ch_info = {}
17101710
question_picker.append(q_ch_info)
1711-
q_ch_info["text"] = "{}. {}".format(ch.chapter_num, ch.chapter_name)
1711+
q_ch_info["text"] = ch.chapter_name
17121712
q_ch_info["children"] = []
17131713
# Copy the same stuff for reading picker.
17141714
r_ch_info = {}
17151715
reading_picker.append(r_ch_info)
1716-
r_ch_info["text"] = "{}. {}".format(ch.chapter_num, ch.chapter_name)
1716+
r_ch_info["text"] = ch.chapter_name
17171717
r_ch_info["children"] = []
17181718
# practice_questions = db((db.questions.chapter == ch.chapter_label) & \
17191719
# (db.questions.practice == True))
@@ -1725,14 +1725,12 @@ def _get_toc_and_questions():
17251725
# p_ch_info['children'] = []
17261726
# todo: check the chapters attribute to see if its available for readings
17271727
subchapters_query = db(db.sub_chapters.chapter_id == ch.id).select(
1728-
orderby=db.sub_chapters.id
1728+
orderby=[db.sub_chapters.sub_chapter_num, db.sub_chapters.sub_chapter_name]
17291729
)
17301730
for sub_ch in subchapters_query:
17311731
q_sub_ch_info = {}
17321732
q_ch_info["children"].append(q_sub_ch_info)
1733-
q_sub_ch_info["text"] = "{}.{} {}".format(
1734-
ch.chapter_num, sub_ch.sub_chapter_num, sub_ch.sub_chapter_name
1735-
)
1733+
q_sub_ch_info["text"] = sub_ch.sub_chapter_name
17361734
# Make the Exercises sub-chapters easy to access, since user-written problems will be added there.
17371735
if sub_ch.sub_chapter_name == "Exercises":
17381736
q_sub_ch_info["id"] = ch.chapter_name + " Exercises"
@@ -1748,9 +1746,7 @@ def _get_toc_and_questions():
17481746
r_sub_ch_info["id"] = "{}/{}".format(
17491747
ch.chapter_name, sub_ch.sub_chapter_name
17501748
)
1751-
r_sub_ch_info["text"] = "{}.{} {}".format(
1752-
ch.chapter_num, sub_ch.sub_chapter_num, sub_ch.sub_chapter_name
1753-
)
1749+
r_sub_ch_info["text"] = sub_ch.sub_chapter_name
17541750

17551751
author = auth.user.first_name + " " + auth.user.last_name
17561752
questions_query = db(
@@ -1762,8 +1758,12 @@ def _get_toc_and_questions():
17621758
& ((db.questions.author == author) | (db.questions.is_private == "F"))
17631759
).select(orderby=db.questions.id)
17641760
for question in questions_query:
1761+
if question.questions.qnumber:
1762+
qlabel = question.questions.qnumber
1763+
else:
1764+
qlabel = question.questions.name
17651765
q_info = dict(
1766-
text=question.questions.name + _add_q_meta_info(question),
1766+
text=qlabel + _add_q_meta_info(question),
17671767
id=question.questions.name,
17681768
)
17691769
q_sub_ch_info["children"].append(q_info)
@@ -1779,7 +1779,6 @@ def _get_toc_and_questions():
17791779
# This is the place to add meta information about questions for the
17801780
# assignment builder
17811781
def _add_q_meta_info(qrow):
1782-
res = ""
17831782
qt = {
17841783
"mchoice": "Mchoice ✓",
17851784
"clickablearea": "Clickable ✓",
@@ -1796,20 +1795,25 @@ def _add_q_meta_info(qrow):
17961795
"actex": "ActiveCode",
17971796
"fillintheblank": "FillB ✓",
17981797
}
1799-
res += qt.get(qrow.questions.question_type, "")
1798+
qt = qt.get(qrow.questions.question_type, "")
18001799

18011800
if qrow.questions.autograde:
1802-
res += " ✓"
1801+
ag = " ✓"
1802+
else:
1803+
ag = ""
18031804

18041805
if qrow.questions.from_source:
18051806
book = "📘"
18061807
else:
18071808
book = "🏫"
18081809

1809-
if res != "":
1810-
res = """ <span style="color: green">[{} {} ] </span> <span>{}...</span>""".format(
1811-
book, res, qrow.questions.description
1812-
)
1810+
name = qrow.questions.name
1811+
1812+
res = """ <span style="color: green">[{} {} {}
1813+
</span> <span style="color: mediumblue">({})</span>]
1814+
<span>{}...</span>""".format(
1815+
book, qt, ag, name, qrow.questions.description
1816+
)
18131817

18141818
return res
18151819

controllers/books.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,6 @@ def _subchaptoc(course, chap):
300300
& (db.chapters.course_id == course)
301301
& (db.chapters.chapter_label == chap)
302302
).select(
303-
db.chapters.chapter_num,
304-
db.sub_chapters.sub_chapter_num,
305-
db.chapters.chapter_label,
306303
db.sub_chapters.sub_chapter_label,
307304
db.sub_chapters.sub_chapter_name,
308305
orderby=db.sub_chapters.sub_chapter_num,
@@ -311,12 +308,8 @@ def _subchaptoc(course, chap):
311308
)
312309
toclist = []
313310
for row in res:
314-
sc_url = "{}.html".format(row.sub_chapters.sub_chapter_label)
315-
title = "{}.{} {}".format(
316-
row.chapters.chapter_num,
317-
row.sub_chapters.sub_chapter_num,
318-
row.sub_chapters.sub_chapter_name,
319-
)
311+
sc_url = "{}.html".format(row.sub_chapter_label)
312+
title = row.sub_chapter_name
320313
toclist.append(dict(subchap_uri=sc_url, title=title))
321314

322315
return toclist

tests/conftest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ def validate(
504504
# The expected status code from the request.
505505
expected_status=200,
506506
# All additional keyword arguments are passed to the ``post`` method.
507-
**kwargs
507+
**kwargs,
508508
):
509509

510510
try:
@@ -573,7 +573,6 @@ def validate(
573573
with open(traceback_file, "wb") as f:
574574
f.write(_html_prep(admin_client.text))
575575
print("Traceback saved to {}.".format(traceback_file))
576-
print(_html_prep(admin_client.text))
577576
raise
578577

579578
def logout(self):

tests/test_ajax2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ def test_GetLastPage(test_client, test_user_1):
530530
# Now, test a query.
531531
res = ajaxCall(test_client, "getlastpage", **kwargs)
532532
assert res[0]["lastPageUrl"] == "test_chapter_1/subchapter_a.html"
533-
assert res[0]["lastPageChapter"] == "Test chapter 1"
533+
assert "Test chapter 1" in res[0]["lastPageChapter"]
534534

535535

536536
def test_GetTop10Answers(test_client, test_user_1, test_user):

tests/test_autograder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,15 @@ def test_reading(
222222

223223
my_ass = test_assignment("reading_test", test_user_1.course)
224224
my_ass.addq_to_assignment(
225-
question="Test chapter 1/Subchapter A",
225+
question="1. Test chapter 1/1.1 Subchapter A",
226226
points=10,
227227
which_to_grade="best_answer",
228228
autograde="interact",
229229
reading_assignment=True,
230230
activities_required=1,
231231
)
232232
my_ass.addq_to_assignment(
233-
question="Test chapter 1/Subchapter B",
233+
question="1. Test chapter 1/1.2 Subchapter B",
234234
points=10,
235235
which_to_grade="best_answer",
236236
autograde="interact",

tests/test_server.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,8 @@ def test_instructor_practice_admin(test_client, runestone_db_tools, test_user):
764764

765765
# The reason I'm manually stringifying the list value is that test_client.post does something strange with compound objects instead of passing them to json.dumps.
766766
test_client.post(
767-
"admin/add_practice_items", data={"data": '["Test chapter 1/Subchapter B"]'}
767+
"admin/add_practice_items",
768+
data={"data": '["1. Test chapter 1/1.2 Subchapter B"]'},
768769
)
769770

770771
practice_settings_1 = (
@@ -986,11 +987,11 @@ def __eq__(self, other):
986987
"Given name",
987988
"e-mail",
988989
"avg grade (%)",
989-
"Q-7",
990-
"Q-4",
991-
"Q-3",
992-
"Q-1",
993-
"Q-2",
990+
"1",
991+
"1",
992+
"1",
993+
"2.1",
994+
"2",
994995
],
995996
"data": [
996997
[

0 commit comments

Comments
 (0)