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

Add refetch button to assignment list #1930

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

KrKOo
Copy link

@KrKOo KrKOo commented Oct 15, 2024

This PR adds a "Refetch" button to the student's assignment list. This allows the student to reset any assignment files to their original version in case they got bricked by the student. Until now, this was possible only using the terminal, which might not be intuitive for some students.

If a student wants to reset a file to its original version, he deletes it and clicks the "Refetch" button. The missing files will be downloaded.

Copy link
Contributor

Binder 👈 Launch a Binder on branch KrKOo/nbgrader/refetch

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';
Copy link
Contributor

Choose a reason for hiding this comment

The 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")?

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Author

Choose a reason for hiding this comment

The 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 ExchangeList.list_files(), but in the default exchange, it is implemented in a weird way, where it does not really list any files. Instead, it returns a list of assignments. So it sure can be done by modifying the exchange a bit, but people can already rely on the way it works now so then it would break their stuff. Someone can even have their own exchange implementation, and since the output of list_files() is not unified, I think, it will not work for everyone.

Do you have any better idea regarding this?

Copy link
Contributor

Choose a reason for hiding this comment

The 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!

Copy link
Contributor

@brichet brichet left a comment

Choose a reason for hiding this comment

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

Thanks @KrKOo for working on it.

I agree with @lahwaacz that it could be nice to disable the button if not needed, but understand that it is not easy at the time. Let's keep it for an other PR.

I have some comments below, and also wonder if we can add some tests on this new feature. I can help on it if necessary.

@@ -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');
Copy link
Contributor

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 and btn-primary.

Comment on lines +298 to +299
refetchButton.setAttribute('data-bs-toggle', 'tooltip');
refetchButton.setAttribute('data-bs-placement', 'top');
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this required ?

refetchButton.classList.add('btn', 'btn-danger', 'btn-xs');
refetchButton.setAttribute('data-bs-toggle', 'tooltip');
refetchButton.setAttribute('data-bs-placement', 'top');
refetchButton.setAttribute('style', 'background:#d43f3a; margin-left:5px');
Copy link
Contributor

Choose a reason for hiding this comment

The 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:

  • an orange background
  • the same font color as the neighbouring button
  • slightly change the background color on hover

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants