-
Notifications
You must be signed in to change notification settings - Fork 334
Add refetch button to assignment list #1930
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -293,6 +293,36 @@ class Assignment { | |
|
|
||
| } | ||
| } else if (this.data.status == 'fetched') { | ||
| var refetchButton = document.createElement('button'); | ||
| refetchButton.classList.add('btn', 'btn-danger', 'btn-xs'); | ||
| refetchButton.setAttribute('data-bs-toggle', 'tooltip'); | ||
| refetchButton.setAttribute('data-bs-placement', 'top'); | ||
|
Comment on lines
+298
to
+299
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this required ? |
||
| refetchButton.setAttribute('style', 'background:#d43f3a; margin-left:5px'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As said above, the style properties could be in common.css. I would also suggest:
|
||
| refetchButton.setAttribute('title', 'If you broke any of your assignment files and you want to redownload them, delete those files and click this button to refetch the original version of those files.') | ||
| container.append(refetchButton); | ||
|
|
||
| refetchButton.innerText = 'Refetch'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Refetch" is quite ambiguous, somebody might expect that it will overwrite existing files. Can we call it "Fetch missing files" (or "Refetch missing files")?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would also be nice to have the button disabled if no files are actually missing.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, the button can be renamed to "Refetch missing files". The problem with disabling the button is that the Exchange has no API for listing all the files of an assignment. Or well... there is Do you have any better idea regarding this?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, so the API would probably have to be extended with a new function... But it can be done later, this is still a big improvement!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
.... also need to factor in that any plugin exchange systems would need to mimic that functionality..... and I know that our nbexchange service has no list of files in an assignment, just the list of |
||
| refetchButton.onclick = async function(){ | ||
| refetchButton.innerText = 'Refetching...'; | ||
| refetchButton.setAttribute('disabled', 'disabled'); | ||
| const dataToSend = { course_id: that.data['course_id'], assignment_id: that.data['assignment_id']}; | ||
| try { | ||
| const reply = await requestAPI<any>('assignments/fetch_missing', { | ||
| body: JSON.stringify(dataToSend), | ||
| method: 'POST' | ||
| }); | ||
|
|
||
| that.on_refresh(reply); | ||
|
|
||
| } catch (reason) { | ||
| remove_children(container); | ||
| container.innerText = 'Error refetching assignment.'; | ||
| console.error( | ||
| `Error on POST /assignment_list/fetch_missing ${dataToSend}.\n${reason}` | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| button.innerText = "Submit"; | ||
| button.onclick = async function(){ | ||
| button.innerText = 'submitting...'; | ||
|
|
||
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.
The class
btn-dangerdoes not seem to be used.In this case I would call it
btn-warning, since this is not supposed to overwrite anything.And the style of this class could be defined in the common.css file, like
btn-defaultandbtn-primary.