Skip to content

Conversation

@muhammadfaiz12
Copy link
Contributor

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?

  • Accessibility test using the WAVE extension.
  • Django unit tests.
  • Selenium tests.
  • Other test. (Add a description below)
  • Manual testing.

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

  • Chrome
  • Firefox
  • This pull request cannot be tested in the browser.

Think of what is affected by these changes and could become broken

Translation

Programming style

  • Did you follow our style guides?
  • Did you use Python type hinting in all functions that you added or edited? (type hints for function parameters and return values)

Have you updated the README or other relevant documentation?

  • documents inside the doc directory.
  • README.md.
  • Aplus Manual.
  • Other documentation (mention below which documentation).

Is it Done?

  • Reviewer has finished the code review
  • After the review, the developer has made changes accordingly
  • Customer/Teacher has accepted the implementation of the feature

Clean up your git commit history before submitting the pull request!

Copy link
Contributor

@PasiSa PasiSa left a 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:
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 missing access_mode = ACCESS.ASSISTANT?

Copy link
Contributor Author

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

Copy link
Contributor

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"
Copy link
Contributor

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)

Copy link
Contributor Author

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

Copy link
Contributor

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.

@muhammadfaiz12 muhammadfaiz12 force-pushed the feat/grade-conversion branch from 0611131 to d5fec19 Compare March 27, 2022 21:33
Copy link
Contributor

@markkuriekkinen markkuriekkinen left a 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
Copy link
Contributor

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

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.

Comment on lines +575 to +580
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)

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

Comment on lines +88 to +92

{% if module.late_allowed and module.late_percent > 0 %}

{% endif %}

Copy link
Contributor

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/$',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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)
Copy link
Contributor

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

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,
Copy link
Contributor

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

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"
Copy link
Contributor

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.

markkuriekkinen added a commit to markkuriekkinen/a-plus that referenced this pull request May 6, 2022
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>
markkuriekkinen added a commit to markkuriekkinen/a-plus that referenced this pull request May 6, 2022
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>
markkuriekkinen added a commit that referenced this pull request May 6, 2022
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>
markkuriekkinen added a commit to markkuriekkinen/a-plus that referenced this pull request May 6, 2022
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>
@markkuriekkinen
Copy link
Contributor

markkuriekkinen commented May 6, 2022

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.

murhum1 pushed a commit to murhum1/a-plus that referenced this pull request Nov 30, 2022
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Check validity of exercise points after admitting deadline deviation or extra attempts

3 participants