-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable canvas assignment creation API #3126
Conversation
c94965d
to
ff0ba9a
Compare
646d00e
to
c6bc581
Compare
ff0ba9a
to
664de4a
Compare
c6bc581
to
6d9499e
Compare
setExtLTIAssignmentId(assignment.ext_lti_assignment_id); | ||
} | ||
|
||
if (content && createAssignmentAPI && !extLTIAssignmentId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ony call the API if:
- Content already selected
- API enabled the config
- And we don't have already called it
664de4a
to
1858755
Compare
057dae5
to
48a4c00
Compare
@@ -94,13 +98,39 @@ export default function FilePickerApp({ onSubmit }) { | |||
// Submit the form after a selection is made via one of the available | |||
// methods. | |||
useEffect(() => { | |||
async function createAssignment() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be defined outside as a const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do, although you'd need to use useCallback to help Preact keep track of the effect's dependencies. This is fine for the moment.
|
||
data.content = content; | ||
data.groupset = groupConfig.groupSet; | ||
const assignment = await apiCall({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't have an expected error response, eg a re-authorization.
Should I then try/catch it? If that's the case how can I show a generic, something went wrong message? (or something more usefull, but this case would likely be a bug).
Should I have boolean creatingAssignment
or similar between this an getting the answer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I then try/catch it? If that's the case how can I show a generic, something went wrong message? (or something more usefull, but this case would likely be a bug).
Yes. There is an existing errorInfo
state in this component that shows a dialog when set. We can probably re-use that here.
Should I have boolean creatingAssignment or similar between this an getting the answer?
Does this call involve any calls to potentially slow third-party APIs or does all the work happen in our app. If the former, we probably should add a loading state. If the latter, it may be less important.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -13,6 +13,7 @@ import { contentItemForContent } from '../utils/content-item'; | |||
* @prop {Record<string,string>} formFields - Form fields provided by the backend | |||
* that should be included in the response without any changes | |||
* @prop {string|null} groupSet | |||
* @prop {string|null} extLTIAssignmentId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a good piece documentation somewhere in the backend code about what this parameter means?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's not super explicit block of docs just for this but it can followed from the schema:
Line 99 in 4e26002
"""Canvas only assignment unique identifier""" |
to the API view itself:
lms/lms/views/api/assignments.py
Line 22 in 4e26002
def create(self): |
and in more detail on the comments on .get
here https://github.com/hypothesis/lms/blob/4e26002eeba952c96d5edcd4d5314399b07cf1c6/lms/services/assignment.py
1858755
to
c673079
Compare
d1f91f9
to
196834c
Compare
ddb9809
to
77c645d
Compare
196834c
to
d46b786
Compare
77c645d
to
a225cb2
Compare
74cd9ee
to
7b0e418
Compare
d46b786
to
9bcc06f
Compare
667b97b
to
a0612b0
Compare
a519fc7
to
3509a59
Compare
selectContent(wrapper, 'https://example.com'); | ||
|
||
await waitFor(() => fakeAPICall.called); | ||
await delay(100); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the last change since you last looked at it @robertknight
Not sure if necessary of a symptom of something else that's missing/wrong.
2b4b787
to
6565127
Compare
6565127
to
45ebf2b
Compare
Create and edit assignments by first calling the API endpoint and then submit the assignment to the LMS.
c68e341
to
cdb1992
Compare
Until canvas assignment are stored on the DB on creation/editing this view will only handle launches of already present in the DB canvas file assignments (regular and SpeedGrader launches).
This is the final piece needed for storing all canvas assignments on the DB using the assigments.create endpoint merged already.
Here, the frontend will use this API if the backend provided the details only when creating/editing assignments.
Testing notes
Check already configured (in canvas) assignments can get launched
delete from module_item_configurations ;
unless you want to keep some of your db assignmentsEdit existing assignments
Edit https://hypothesis.instructure.com/courses/125/assignments/1513 ( https://en.wikipedia.org/wiki/Margaret_(singer))
New record will show up on the DB ( no
resource_link_id
)Launch it,
resource_link_id
will be filled now.Edit https://hypothesis.instructure.com/courses/125/assignments/875 with a canvas file
New record will show up on the DB ( no
resource_link_id
) (note that this is a duplicate of another already exiting assignment. One will have aresource_link_id
, the newest will have onlyext_lti_assignment_id
Launch it. The record with only
resource_link_id
will get deleted and the new one will have all information completed.Create new assignments
resource_link_id
on launch.