RunestoneComponents icon indicating copy to clipboard operation
RunestoneComponents copied to clipboard

Can't add problems from other books to an assignment

Open debbieyuster opened this issue 3 years ago • 8 comments

Course: derived from FOPP Username: debbieyuster

In the Assignments editor (in my FOPP-like course), upon searching for problems from another book (ThinkCSPy), I can locate a problem (for example, lhs_16_7) using the Search interface, but the Add to Assignment button does not actually add the problem to the assignment. The Add to Assignment button does not appear to do anything. Here's the Javascript message:

Uncaught (in promise) 
{…}
​
abort: function abort(a)
​
always: function always()
​
complete: function add()
​
done: function add()
​
error: function add()
​
fail: function add()
​
getAllResponseHeaders: function getAllResponseHeaders()
​
getResponseHeader: function getResponseHeader(a)
​
overrideMimeType: function overrideMimeType(a)
​
pipe: function then()
​
progress: function add()
​
promise: function promise(a)
​
readyState: 4
​
responseText: "<!DOCTYPE html>\n<html lang=\"en\">\n    <head>\n        <title>\n            Assignments\n        </title>\n        <meta charset='utf-8'>\n        <meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>\n        <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>\n        <meta name=\"apple-mobile-web-app-capable\" content=\"yes\">\n        <meta name=\"description\" content=\"Learning Python should be fun and easy.  We provide an interactive Python textbook that helps you learn to program in Python right in your browser.\">\n        <link href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css\" rel=\"stylesheet\" integrity=\"sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u\" crossorigin=\"anonymous\">\n        <link rel=\"stylesheet\" type=\"text/css\" href=\"/runestone/static/bootstrap-sphinx.css\" />\n        <link rel=\"stylesheet\" type=\"text/css\" href=\"/runestone/static/runestone-custom-sphinx-bootstrap.css\" />\n        <link rel=…"
​
setRequestHeader: function setRequestHeader(a, b)
​
state: function state()
​
status: 200
​
statusCode: function statusCode(a)
​
statusText: "OK"
​
success: function add()
​
then: function then()
​
<prototype>: Object { … }
admin.js:1947:18
    addToAssignment https://runestone.academy/runestone/static/js/admin.js?v=1613836660:1947
    AsyncFunctionThrow self-hosted:694
    (Async: async)
    onclick https://runestone.academy/runestone/admin/assignments:1

debbieyuster avatar Mar 23 '21 15:03 debbieyuster

Notes for Fixing

A quick investigation shows that_get_question_id in admin.py uses the instructors current base_course when trying to retrieve the question from the database for adding to the assignment.

Since it is the (name, base_course) that are the unique id for each question the search function in the UI should send along the base_course for the question when trying to add it to the assignment. OR else just use the numeric index for the question?

bnmnetp avatar Mar 24 '21 14:03 bnmnetp

I like the (div_id: str, base_course: str) tuple idea!

bjones1 avatar Mar 25 '21 09:03 bjones1

Can you say more about why you like that?

I am going down the path of the id at the moment. But this seemingly simple change has very long tentacles.

Not only does it effect _get_question_id but also add__or_update_assignment_question and doAssignment and I suspect some of the autograder code but I haven't got that far yet. For the most part the majority of that code uses the question id as that is what is already stored in the assignment_questions table.

bnmnetp avatar Mar 25 '21 14:03 bnmnetp

Ouch. The code was probably written assuming that questions always come from the current course. As you say, there's a LOT of code that makes this assumption. What places in the UI do we allow pulling questions from other courses? Perhaps we want to limit this until we have a better handle on what the fix will require?

I think I misunderstood which id you were referring to -- this sounds like the id from the database; I'd assumed you meant the numeric index of the question in the client-side UI. I'm quite happy with the database id instead of (div_id, base_course).

bjones1 avatar Mar 25 '21 15:03 bjones1

Its funny how some parts of the code come back to haunt you over and over again.... a few years ago I merged a PR from paul to allow us to make a link from the assignment page to that "Question in Context" that change has caused more problems than I ever imagined... as we have moved from static courses to dynamic courses to forcing every chapter to have an Exercises subchapter, to mysteriously missing questions in an assignment.... and now easing the restriction on selecting a question from another book. In the end the solution is going to be much simpler than the query I merged years ago.

This is a feature I promised to Barb, and is required for having an independent question bank, and is requested more and more from instructors who want to mix and match content from multiple books.

I'm pretty confident I'm on the right path here and its not going to be too bad in the end. I'll submit a PR (maybe today) on this so you can look over the changes.

bnmnetp avatar Mar 25 '21 15:03 bnmnetp

A related issue: I am sometimes able to add problems from other books (for example, I added problems from On Complexity to my FOPP-based course). They work, temporarily (but can't be autograded). Coming back later, the source for the problems is not found - unless you search for the problems in the Assignment Editor, and then the source code appears again in the problem list. In any case, the problem is that I'm unable to delete these problems from an assignment. They appear to go away when I X them out and save the assignment, but upon navigating away and then back, the phantom deleted problems have returned. Seems this only happens with problems that were added from other books.

debbieyuster avatar Apr 13 '21 21:04 debbieyuster

@debbieyuster I just merged my changes over the weekend to make it possible for you to really use questions from other books. This was not designed into Runestone from the beginning. I tested that the autograding was working. So if this is very recent experience (today or yesterday) please give me some more specifics so I can investigate further. Feel free to DM me on Slack.

bnmnetp avatar Apr 13 '21 21:04 bnmnetp

See also #1023

We will get this working reliably this summer.

bnmnetp avatar Jun 07 '21 15:06 bnmnetp