Skip to content
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

Merged
merged 6 commits into from
Nov 15, 2021

Conversation

marcospri
Copy link
Member

@marcospri marcospri commented Sep 20, 2021

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

Edit existing assignments

Create new assignments

  • Create new assignments and launch them for both URL and canvas file. New row on creating, filled with resource_link_id on launch.

@marcospri marcospri force-pushed the ext_lti_assignment_id-column-config branch from c94965d to ff0ba9a Compare September 20, 2021 05:44
@marcospri marcospri force-pushed the ext_lti_assignment_id-column-frontend branch from 646d00e to c6bc581 Compare September 20, 2021 05:53
@marcospri marcospri force-pushed the ext_lti_assignment_id-column-config branch from ff0ba9a to 664de4a Compare September 20, 2021 08:19
@marcospri marcospri force-pushed the ext_lti_assignment_id-column-frontend branch from c6bc581 to 6d9499e Compare September 20, 2021 08:27
@marcospri marcospri linked an issue Sep 20, 2021 that may be closed by this pull request
setExtLTIAssignmentId(assignment.ext_lti_assignment_id);
}

if (content && createAssignmentAPI && !extLTIAssignmentId) {
Copy link
Member Author

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

@marcospri marcospri force-pushed the ext_lti_assignment_id-column-config branch from 664de4a to 1858755 Compare September 20, 2021 13:01
@marcospri marcospri force-pushed the ext_lti_assignment_id-column-frontend branch 2 times, most recently from 057dae5 to 48a4c00 Compare September 20, 2021 13:37
@@ -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() {
Copy link
Member Author

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?

Copy link
Member

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({
Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a try and used errorInfo. This is how the UI looks:

Screenshot from 2021-09-23 15-07-43

@marcospri marcospri marked this pull request as ready for review September 20, 2021 13:42
@@ -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
Copy link
Member

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?

Copy link
Member Author

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:

"""Canvas only assignment unique identifier"""

to the API view itself:

def create(self):

and in more detail on the comments on .get here https://github.com/hypothesis/lms/blob/4e26002eeba952c96d5edcd4d5314399b07cf1c6/lms/services/assignment.py

@marcospri marcospri force-pushed the ext_lti_assignment_id-column-config branch from 1858755 to c673079 Compare September 23, 2021 10:40
@marcospri marcospri force-pushed the ext_lti_assignment_id-column-frontend branch 4 times, most recently from d1f91f9 to 196834c Compare September 23, 2021 13:31
@marcospri marcospri force-pushed the ext_lti_assignment_id-column-config branch from ddb9809 to 77c645d Compare September 27, 2021 15:23
@marcospri marcospri force-pushed the ext_lti_assignment_id-column-frontend branch from 196834c to d46b786 Compare September 27, 2021 15:25
@marcospri marcospri force-pushed the ext_lti_assignment_id-column-config branch from 77c645d to a225cb2 Compare September 28, 2021 12:49
Base automatically changed from ext_lti_assignment_id-column-config to ext_lti_assignment_id-column-view September 28, 2021 12:49
@marcospri marcospri force-pushed the ext_lti_assignment_id-column-view branch 3 times, most recently from 74cd9ee to 7b0e418 Compare September 28, 2021 12:57
@marcospri marcospri force-pushed the ext_lti_assignment_id-column-frontend branch from d46b786 to 9bcc06f Compare September 28, 2021 14:18
@marcospri marcospri changed the base branch from ext_lti_assignment_id-column-view to ext_lti_assignment_id-column-launches September 28, 2021 14:18
@marcospri marcospri force-pushed the ext_lti_assignment_id-column-launches branch from 667b97b to a0612b0 Compare September 29, 2021 09:41
selectContent(wrapper, 'https://example.com');

await waitFor(() => fakeAPICall.called);
await delay(100);
Copy link
Member Author

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.

@marcospri marcospri changed the base branch from master to use-new-canvas-view November 4, 2021 15:46
@marcospri marcospri force-pushed the ext_lti_assignment_id-column-frontend branch from 2b4b787 to 6565127 Compare November 5, 2021 09:06
Base automatically changed from use-new-canvas-view to master November 9, 2021 09:50
@marcospri marcospri force-pushed the ext_lti_assignment_id-column-frontend branch from 6565127 to 45ebf2b Compare November 9, 2021 12:07
Create and edit assignments by first calling the API endpoint and then
submit the assignment to the LMS.
@marcospri marcospri force-pushed the ext_lti_assignment_id-column-frontend branch 2 times, most recently from c68e341 to cdb1992 Compare November 9, 2021 12:10
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).
@marcospri marcospri changed the title Ext lti assignment id column frontend Enable canvas assignment creation API Nov 15, 2021
@marcospri marcospri merged commit 0d95d5b into master Nov 15, 2021
@marcospri marcospri deleted the ext_lti_assignment_id-column-frontend branch November 15, 2021 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move Canvas assignments into the DB
3 participants