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

Commit 856460a

Browse files
authored
Merge pull request #1475 from RunestoneInteractive/revert-1472-at_show_exception
Revert "Fix: Provide an error report when the assignment table raises an exception"
2 parents 7e169b5 + 3b0917d commit 856460a

File tree

4 files changed

+24
-90
lines changed

4 files changed

+24
-90
lines changed

modules/questions_report.py

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,15 @@ def _headers_query(
271271

272272
# **user_id headings query**
273273
## ---------------------------
274+
# The base query for this entire function. It's used to get information about each user_id/div_id combination.
275+
query = (
276+
# Choose seleted questions.
277+
query_questions
278+
# Join them to ``useinfo``.
279+
& (db.questions.name == db.useinfo.div_id)
280+
# Select only questions in the provided course.
281+
& (db.useinfo.course_id == course_name)
282+
)
274283
# Get information about each user_id.
275284
select_args = [db.auth_user.first_name, db.auth_user.last_name, db.auth_user.email]
276285
select_kwargs = dict(orderby=db.auth_user.last_name | db.auth_user.first_name)
@@ -291,33 +300,13 @@ def _headers_query(
291300
[row.first_name, row.last_name, row.email]
292301
)
293302

294-
# Second, find all students who answered a question in this course or receive a grade on a question in the course. Students can later remove themselves from a course, but their answers will still be in the course, hence this part of the query. Likewise, students who aren't logged in but did answer questions aren't enrolled in the course, but should also be included.
303+
# Second, find all students who answered a question in this course. Students can later remove themselves from a course, but their answers will still be in the course, hence this part of the query. Likewise, students who aren't logged in but did answer questions aren't enrolled in the course, but should also be included.
295304
for row in db(
296-
# Choose selected questions.
297-
query_questions
298-
& (
299-
(
300-
# Look for all students that answered any of these questions.
301-
#
302-
# Join these questions to ``useinfo``.
303-
(db.questions.name == db.useinfo.div_id)
304-
# Select only questions in the provided course.
305-
& (db.useinfo.course_id == course_name)
306-
)
307-
| (
308-
# Look for all students that received a grade on any of these questions.
309-
(db.questions.name == db.question_grades.div_id)
310-
& (db.question_grades.course_name == course_name)
311-
)
312-
)
305+
query
313306
# Remove any students produced by the previous query.
314307
& ~db.useinfo.sid.belongs(db(enrolled_students)._select(db.auth_user.username))
315-
& ~db.question_grades.sid.belongs(
316-
db(enrolled_students)._select(db.auth_user.username)
317-
)
318308
).select(
319309
db.useinfo.sid,
320-
db.question_grades.sid,
321310
*select_args,
322311
# Get the associated ``auth_user`` record if possible.
323312
left=(db.auth_user.on(db.useinfo.sid == db.auth_user.username),),
@@ -326,23 +315,13 @@ def _headers_query(
326315
**select_kwargs
327316
):
328317

329-
# Pick whichever user id is present.
330-
user_id = row.useinfo.sid or row.question_grades.sid
318+
user_id = row.useinfo.sid
331319
assert user_id not in grades
332320
grades[user_id] = dict()
333321
grades[user_id][None] = _UserInfo._make(
334322
[row.auth_user.first_name, row.auth_user.last_name, row.auth_user.email]
335323
)
336324

337-
# Return a query used to get information about each user_id/div_id combination.
338-
query = (
339-
# Choose selected questions.
340-
query_questions
341-
# Join them to ``useinfo``.
342-
& (db.questions.name == db.useinfo.div_id)
343-
# Select only questions in the provided course.
344-
& (db.useinfo.course_id == course_name)
345-
)
346325
return grades, query
347326

348327

static/js/assignment_table.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,6 @@ function populateAssignmentTable() {
146146
report_type: $("#gradingoption1").val(),
147147
chap_or_assign: $("#chaporassignselector").val(),
148148
}, (data) => {
149-
// Check for errors.
150-
if ("errors" in data) {
151-
$("#assignment_info_table_loading").html(`Error<br/>Please report this error: ${escapeHTML(data.errors)}`);
152-
return;
153-
}
154-
155149
// Recreate more helpful data structures from the "flattened" data.
156150
data.orig_data.forEach(
157151
(user_id_row, user_id_index) => user_id_row.forEach((div_id_entry, div_id_index) => {

tests/conftest.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -762,16 +762,6 @@ def hsblog(self, **kwargs):
762762
# Post to the server.
763763
return json.loads(self.test_client.validate("ajax/hsblog", data=kwargs))
764764

765-
def coursechooser(self, course_name):
766-
html = self.test_client.validate("default/coursechooser/{}".format(course_name))
767-
# Make sure this didn't send us to the user profile page to add a course we aren't registered for.
768-
assert "Course IDs for open courses" not in html
769-
770-
def removecourse(self, course_name):
771-
html = self.test_client.validate("default/removecourse/{}".format(course_name))
772-
assert "Sorry, you cannot remove" not in html
773-
assert "Course Selection" in html
774-
775765

776766
# Present ``_TestUser`` as a fixture.
777767
@pytest.fixture

tests/test_server.py

Lines changed: 12 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ def test_grades_1(runestone_db_tools, test_user, tmp_path):
828828
test_user(
829829
"test_user_{}".format(index), "x", course, last_name="user_{}".format(index)
830830
)
831-
for index in range(4)
831+
for index in range(3)
832832
]
833833

834834
def assert_passing(index, *args, **kwargs):
@@ -850,10 +850,10 @@ def assert_passing(index, *args, **kwargs):
850850
unittest_kwargs = dict(event="unittest", div_id="units2", course=course_name)
851851

852852
# *User 0*: no data supplied
853-
##----------------------------
853+
# ----------------------------
854854

855855
# *User 1*: correct answers
856-
##---------------------------
856+
# ---------------------------
857857
# It doesn't matter which user logs out, since all three users share the same client.
858858
logout = test_user_array[2].test_client.logout
859859
logout()
@@ -867,7 +867,7 @@ def assert_passing(index, *args, **kwargs):
867867
assert_passing(1, act="percent:100:passed:2:failed:0", **unittest_kwargs)
868868

869869
# *User 2*: incorrect answers
870-
##----------------------------
870+
# ----------------------------
871871
logout()
872872
test_user_array[2].login()
873873
# Add three shortanswer answers, to make sure the number of attempts is correctly recorded.
@@ -880,12 +880,8 @@ def assert_passing(index, *args, **kwargs):
880880
)
881881
assert_passing(2, act="percent:50:passed:1:failed:1", **unittest_kwargs)
882882

883-
# *User 3*: no data supplied, and no longer in course.
884-
##----------------------------------------------------
885-
# Wait until the autograder is run to remove the student, so they will have a grade but not have any submissions.
886-
887883
# **Test the grades_report endpoint**
888-
##====================================
884+
# ====================================
889885
tu = test_user_array[2]
890886

891887
def grades_report(assignment, *args, **kwargs):
@@ -938,22 +934,8 @@ def add_to_assignment(question_kwargs, points):
938934
tu.test_client.validate("assignments/calculate_totals", **assignment_kwargs)
939935
)["success"]
940936

941-
# Remove test user 3 from the course. They can't be removed from the current course, so create a new one then add this user to it.
942-
logout()
943-
tu = test_user_array[3]
944-
tu.login()
945-
new_course = runestone_db_tools.create_course("random_course_name")
946-
tu.update_profile(course_name=new_course.course_name, is_free=True)
947-
tu.coursechooser(new_course.course_name)
948-
tu.removecourse(course_name)
949-
950937
# **Test this assignment.**
951938
# ===========================
952-
# Log back in as the instructor.
953-
logout()
954-
tu = test_user_array[2]
955-
tu.login()
956-
# Now, we can get the report.
957939
grades = json.loads(grades_report(assignment_name))
958940

959941
# Define a regex string comparison.
@@ -1035,20 +1017,18 @@ def __eq__(self, other):
10351017
["test_user_0", "user_0", "test", "test_user_0@foo.com", 0.0],
10361018
["test_user_1", "user_1", "test", "test_user_1@foo.com", 1.0],
10371019
["test_user_2", "user_2", "test", "test_user_2@foo.com", 0.2],
1038-
["test_user_3", "user_3", "test", "test_user_3@foo.com", 0.0],
10391020
],
10401021
# Correct since the first 3 questions are all on the index page.
10411022
"mergeCells": [{"col": 5, "colspan": 3, "row": 1, "rowspan": 1}],
10421023
"orig_data": [
10431024
# User 0: not submitted.
10441025
[
1045-
# The format is:
1046-
# ``[timestamp, score, answer, correct, num_attempts]``.
1047-
[None, 0.0, None, None, None], # shortanswer
1048-
[None, 0.0, None, None, None], # fillintheblank
1049-
[None, 0.0, None, None, None], # mchoice
1050-
[None, 0.0, {}, None, None], # lp_build
1051-
[None, 0.0, "", None, None], # activecode
1026+
# The format is: ``[timestamp, score, answer, correct, num_attempts]``.
1027+
[None, 0.0, None, None, None],
1028+
[None, 0.0, None, None, None],
1029+
[None, 0.0, None, None, None],
1030+
[None, 0.0, {}, None, None],
1031+
[None, 0.0, "", None, None],
10521032
],
10531033
# User 1: all correct.
10541034
[
@@ -1089,19 +1069,10 @@ def __eq__(self, other):
10891069
],
10901070
[AlmostNow(), 2.0, "percent:50:passed:1:failed:1", False, 1],
10911071
],
1092-
# User 3: not submitted.
1093-
[
1094-
# The format is:
1095-
[None, 0.0, None, None, None],
1096-
[None, 0.0, None, None, None],
1097-
[None, 0.0, None, None, None],
1098-
[None, 0.0, {}, None, None],
1099-
[None, 0.0, "", None, None],
1100-
],
11011072
],
11021073
}
11031074

1104-
# Note: on test failure, pytest will report as incorrect all the ``AlmostNow()`` and ``RegexEquals`` items, even though they may have actually compared as equal.
1075+
# Note: on test failure, pytest will report as incorrect all the ``AlmostNow()`` and ``RegexEquals`` items, even though they make have actually compared as equal.
11051076
assert grades == expected_grades
11061077

11071078
logout()

0 commit comments

Comments
 (0)