Skip to content

Commit

Permalink
Fix small issues with pseudonymization
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelGusse committed Apr 4, 2024
1 parent fcdb286 commit 75571b8
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 14 deletions.
2 changes: 1 addition & 1 deletion exercise/templates/exercise/_submission_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h4 class="panel-title">{% translate "SUBMISSION_INFO" %}</h4>
{{ submission.submitters.all|names }}
{% endif %}
{% else %}
Somebody
{% translate "PSEUDONYMIZED_SUBMITTERS" %}
{% endif %}
</dd>
</dl>
Expand Down
4 changes: 1 addition & 3 deletions exercise/templates/exercise/staff/_assessment_panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
ASSESSED_BY -- {{ user }}, {{ time }}
{% endblocktranslate %}
{% else %}
{% blocktranslate trimmed with user="Somebody" time=submission.grading_time %}
ASSESSED_BY -- {{ user }}, {{ time }}
{% endblocktranslate %}
{% translate 'ASSESSED_BY' %} -- {% translate 'SOMEBODY' %}, {{ submission.grading_time }}
{% endif %}
{% else %}
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
Expand Down
1 change: 0 additions & 1 deletion external_services/templatetags/external_services.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import string

from django import template

from lib.errors import TagUsageError
Expand Down
24 changes: 18 additions & 6 deletions locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-01-20 17:06+0200\n"
"POT-Creation-Date: 2024-04-04 13:12+0300\n"
"PO-Revision-Date: 2021-05-27 14:47+0300\n"
"Last-Translator: Jimmy Ihalainen <[email protected]>\n"
"Language-Team: English<>\n"
Expand Down Expand Up @@ -1017,11 +1017,6 @@ msgstr "Deadline deviations"
msgid "SUBMISSION_DEVIATIONS"
msgstr "Submission deviations"

#: exercise/templates/exercise/staff/results.html
#: exercise/templates/exercise/staff/analytics.html
msgid "PSEUDONYMIZATION_ERROR_MSG"
msgstr "This view is not available when pseudonymization is enabled!"

#: course/templates/course/_course_menu.html
msgid "UNPSEUDONYMIZE"
msgstr "Depseudonymize"
Expand Down Expand Up @@ -4044,6 +4039,10 @@ msgstr "Submitted on"
msgid "INCLUDES_LATE_PENALTY"
msgstr "Includes late penalty"

#: exercise/templates/exercise/_submission_info.html
msgid "PSEUDONYMIZED_SUBMITTERS"
msgstr "Anonymous submitters"

#: exercise/templates/exercise/_submit_progress.html
#: exercise/templates/exercise/exercise.html
msgid "POSTING_SUBMISSION"
Expand Down Expand Up @@ -4256,6 +4255,14 @@ msgstr "Results"
msgid "ASSESSED_BY -- %(user)s, %(time)s"
msgstr "Assessed by %(user)s, %(time)s"

#: exercise/templates/exercise/staff/_assessment_panel.html
msgid "ASSESSED_BY"
msgstr "Assessed by"

#: exercise/templates/exercise/staff/_assessment_panel.html
msgid "SOMEBODY"
msgstr "Somebody"

#: exercise/templates/exercise/staff/_assessment_panel.html
msgid "NOT_ASSESSED_MANUALLY"
msgstr "Not assessed manually"
Expand Down Expand Up @@ -4481,6 +4488,11 @@ msgstr "Latest submission time"
msgid "NO_SUBMITTERS"
msgstr "No submitters"

#: exercise/templates/exercise/staff/analytics.html
#: exercise/templates/exercise/staff/results.html
msgid "PSEUDONYMIZATION_ERROR_MSG"
msgstr "This view is not available when pseudonymization is enabled!"

#: exercise/templates/exercise/staff/analytics.html
msgid "MODULE_SELECTION"
msgstr "Module selection"
Expand Down
20 changes: 18 additions & 2 deletions locale/fi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-01-20 17:06+0200\n"
"POT-Creation-Date: 2024-04-04 13:12+0300\n"
"PO-Revision-Date: 2019-08-14 12:16+0200\n"
"Last-Translator: Jimmy Ihalainen <[email protected]>\n"
"Language-Team: Finnish <>\n"
Expand Down Expand Up @@ -1031,7 +1031,6 @@ msgstr "Pseudonymisointi pois päältä"
msgid "PSEUDONYMIZE"
msgstr "Pseudonymisointi päälle"


#: course/templates/course/_enroll_form.html
msgid "ENROLL_THROUGH_SIS"
msgstr ""
Expand Down Expand Up @@ -4050,6 +4049,10 @@ msgstr "Palautushetki"
msgid "INCLUDES_LATE_PENALTY"
msgstr "Sisältää myöhästymissakon"

#: exercise/templates/exercise/_submission_info.html
msgid "PSEUDONYMIZED_SUBMITTERS"
msgstr "Anonymisoidut palauttajat"

#: exercise/templates/exercise/_submit_progress.html
#: exercise/templates/exercise/exercise.html
msgid "POSTING_SUBMISSION"
Expand Down Expand Up @@ -4264,6 +4267,14 @@ msgstr "Tulokset"
msgid "ASSESSED_BY -- %(user)s, %(time)s"
msgstr "Arvostellut %(user)s, %(time)s"

#: exercise/templates/exercise/staff/_assessment_panel.html
msgid "ASSESSED_BY"
msgstr "Arvostellut"

#: exercise/templates/exercise/staff/_assessment_panel.html
msgid "SOMEBODY"
msgstr "Joku"

#: exercise/templates/exercise/staff/_assessment_panel.html
msgid "NOT_ASSESSED_MANUALLY"
msgstr "Ei arvosteltu manuaalisesti"
Expand Down Expand Up @@ -4490,6 +4501,11 @@ msgstr "Viimeisin palautusaika"
msgid "NO_SUBMITTERS"
msgstr "Ei palauttajia"

#: exercise/templates/exercise/staff/analytics.html
#: exercise/templates/exercise/staff/results.html
msgid "PSEUDONYMIZATION_ERROR_MSG"
msgstr "Tämä näkymä ei ole saatavilla kun pseudonymisointi on päällä!"

#: exercise/templates/exercise/staff/analytics.html
msgid "MODULE_SELECTION"
msgstr "Moduulin valinta"
Expand Down
4 changes: 3 additions & 1 deletion userprofile/pseudonymize.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
from random import choice
from random import seed, choice

from faker import Faker
import hashlib
Expand Down Expand Up @@ -32,7 +32,9 @@ def format_user(user: User, pseudonymized: bool, user_profile: UserProfile = Non
if pseudonymized:
# Return formatted versions of the user's attributes and all the user class's methods
if user_profile is not None:
Faker.seed(user_profile.student_id)
user_profile.student_id = str(fake.random_int(min=10, max=10000))
seed(user.first_name)
user.first_name = choice(DATA["colors"])["name"]
user.last_name = choice(DATA["animals"])
user.email = pseudonymize('email', user.email)
Expand Down

0 comments on commit 75571b8

Please sign in to comment.