-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'nau/nutmeg.master' into nau/redwood.master
- Loading branch information
Showing
25 changed files
with
634 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
""" | ||
This file defines overrides of the context render of course certificates using an Open edX Filters pipeline step. | ||
""" | ||
|
||
import logging | ||
|
||
from openedx_filters import PipelineStep | ||
|
||
from nau_openedx_extensions.edxapp_wrapper.cohort import get_cohort | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
class CertificatesContextCohortOverride(PipelineStep): | ||
""" | ||
Override the certificates render template context with information from the student cohort. | ||
If user has a cohort and that cohort has custom certificate overrides, then override the root context variables | ||
with the cohorted ones. | ||
Example usage: | ||
Add the following configurations to your configuration file: | ||
"OPEN_EDX_FILTERS_CONFIG": { | ||
"org.openedx.learning.certificate.render.started.v1": { | ||
"fail_silently": false, | ||
"pipeline": [ | ||
"nau_openedx_extensions.certificates.context_overrides.CertificatesContextCohortOverride" | ||
] | ||
} | ||
} | ||
Configure course on field "Certificate Web/HTML View Overrides" with: | ||
{ | ||
"footer_additional_logo": "https://lms.example.com/some_logo.png", | ||
"cohort_overrides": { | ||
"test": { | ||
"footer_additional_logo": "https://lms.example.com/override_logo.png" | ||
} | ||
} | ||
} | ||
""" | ||
|
||
def run_filter(self, context, custom_template): # pylint: disable=arguments-differ | ||
""" | ||
The filter logic. | ||
""" | ||
username = context["username"] | ||
course_key = context["course_id"] | ||
if "cohort_overrides" in context: | ||
cohort = get_cohort(username, course_key) | ||
if cohort: | ||
if cohort.name in context["cohort_overrides"]: | ||
cohort_override_dict = context["cohort_overrides"][cohort.name] | ||
context.update(cohort_override_dict) | ||
else: | ||
log.info( | ||
"The user '%s' enrollment on course '%s' doesn't have a cohort " | ||
"certificate context overrides configured for the cohort '%s'.", | ||
username, | ||
course_key, | ||
cohort.name, | ||
) | ||
else: | ||
log.info( | ||
"User '%s' not in a cohort on course '%s'", username, course_key | ||
) | ||
else: | ||
log.info( | ||
"No Certificates context cohort_overrides defined on course '%s'", | ||
course_key, | ||
) | ||
|
||
return {"context": context, "custom_template": custom_template} |
14 changes: 14 additions & 0 deletions
14
nau_openedx_extensions/edxapp_wrapper/backends/cohort_v1.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
""" | ||
Cohort abstraction backend | ||
""" | ||
from common.djangoapps.student.models import get_user_by_username_or_email # pylint: disable=import-error | ||
from openedx.core.djangoapps.course_groups.cohorts import \ | ||
get_cohort as edxapp_get_cohort # pylint: disable=import-error | ||
|
||
|
||
def get_cohort(username, course_key): | ||
""" | ||
Get the Course Cohort for the User that belongs the username if available other case return None. | ||
""" | ||
user = get_user_by_username_or_email(username) | ||
return edxapp_get_cohort(user, course_key, assign=False, use_cached=False) |
10 changes: 10 additions & 0 deletions
10
nau_openedx_extensions/edxapp_wrapper/backends/cohort_v1_tests.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
""" | ||
Cohort abstraction backend | ||
""" | ||
|
||
|
||
def get_cohort(username, course_key): # pylint: disable=unused-argument | ||
""" | ||
For tests. | ||
""" | ||
return None |
33 changes: 33 additions & 0 deletions
33
nau_openedx_extensions/edxapp_wrapper/backends/verify_student_v1.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" | ||
Real implementation of user id verifications service. | ||
""" | ||
from django.contrib.auth import get_user_model | ||
from lms.djangoapps.verify_student.models import ManualVerification # pylint: disable=import-error | ||
|
||
|
||
def get_user_id_verifications(user_id, *args, **kwargs): | ||
""" | ||
Read the user's `ManualVerification` from the edx-platform. | ||
Args: | ||
user: The user id to read the Id Verifications. | ||
Returns: | ||
An enumeration of those Id Verifications | ||
""" | ||
user = get_user_model().objects.get(id=user_id) | ||
return ManualVerification.objects.filter(user=user).order_by('-created_at') | ||
|
||
|
||
def create_user_id_verification(user_id, *args, **kwargs): | ||
""" | ||
Create a new `ManualVerification` on the edx-platform. | ||
Args: | ||
user: The user id that this Id verification should be created. | ||
Returns: | ||
The object created | ||
""" | ||
user = get_user_model().objects.get(id=user_id) | ||
ManualVerification(user=user, name=user.profile.name, *args, **kwargs).save() |
28 changes: 28 additions & 0 deletions
28
nau_openedx_extensions/edxapp_wrapper/backends/verify_student_v1_tests.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
""" | ||
Real implementation of user id verifications service. | ||
""" | ||
|
||
|
||
def get_user_id_verifications(user_id, *args, **kwargs): # pylint: disable=unused-argument | ||
""" | ||
Read the user's `ManualVerification` from the edx-platform. | ||
Args: | ||
user_id: The user id to read the Id Verifications. | ||
Returns: | ||
An enumeration of those Id Verifications | ||
""" | ||
return [] | ||
|
||
def create_user_id_verification(user_id, *args, **kwargs): # pylint: disable=unused-argument | ||
""" | ||
Create a new `ManualVerification` on the edx-platform. | ||
Args: | ||
user_id: The user id that this Id verification should be created. | ||
Returns: | ||
The object created | ||
""" | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
""" CourseMetadata backend abstraction """ | ||
|
||
from importlib import import_module | ||
|
||
from django.conf import settings | ||
|
||
|
||
def get_cohort(*args, **kwargs): | ||
""" | ||
Get the Course Cohort for the User that belongs the username if available other case return None. | ||
""" | ||
backend_module = settings.NAU_COHORT_MODULE | ||
backend = import_module(backend_module) | ||
|
||
return backend.get_cohort(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
Student backend abstraction | ||
""" | ||
from __future__ import absolute_import, unicode_literals | ||
|
||
from importlib import import_module | ||
|
||
from django.conf import settings | ||
|
||
|
||
def get_user_id_verifications(user_id, *args, **kwargs): | ||
""" | ||
Read the user's `ManualVerification` from the edx-platform. | ||
""" | ||
|
||
backend_module = settings.NAU_VERIFY_STUDENT_MODULE | ||
backend = import_module(backend_module) | ||
|
||
return backend.get_user_id_verifications(user_id, *args, **kwargs) | ||
|
||
|
||
def create_user_id_verification(user_id, *args, **kwargs): | ||
""" | ||
Create an user Id Verification `ManualVerification` instance on the edx-platform. | ||
""" | ||
backend_module = settings.NAU_VERIFY_STUDENT_MODULE | ||
backend = import_module(backend_module) | ||
|
||
return backend.create_user_id_verification(user_id, *args, **kwargs) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PROJECT VERSION\n" | ||
"Report-Msgid-Bugs-To: [email protected]\n" | ||
"POT-Creation-Date: 2024-05-10 14:45+0100\n" | ||
"POT-Creation-Date: 2024-10-02 13:56+0100\n" | ||
"PO-Revision-Date: 2021-02-15 15:56+0000\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language: en\n" | ||
|
@@ -133,11 +133,11 @@ msgid "" | |
"out in order to obtain a certificate." | ||
msgstr "" | ||
|
||
#: nau_openedx_extensions/settings/common.py:86 | ||
#: nau_openedx_extensions/settings/common.py:35 | ||
msgid "Certificate" | ||
msgstr "" | ||
|
||
#: nau_openedx_extensions/settings/common.py:87 | ||
#: nau_openedx_extensions/settings/common.py:36 | ||
msgid "Certificate of Achievement" | ||
msgstr "" | ||
|
||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PROJECT VERSION\n" | ||
"Report-Msgid-Bugs-To: [email protected]\n" | ||
"POT-Creation-Date: 2024-05-10 14:45+0100\n" | ||
"POT-Creation-Date: 2024-10-02 13:56+0100\n" | ||
"PO-Revision-Date: 2021-02-15 15:56+0000\n" | ||
"Last-Translator: Ivo Branco <[email protected]>\n" | ||
"Language: pt_PT\n" | ||
|
@@ -142,11 +142,11 @@ msgstr "" | |
"Este curso encontra-se arquivado e já não permite a realização de " | ||
"atividades para obtenção de certificado." | ||
|
||
#: nau_openedx_extensions/settings/common.py:86 | ||
#: nau_openedx_extensions/settings/common.py:35 | ||
msgid "Certificate" | ||
msgstr "Certificado" | ||
|
||
#: nau_openedx_extensions/settings/common.py:87 | ||
#: nau_openedx_extensions/settings/common.py:36 | ||
msgid "Certificate of Achievement" | ||
msgstr "Certificado de Conclusão" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
""" | ||
File that contains the definition of all signals and its receivers. | ||
""" | ||
|
||
from nau_openedx_extensions.verify_student.id_verification import ( # pylint: disable=unused-import | ||
event_receiver_no_id_verify_for_enrollment_modes, | ||
) |
Oops, something went wrong.