-
Notifications
You must be signed in to change notification settings - Fork 319
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
Add refetch button to assignment list #1930
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
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'); | ||
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'; | ||
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")? 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. 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? 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! |
||
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-danger
does 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-default
andbtn-primary
.