diff --git a/course/staff_views.py b/course/staff_views.py index a7296f160..8511e084e 100644 --- a/course/staff_views.py +++ b/course/staff_views.py @@ -28,7 +28,7 @@ def format_group(group: StudentGroup, pseudonymized: bool): if pseudonymized: for member in group.members.all(): - format_user(member.user, True) + format_user(member.user, True, member) return group @@ -71,7 +71,7 @@ def _get_students_with_tags(self) -> List[Dict[str, Any]]: participants = ci.all_students.prefetch_tags(ci) data = [] for participant in participants: - format_user(participant.user, self.pseudonymize) + format_user(participant.user, self.pseudonymize, participant) user_id = participant.user.id user_tags = CachedStudent(ci, participant.user).data user_tags_html = ' '.join(tags[slug].html_label for slug in user_tags['tag_slugs'] if slug in tags) @@ -124,7 +124,7 @@ def get_resource_objects(self): ) else: group = StudentGroup(course_instance=self.instance) - self.group = format_group(group, self.pseudonymize) + self.group = group def get_form_kwargs(self): kwargs = super().get_form_kwargs() diff --git a/course/templates/course/_course_menu.html b/course/templates/course/_course_menu.html index 2e11118f7..6857390b3 100644 --- a/course/templates/course/_course_menu.html +++ b/course/templates/course/_course_menu.html @@ -202,6 +202,19 @@

{% translate "COURSE_STAFF" %}

{% translate "SUBMISSION_DEVIATIONS" %} + + + {% endif %} {% for group in course_menu.staff_link_groups %} diff --git a/deviations/viewbase.py b/deviations/viewbase.py index daddb2351..d7d608499 100644 --- a/deviations/viewbase.py +++ b/deviations/viewbase.py @@ -284,7 +284,7 @@ def get_deviation_groups( lambda obj: (obj.submitter, obj.exercise.course_module), ) for (submitter, module), deviations_iter in deviation_groups: - format_user(submitter.user, pseudonymize) + format_user(submitter.user, pseudonymize, submitter) deviations = list(deviations_iter) can_group = True show_granter = True diff --git a/exercise/staff_views.py b/exercise/staff_views.py index 62591798e..0942685b7 100644 --- a/exercise/staff_views.py +++ b/exercise/staff_views.py @@ -52,7 +52,8 @@ def format_submission(submission: Submission, pseudonymized: bool): if pseudonymized: for submitter in submission.submitters.all(): - submitter.user = format_user(submitter.user, pseudonymized=True) + pseudo = True + format_user(submitter.user, pseudo, submitter) return submission @@ -76,6 +77,7 @@ def get_common_objects(self) -> None: ) for submission in qs: format_submission(submission, self.pseudonymize) + print(submission.submitters) self.all = self.request.GET.get('all', None) self.all_url = self.exercise.get_submission_list_url() + "?all=yes" self.submissions = qs if self.all else qs[:self.default_limit] @@ -127,7 +129,8 @@ def get_common_objects(self) -> None: ) if self.pseudonymize: for profile in profiles.values(): - format_user(profile.user, pseudonymized=True) + pseudo = True + format_user(profile.user, pseudo, profile) # Add UserProfile instances to the dicts in submitter_summaries, so we can # use the 'profiles' template tag. for submitter_summary in submitter_summaries: @@ -173,7 +176,7 @@ class InspectSubmissionView(SubmissionBaseView, BaseFormView): def get_common_objects(self) -> None: super().get_common_objects() self.files = list(self.submission.files.all()) - + self.pseudonymize = self.request.session.get('pseudonymize', False) self.lowest_visible_index = self.index - 10 self.highest_visible_index = self.index + 10 @@ -184,7 +187,7 @@ def get_common_objects(self) -> None: self.not_best = False self.not_last = False for submission in self.submissions: - format_submission(submission, self.pseudonymize) + format_submission(self.submission, self.pseudonymize) if submission.id != self.submission.id: if submission.force_exercise_points: self.not_final = True @@ -407,8 +410,9 @@ def get_common_objects(self): super().get_common_objects() self.tags = [USERTAG_INTERNAL, USERTAG_EXTERNAL] self.tags.extend(self.instance.usertags.all()) + self.pseudonymize = self.request.session.get("pseudonymize", False) self.note( - 'tags', + 'tags', 'pseudonymize', ) @@ -421,8 +425,9 @@ def get_common_objects(self): self.tags = list(self.instance.usertags.all()) self.internal_user_label = settings_text('INTERNAL_USER_LABEL') self.external_user_label = settings_text('EXTERNAL_USER_LABEL') + self.pseudonymize = self.request.session.get("pseudonymize", False) self.note( - 'tags', 'internal_user_label', 'external_user_label', + 'tags', 'internal_user_label', 'external_user_label', 'pseudonymize', ) @@ -442,7 +447,7 @@ def get_resource_objects(self): User, id=self.kwargs[self.user_kw], ) - self.student = format_user(student, self.pseudonymize) + self.student = format_user(student, self.pseudonymize, student.userprofile) self.note('student') def get_common_objects(self): diff --git a/exercise/templates/exercise/_submission_info.html b/exercise/templates/exercise/_submission_info.html index b21b2148c..18d9d0606 100644 --- a/exercise/templates/exercise/_submission_info.html +++ b/exercise/templates/exercise/_submission_info.html @@ -33,14 +33,18 @@

{% translate "SUBMISSION_INFO" %}

{% translate "SUBMITTERS" %}
- {% if is_course_staff %} - {% if is_teacher %} - - - {% endif %} - {% profiles submission.submitters.all instance is_teacher %} + {% if not pseudonymize %} + {% if is_course_staff %} + {% if is_teacher %} + + + {% endif %} + {% profiles submission.submitters.all instance is_teacher %} + {% else %} + {{ submission.submitters.all|names }} + {% endif %} {% else %} - {{ submission.submitters.all|names }} + Somebody {% endif %}
diff --git a/exercise/templates/exercise/staff/_assessment_panel.html b/exercise/templates/exercise/staff/_assessment_panel.html index 980e9788b..f64b2bb22 100644 --- a/exercise/templates/exercise/staff/_assessment_panel.html +++ b/exercise/templates/exercise/staff/_assessment_panel.html @@ -10,9 +10,15 @@
{% if submission.grader %} - {% blocktranslate trimmed with user=submission.grader.user.get_full_name time=submission.grading_time %} - ASSESSED_BY -- {{ user }}, {{ time }} - {% endblocktranslate %} + {% if not pseudonymize %} + {% blocktranslate trimmed with user=submission.grader.user.get_full_name time=submission.grading_time %} + ASSESSED_BY -- {{ user }}, {{ time }} + {% endblocktranslate %} + {% else %} + {% blocktranslate trimmed with user="Somebody" time=submission.grading_time %} + ASSESSED_BY -- {{ user }}, {{ time }} + {% endblocktranslate %} + {% endif %} {% else %} {% translate 'NOT_ASSESSED_MANUALLY' %} diff --git a/exercise/templates/exercise/staff/analytics.html b/exercise/templates/exercise/staff/analytics.html index 79305e663..606814faf 100644 --- a/exercise/templates/exercise/staff/analytics.html +++ b/exercise/templates/exercise/staff/analytics.html @@ -12,6 +12,12 @@ {% endblock %} {% block columns %} +{% if pseudonymize %} +
+ {% translate "PSEUDONYMIZATION_ERROR_MSG" %} +
+{% endif %} +