-
Notifications
You must be signed in to change notification settings - Fork 79
Add submision conversion feature for individual submission and by module #991
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 submision conversion feature for individual submission and by module #991
Conversation
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.
Here are some comments from me.
The commit log message could be a bit more verbose in my mind. "Submission conversion feature" is not so clear if you do not know what this relates to. After a short title line, perhaps sentence or two to clarify what the feature does would be useful. You could also add reference to the issue: "Closes #892", to link the commit with the original issue (and automatically close it).
Could you write short step-by-step instructions, for example as a follow-up comment in this pull request feed, on how to test this feature? (See recent discussion on EDIT Teams channel about improving our documentation on testing)
| A POST-only view that updates a student's late or unofficial submission | ||
| to normal submission. Changed the status and remove the penalty | ||
| """ | ||
| def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: |
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 this missing access_mode = ACCESS.ASSISTANT?
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.
Well, i'm not sure, but if you think i should add that then i could do that
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.
Actually, it should be ACCESS.GRADING so that it takes the setting exercise.allow_assistant_grading True/False into account.
|
|
||
| #: exercise/templates/exercise/_user_results.html | ||
| msgid "CONVERT_SUBMISSION_BY_MODULE" | ||
| msgstr "Convert Late Submissions in Finnish" |
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.
I can help with Finnish translations, once the terminology is fixed (relating to above comment on English texts)
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.
Yes, thanks for the help
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.
I will add Finnish translations now that I am fixing many details in this PR.
7184082 to
0611131
Compare
conversion EDIT-767
0611131 to
d5fec19
Compare
markkuriekkinen
left a comment
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.
Nice work with your first feature!
I will fix the issues in this pull request myself due to time constraints. I commented on some issues below. There are coding style issues, some significant bugs, lacking access control and user interface improvements.
You could have made more unit tests than just a single very simple test.
| @@ -1,4 +1,5 @@ | |||
| from itertools import groupby | |||
| from lib2to3.pytree import convert | |||
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.
Isn't this import unused? Remove this line.
| from django.utils.translation import ugettext_lazy as _, ngettext | ||
| from django.utils import timezone | ||
| from django.utils.dateparse import parse_datetime | ||
| import datetime |
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 correct coding style is to place standard imports (built-in Python modules) before the third-party libraries. You can move import datetime to the top above all other imports.
| def test_submission_late_conversion(self): | ||
| convert_submission_url = self.late_submission.get_url('submission-conversion') | ||
| response = self.client.get(convert_submission_url) | ||
| self.assertEqual(response.status_code, 302) | ||
| self.assertTrue(self.late_submission.late_penalty_applied is None) | ||
|
|
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.
It would make sense to add more tests than just this. For example, there could be unit tests that directly call the method Submission.convert_penalized_submission() without making HTTP requests with self.client.
|
|
||
| {% if module.late_allowed and module.late_percent > 0 %} | ||
|
|
||
| {% endif %} | ||
|
|
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.
Why is this empty if here?
| staff_views.FetchMetadataView.as_view(), | ||
| name="exercise-metadata"), | ||
|
|
||
| url(EDIT_URL_PREFIX+r'convert/module/$', |
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.
| url(EDIT_URL_PREFIX+r'convert/module/$', | |
| url(EDIT_URL_PREFIX + r'convert/module/$', |
| new_date = form_data.get('new_date') | ||
| for submitter in submitters: | ||
| for exercise in exercises: | ||
| submissions = exercise.get_submissions_for_student(submitter, exclude_errors=True) |
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.
These database queries could be made more efficient. Now, this fetches also normal, graded submissions that couldn't be approved. There could be many such submissions, but they are not needed here.
Note that late submissions do not always have any late penalty and thus, it is not enough to check submissions with submission.late_penalty_applied is not None. If the module does not allow late submissions, but the exercise category allows unofficial submissions, then late submissions become unofficial without any late penalty (submission.late_penalty_applied is None).
If the teacher adds deviations to many exercises and students at once, then making database queries separately for each exercise and student pair might be needlessly slow. Making hundreds of database queries for a single HTTP request is never good. It is possible to fetch more data in a single query.
|
|
||
| user_kw = 'user_id' | ||
| module_kw = 'module_id' | ||
| access_mode = ACCESS.ASSISTANT |
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.
We need to also check exercise.allow_assistant_grading separately.
|
|
||
| #getting module and user by id. | ||
| self.module = get_object_or_404( | ||
| CourseModule, |
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.
Bad indentation.
| exercises = BaseExercise.objects.filter(course_module=self.module) | ||
|
|
||
| for exercise in exercises: | ||
| submissions = exercise.get_submissions_for_student(self.student.userprofile, exclude_errors=True) |
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 database queries can be made more efficient. It is not necessary to iterate over all the normal submissions.
Note that if a course module does not allow late submissions, but unofficial submissions are allowed in the exercise category, then late submissions become unofficial without any late penalty. Though, since the user interface has choices "late only" or "unofficial only", then "late only" should imply that it does not pick any unofficial submissions. Note that unofficial submissions may have late penalty set when the module allows late submissions.
|
|
||
| #: exercise/templates/exercise/_user_results.html | ||
| msgid "CONVERT_SUBMISSION_BY_MODULE" | ||
| msgstr "Convert Late Submissions in Finnish" |
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.
I will add Finnish translations now that I am fixing many details in this PR.
Course staff may approve late and/or unofficial submissions so that any point penalties are removed from those submissions and they become normal, graded submissions (with the "ready" status). Single submissions may be approved or all submissions from one student in one assignment or one whole course module. The whole assignment or module approval may also be set to target only late submissions or only unofficial submissions. The user interface for this feature is visible in the inspect submission view when inspecting a late or unofficial submission. Part of apluslms#892. "The first pull request" in the comment: apluslms#892 (comment) This work started in Muhammad's pull request apluslms#991. Markku has refactored the code, improved the database queries and the details overall. Co-authored-by: Muhammad Wahjoe <faiz00.muhammad@gmail.com>
Course staff may approve late and/or unofficial submissions so that any point penalties are removed from those submissions and they become normal, graded submissions (with the "ready" status). Single submissions may be approved or all submissions from one student in one assignment or one whole course module. The whole assignment or module approval may also be set to target only late submissions or only unofficial submissions. The user interface for this feature is visible in the inspect submission view when inspecting a late or unofficial submission. Part of apluslms#892. "The first pull request" in the comment: apluslms#892 (comment) This work started in Muhammad's pull request apluslms#991. Markku has refactored the code, improved the database queries and the details overall. Co-authored-by: Muhammad Wahjoe <faiz00.muhammad@gmail.com>
Course staff may approve late and/or unofficial submissions so that any point penalties are removed from those submissions and they become normal, graded submissions (with the "ready" status). Single submissions may be approved or all submissions from one student in one assignment or one whole course module. The whole assignment or module approval may also be set to target only late submissions or only unofficial submissions. The user interface for this feature is visible in the inspect submission view when inspecting a late or unofficial submission. Part of #892. "The first pull request" in the comment: #892 (comment) This work started in Muhammad's pull request #991. Markku has refactored the code, improved the database queries and the details overall. Co-authored-by: Muhammad Wahjoe <faiz00.muhammad@gmail.com>
TODO: * +1 max submissions deviation button in the inspect submission view: should this also check if any submission should be approved immediately? * test all the changes * deviations/viewbase.py approve_unofficial_submissions(): implementation unfinished * clean up the code * success messages to the user in the user interface? When deviations are added, the teacher may choose to also immediately approve such existing submissions that are covered by the deviation. For example, if the submission was late, but with the new personal deadline it is not late, then it would be approved. Fixes apluslms#892. "The second pull request" in the comment: apluslms#892 (comment) This work started in Muhammad's pull request apluslms#991. Markku has refactored the code, improved the database queries and the details overall. Co-authored-by: Muhammad Wahjoe <faiz00.muhammad@gmail.com>
|
The merged commit 7c65106 implements the basic submission approval in the inspect view: a single submission or all submissions in one assignment or module. Approving when adding deviations is part of the unfinished draft pull request #1029. Closing this PR because it had too many issues. The impoved version is done outside this PR. |
Course staff may approve late and/or unofficial submissions so that any point penalties are removed from those submissions and they become normal, graded submissions (with the "ready" status). Single submissions may be approved or all submissions from one student in one assignment or one whole course module. The whole assignment or module approval may also be set to target only late submissions or only unofficial submissions. The user interface for this feature is visible in the inspect submission view when inspecting a late or unofficial submission. Part of apluslms#892. "The first pull request" in the comment: apluslms#892 (comment) This work started in Muhammad's pull request apluslms#991. Markku has refactored the code, improved the database queries and the details overall. Co-authored-by: Muhammad Wahjoe <faiz00.muhammad@gmail.com>
Late submission conversion
EDIT-767
Description
What?
This feature convert a late submission to a normal submission without late penalty.
Why?
Teaching staff could convert a late submission
How?
Removing late penalties and changing the submission status
Testing
Remember to add or update unit tests for new features and changes.
What type of test did you run?
I test the fature manually and checking wether a late submission was actually converted and get the grade without penalities.
Did you test the changes in
Think of what is affected by these changes and could become broken
Translation
Programming style
Have you updated the README or other relevant documentation?
Is it Done?
Clean up your git commit history before submitting the pull request!