platform-plugin-aspects 2.2.1__tar.gz → 3.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/PKG-INFO +17 -1
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/README.rst +16 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/settings/common.py +12 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/signals.py +102 -1
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/sinks/__init__.py +4 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/sinks/serializers.py +99 -1
- platform_plugin_aspects-3.0.0/src/platform_plugin_aspects/sinks/student_competency_status_sink.py +62 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/sinks/tag_sink.py +9 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/sinks/tests/test_serializers.py +119 -0
- platform_plugin_aspects-3.0.0/src/platform_plugin_aspects/sinks/tests/test_student_competency_status_sink.py +81 -0
- platform_plugin_aspects-3.0.0/src/platform_plugin_aspects/sinks/tests/test_tag_sink.py +33 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/tests/test_signals.py +56 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/tests/test_utils.py +37 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/utils.py +15 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects.egg-info/PKG-INFO +17 -1
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects.egg-info/SOURCES.txt +3 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects.egg-info/scm_file_list.json +3 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/.annotation_safe_list.yml +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/.editorconfig +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/.pii_annotations.yml +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/.readthedocs.yaml +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/LICENSE +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/MANIFEST.in +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/catalog-info.yaml +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/codecov.yml +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/manage.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/pylintrc +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/pylintrc_tweaks +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/pyproject.toml +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/setup.cfg +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/__init__.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/apps.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/conf/locale/babel_mako.cfg +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/conf/locale/config.yaml +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/conf/locale/en/LC_MESSAGES/django.mo +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/conf/locale/en/LC_MESSAGES/django.po +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/conf/locale/en/LC_MESSAGES/mako.mo +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/conf/locale/en/LC_MESSAGES/mako.po +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/conf/locale/eo/LC_MESSAGES/django.mo +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/conf/locale/eo/LC_MESSAGES/django.po +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/conf/locale/eo/LC_MESSAGES/mako.mo +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/conf/locale/eo/LC_MESSAGES/mako.po +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/extensions/__init__.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/extensions/filters.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/extensions/tests/__init__.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/extensions/tests/test_filters.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/management/__init__.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/management/commands/__init__.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/management/commands/dump_data_to_clickhouse.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/management/commands/load_test_tracking_events.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/management/commands/monitor_load_test_tracking.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/settings/__init__.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/settings/production.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/settings/tests/__init__.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/sinks/base_sink.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/sinks/catalog_pathway_sink.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/sinks/course_enrollment_sink.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/sinks/course_overview_sink.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/sinks/external_id_sink.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/sinks/pathway_enrollment_sink.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/sinks/tests/test_base_sink.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/sinks/tests/test_catalog_pathway_sink.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/sinks/tests/test_course_enrollment_sink.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/sinks/tests/test_course_overview_sink.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/sinks/tests/test_external_id_sink.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/sinks/tests/test_pathway_enrollment_sink.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/sinks/tests/test_user_profile_sink.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/sinks/tests/test_user_retire_sink.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/sinks/user_profile_sink.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/sinks/user_retire_sink.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/static/css/superset.css +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/static/html/superset.html +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/static/html/superset_student.html +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/static/js/embed_dashboard.js +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/static/js/install_required.js +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/static/js/superset.js +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/tasks.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/templates/instructor_dashboard/aspects.html +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/tests/__init__.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/tests/commands/test_dump_data_to_clickhouse.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/tests/commands/test_load_test_monitor.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/tests/commands/test_load_test_tracking_events.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/tests/test_tasks.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/tests/test_views.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/tests/test_xblock.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/urls.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/views.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/waffle.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/xblock.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects.egg-info/dependency_links.txt +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects.egg-info/entry_points.txt +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects.egg-info/requires.txt +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects.egg-info/top_level.txt +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/test_settings.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/test_utils/__init__.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/test_utils/helpers.py +0 -0
- {platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/uv.lock +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: platform-plugin-aspects
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0
|
|
4
4
|
Summary: Aspects plugins for edx-platform
|
|
5
5
|
Author-email: Open edX Project <oscm@openedx.org>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -78,9 +78,25 @@ Below are the existing sink names and their corresponding object names (as neede
|
|
|
78
78
|
``CatalogPathway`` model and marks the pathway deleted in ``catalog_pathway``.
|
|
79
79
|
- ``PathwayEnrollmentSink`` - Listens for the ``post_save`` Django signal on the openedx-core
|
|
80
80
|
``PathwayEnrollment`` model. Object name: ``pathway_enrollment``
|
|
81
|
+
- ``StudentCompetencyStatusSink`` - Listens for the ``post_save`` Django signal on the openedx-core
|
|
82
|
+
``StudentCompetencyStatus`` model (a learner's mastery status for one competency). Object name:
|
|
83
|
+
``student_competency_status``
|
|
84
|
+
- ``StudentCompetencyCourseStatusSink`` - Listens for the ``post_save`` Django signal on the
|
|
85
|
+
openedx-core ``StudentCompetencyCriteriaGroupStatus`` model, course-level groups only (a learner's
|
|
86
|
+
mastery status for one competency in one course run, with the competency and course key). Object name:
|
|
87
|
+
``student_competency_course_status``
|
|
81
88
|
- ``UserRetirementSink`` - Listen for the ``USER_RETIRE_LMS_MISC`` Django signal and
|
|
82
89
|
remove the user PII information from ClickHouse. This is a special sink with no assigned object name.
|
|
83
90
|
|
|
91
|
+
The competency sinks need an openedx-core with competency-based education (the
|
|
92
|
+
``CompetencyTaxonomy`` model). Without it they stay inactive and ``TaxonomySink`` writes every
|
|
93
|
+
taxonomy's ``taxonomy_type`` as ``tags``. Their ``EVENT_SINK_CLICKHOUSE_MODEL_CONFIG`` keys are
|
|
94
|
+
``student_competency_status``, ``student_competency_course_status`` and ``competency_taxonomy``.
|
|
95
|
+
|
|
96
|
+
Apply the matching tutor-contrib-aspects ClickHouse migrations before upgrading to a version that
|
|
97
|
+
adds sink columns, such as ``taxonomy_type`` on ``taxonomy``. Sink inserts are positional CSV and
|
|
98
|
+
tolerate one bad row, so a single-row dump against the old schema is dropped without an error.
|
|
99
|
+
|
|
84
100
|
Commands
|
|
85
101
|
========
|
|
86
102
|
|
|
@@ -42,9 +42,25 @@ Below are the existing sink names and their corresponding object names (as neede
|
|
|
42
42
|
``CatalogPathway`` model and marks the pathway deleted in ``catalog_pathway``.
|
|
43
43
|
- ``PathwayEnrollmentSink`` - Listens for the ``post_save`` Django signal on the openedx-core
|
|
44
44
|
``PathwayEnrollment`` model. Object name: ``pathway_enrollment``
|
|
45
|
+
- ``StudentCompetencyStatusSink`` - Listens for the ``post_save`` Django signal on the openedx-core
|
|
46
|
+
``StudentCompetencyStatus`` model (a learner's mastery status for one competency). Object name:
|
|
47
|
+
``student_competency_status``
|
|
48
|
+
- ``StudentCompetencyCourseStatusSink`` - Listens for the ``post_save`` Django signal on the
|
|
49
|
+
openedx-core ``StudentCompetencyCriteriaGroupStatus`` model, course-level groups only (a learner's
|
|
50
|
+
mastery status for one competency in one course run, with the competency and course key). Object name:
|
|
51
|
+
``student_competency_course_status``
|
|
45
52
|
- ``UserRetirementSink`` - Listen for the ``USER_RETIRE_LMS_MISC`` Django signal and
|
|
46
53
|
remove the user PII information from ClickHouse. This is a special sink with no assigned object name.
|
|
47
54
|
|
|
55
|
+
The competency sinks need an openedx-core with competency-based education (the
|
|
56
|
+
``CompetencyTaxonomy`` model). Without it they stay inactive and ``TaxonomySink`` writes every
|
|
57
|
+
taxonomy's ``taxonomy_type`` as ``tags``. Their ``EVENT_SINK_CLICKHOUSE_MODEL_CONFIG`` keys are
|
|
58
|
+
``student_competency_status``, ``student_competency_course_status`` and ``competency_taxonomy``.
|
|
59
|
+
|
|
60
|
+
Apply the matching tutor-contrib-aspects ClickHouse migrations before upgrading to a version that
|
|
61
|
+
adds sink columns, such as ``taxonomy_type`` on ``taxonomy``. Sink inserts are positional CSV and
|
|
62
|
+
tolerate one bad row, so a single-row dump against the old schema is dropped without an error.
|
|
63
|
+
|
|
48
64
|
Commands
|
|
49
65
|
========
|
|
50
66
|
|
|
@@ -99,6 +99,10 @@ def plugin_settings(settings):
|
|
|
99
99
|
"module": "openedx_tagging.models.base",
|
|
100
100
|
"model": "Taxonomy",
|
|
101
101
|
},
|
|
102
|
+
"competency_taxonomy": {
|
|
103
|
+
"module": "openedx_learning.models",
|
|
104
|
+
"model": "CompetencyTaxonomy",
|
|
105
|
+
},
|
|
102
106
|
"object_tag": {
|
|
103
107
|
"module": "openedx_tagging.models.base",
|
|
104
108
|
"model": "ObjectTag",
|
|
@@ -111,6 +115,14 @@ def plugin_settings(settings):
|
|
|
111
115
|
"module": "openedx_catalog.models",
|
|
112
116
|
"model": "PathwayEnrollment",
|
|
113
117
|
},
|
|
118
|
+
"student_competency_status": {
|
|
119
|
+
"module": "openedx_learning.models",
|
|
120
|
+
"model": "StudentCompetencyStatus",
|
|
121
|
+
},
|
|
122
|
+
"student_competency_course_status": {
|
|
123
|
+
"module": "openedx_learning.models",
|
|
124
|
+
"model": "StudentCompetencyCriteriaGroupStatus",
|
|
125
|
+
},
|
|
114
126
|
}
|
|
115
127
|
|
|
116
128
|
# This is on by default here, off by default in tutor-contrib-aspects until we only
|
|
@@ -14,6 +14,8 @@ from platform_plugin_aspects.sinks import (
|
|
|
14
14
|
ExternalIdSink,
|
|
15
15
|
ObjectTagSink,
|
|
16
16
|
PathwayEnrollmentSink,
|
|
17
|
+
StudentCompetencyCourseStatusSink,
|
|
18
|
+
StudentCompetencyStatusSink,
|
|
17
19
|
TagSink,
|
|
18
20
|
TaxonomySink,
|
|
19
21
|
UserProfileSink,
|
|
@@ -242,12 +244,21 @@ def on_taxonomy_saved_txn(*args, **kwargs):
|
|
|
242
244
|
transaction.on_commit(lambda: on_taxonomy_saved(*args, **kwargs))
|
|
243
245
|
|
|
244
246
|
|
|
245
|
-
# Connect the
|
|
247
|
+
# Connect the Taxonomy.post_save signal handler only if we have a model to attach to.
|
|
246
248
|
# (prevents celery errors during tests)
|
|
247
249
|
_taxonomy = get_model("taxonomy")
|
|
248
250
|
if _taxonomy:
|
|
249
251
|
post_save.connect(on_taxonomy_saved_txn, sender=_taxonomy) # pragma: no cover
|
|
250
252
|
|
|
253
|
+
# A competency taxonomy is saved once, as openedx-core's CompetencyTaxonomy (a
|
|
254
|
+
# multi-table-inheritance child of Taxonomy), and Django sends that post_save with the
|
|
255
|
+
# child class only. This is the only signal that dumps a competency taxonomy.
|
|
256
|
+
_competency_taxonomy = get_model("competency_taxonomy")
|
|
257
|
+
if _competency_taxonomy:
|
|
258
|
+
post_save.connect( # pragma: no cover
|
|
259
|
+
on_taxonomy_saved_txn, sender=_competency_taxonomy
|
|
260
|
+
)
|
|
261
|
+
|
|
251
262
|
|
|
252
263
|
def on_object_tag_saved_txn(*args, **kwargs):
|
|
253
264
|
"""
|
|
@@ -408,3 +419,93 @@ def on_pathway_enrollment_saved_txn(*args, **kwargs):
|
|
|
408
419
|
_pathway_enrollment = get_model("pathway_enrollment")
|
|
409
420
|
if _pathway_enrollment: # pragma: no cover
|
|
410
421
|
post_save.connect(on_pathway_enrollment_saved_txn, sender=_pathway_enrollment)
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
def on_student_competency_status_saved_txn(*args, **kwargs):
|
|
425
|
+
"""
|
|
426
|
+
Handle student_competency_status saves in the middle of a transaction.
|
|
427
|
+
|
|
428
|
+
openedx-core sends post_save for a raise before its transaction commits, so a
|
|
429
|
+
dump queued right away could read the old status. A rolled-back raise is never
|
|
430
|
+
queued. If queuing fails, the error is logged and the row needs a backfill.
|
|
431
|
+
"""
|
|
432
|
+
|
|
433
|
+
def on_student_competency_status_saved( # pylint: disable=unused-argument # pragma: no cover
|
|
434
|
+
sender, instance, **kwargs
|
|
435
|
+
):
|
|
436
|
+
"""
|
|
437
|
+
Receives post save signal and queues the dump job.
|
|
438
|
+
"""
|
|
439
|
+
# import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
|
|
440
|
+
from platform_plugin_aspects.tasks import ( # pylint: disable=import-outside-toplevel
|
|
441
|
+
dump_data_to_clickhouse,
|
|
442
|
+
)
|
|
443
|
+
|
|
444
|
+
sink = StudentCompetencyStatusSink(None, None)
|
|
445
|
+
dump_data_to_clickhouse.delay(
|
|
446
|
+
sink_module=sink.__module__,
|
|
447
|
+
sink_name=sink.__class__.__name__,
|
|
448
|
+
object_id=str(instance.id),
|
|
449
|
+
)
|
|
450
|
+
|
|
451
|
+
transaction.on_commit(
|
|
452
|
+
lambda: on_student_competency_status_saved(*args, **kwargs), robust=True
|
|
453
|
+
)
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
# Connect the StudentCompetencyStatus.post_save signal handler only if we have a model to attach to.
|
|
457
|
+
# (prevents celery errors during tests)
|
|
458
|
+
_student_competency_status = get_model("student_competency_status")
|
|
459
|
+
if _student_competency_status: # pragma: no cover
|
|
460
|
+
post_save.connect(
|
|
461
|
+
on_student_competency_status_saved_txn, sender=_student_competency_status
|
|
462
|
+
)
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
def on_student_competency_course_status_saved_txn(*args, **kwargs):
|
|
466
|
+
"""
|
|
467
|
+
Handle student_competency_course_status saves in the middle of a transaction.
|
|
468
|
+
|
|
469
|
+
Deferred to the commit for the same reasons as student_competency_status saves.
|
|
470
|
+
Only rows the sink dumps (course-level groups) are queued.
|
|
471
|
+
"""
|
|
472
|
+
|
|
473
|
+
def on_student_competency_course_status_saved( # pylint: disable=unused-argument
|
|
474
|
+
sender, instance, **kwargs
|
|
475
|
+
):
|
|
476
|
+
"""
|
|
477
|
+
Receives post save signal and queues the dump job.
|
|
478
|
+
"""
|
|
479
|
+
# import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
|
|
480
|
+
from platform_plugin_aspects.tasks import ( # pylint: disable=import-outside-toplevel
|
|
481
|
+
dump_data_to_clickhouse,
|
|
482
|
+
)
|
|
483
|
+
|
|
484
|
+
# The rollup saves every group level; checking the sink first spares the group
|
|
485
|
+
# lookup, and the broker message, on installs that don't sink these rows.
|
|
486
|
+
if not StudentCompetencyCourseStatusSink.is_enabled():
|
|
487
|
+
return
|
|
488
|
+
if not StudentCompetencyCourseStatusSink.is_course_level(instance):
|
|
489
|
+
return
|
|
490
|
+
|
|
491
|
+
sink = StudentCompetencyCourseStatusSink(None, None)
|
|
492
|
+
dump_data_to_clickhouse.delay(
|
|
493
|
+
sink_module=sink.__module__,
|
|
494
|
+
sink_name=sink.__class__.__name__,
|
|
495
|
+
object_id=str(instance.id),
|
|
496
|
+
)
|
|
497
|
+
|
|
498
|
+
transaction.on_commit(
|
|
499
|
+
lambda: on_student_competency_course_status_saved(*args, **kwargs),
|
|
500
|
+
robust=True,
|
|
501
|
+
)
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
# Connect the StudentCompetencyCriteriaGroupStatus (course status) post_save signal handler only if we have a
|
|
505
|
+
# model to attach to. (prevents celery errors during tests)
|
|
506
|
+
_student_competency_course_status = get_model("student_competency_course_status")
|
|
507
|
+
if _student_competency_course_status: # pragma: no cover
|
|
508
|
+
post_save.connect(
|
|
509
|
+
on_student_competency_course_status_saved_txn,
|
|
510
|
+
sender=_student_competency_course_status,
|
|
511
|
+
)
|
|
@@ -8,6 +8,10 @@ from .course_enrollment_sink import CourseEnrollmentSink
|
|
|
8
8
|
from .course_overview_sink import CourseOverviewSink, XBlockSink
|
|
9
9
|
from .external_id_sink import ExternalIdSink
|
|
10
10
|
from .pathway_enrollment_sink import PathwayEnrollmentSink
|
|
11
|
+
from .student_competency_status_sink import (
|
|
12
|
+
StudentCompetencyCourseStatusSink,
|
|
13
|
+
StudentCompetencyStatusSink,
|
|
14
|
+
)
|
|
11
15
|
from .tag_sink import ObjectTagSink, TagSink, TaxonomySink
|
|
12
16
|
from .user_profile_sink import UserProfileSink
|
|
13
17
|
from .user_retire_sink import UserRetirementSink
|
|
@@ -9,6 +9,7 @@ from pytz import UTC
|
|
|
9
9
|
from rest_framework import serializers
|
|
10
10
|
|
|
11
11
|
from platform_plugin_aspects.utils import (
|
|
12
|
+
get_competency_api,
|
|
12
13
|
get_model,
|
|
13
14
|
get_or_create_xapi_actor_id,
|
|
14
15
|
get_tags_for_block,
|
|
@@ -279,6 +280,85 @@ class PathwayEnrollmentSerializer(BaseSinkSerializer, serializers.ModelSerialize
|
|
|
279
280
|
return get_or_create_xapi_actor_id(instance.user)
|
|
280
281
|
|
|
281
282
|
|
|
283
|
+
class StudentCompetencyStatusSerializer(
|
|
284
|
+
BaseSinkSerializer, serializers.ModelSerializer
|
|
285
|
+
):
|
|
286
|
+
"""
|
|
287
|
+
Serializer for the openedx-core StudentCompetencyStatus model.
|
|
288
|
+
|
|
289
|
+
``created`` is when the learner first got a status for the competency. openedx-core
|
|
290
|
+
only raises statuses today, so ``modified`` on a Demonstrated row is when they
|
|
291
|
+
demonstrated it. That is current behavior, not a promise: a later staff edit or
|
|
292
|
+
recalculation could move it.
|
|
293
|
+
"""
|
|
294
|
+
|
|
295
|
+
actor_id = serializers.SerializerMethodField()
|
|
296
|
+
taxonomy_id = serializers.IntegerField(source="tag.taxonomy_id")
|
|
297
|
+
status_name = serializers.CharField(source="status.status")
|
|
298
|
+
|
|
299
|
+
class Meta:
|
|
300
|
+
"""Meta class for the StudentCompetencyStatusSerializer"""
|
|
301
|
+
|
|
302
|
+
model = get_model("student_competency_status")
|
|
303
|
+
fields = [
|
|
304
|
+
"id",
|
|
305
|
+
"actor_id",
|
|
306
|
+
"tag_id",
|
|
307
|
+
"taxonomy_id",
|
|
308
|
+
"status_id",
|
|
309
|
+
"status_name",
|
|
310
|
+
"created",
|
|
311
|
+
"modified",
|
|
312
|
+
"dump_id",
|
|
313
|
+
"time_last_dumped",
|
|
314
|
+
]
|
|
315
|
+
|
|
316
|
+
def get_actor_id(self, instance):
|
|
317
|
+
"""Return the learner's xAPI actor id instead of any user identifier."""
|
|
318
|
+
return get_or_create_xapi_actor_id(instance.user)
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
class StudentCompetencyCourseStatusSerializer(
|
|
322
|
+
BaseSinkSerializer, serializers.ModelSerializer
|
|
323
|
+
):
|
|
324
|
+
"""
|
|
325
|
+
Serializer for the openedx-core StudentCompetencyCriteriaGroupStatus model.
|
|
326
|
+
|
|
327
|
+
Only course-level groups are sunk (see StudentCompetencyCourseStatusSink): a
|
|
328
|
+
row is the learner's status for one competency in one course run. The group's
|
|
329
|
+
competency and course key are denormalized so ClickHouse needs no criteria-group table.
|
|
330
|
+
"""
|
|
331
|
+
|
|
332
|
+
actor_id = serializers.SerializerMethodField()
|
|
333
|
+
tag_id = serializers.IntegerField(source="group.tag_id")
|
|
334
|
+
taxonomy_id = serializers.IntegerField(source="group.tag.taxonomy_id")
|
|
335
|
+
course_key = serializers.CharField(source="group.course.course_key")
|
|
336
|
+
status_name = serializers.CharField(source="status.status")
|
|
337
|
+
|
|
338
|
+
class Meta:
|
|
339
|
+
"""Meta class for the StudentCompetencyCourseStatusSerializer"""
|
|
340
|
+
|
|
341
|
+
model = get_model("student_competency_course_status")
|
|
342
|
+
fields = [
|
|
343
|
+
"id",
|
|
344
|
+
"actor_id",
|
|
345
|
+
"group_id",
|
|
346
|
+
"tag_id",
|
|
347
|
+
"taxonomy_id",
|
|
348
|
+
"course_key",
|
|
349
|
+
"status_id",
|
|
350
|
+
"status_name",
|
|
351
|
+
"created",
|
|
352
|
+
"modified",
|
|
353
|
+
"dump_id",
|
|
354
|
+
"time_last_dumped",
|
|
355
|
+
]
|
|
356
|
+
|
|
357
|
+
def get_actor_id(self, instance):
|
|
358
|
+
"""Return the learner's xAPI actor id instead of any user identifier."""
|
|
359
|
+
return get_or_create_xapi_actor_id(instance.user)
|
|
360
|
+
|
|
361
|
+
|
|
282
362
|
class TagSerializer(BaseSinkSerializer, serializers.ModelSerializer):
|
|
283
363
|
"""Serializer for the Tag model."""
|
|
284
364
|
|
|
@@ -329,7 +409,17 @@ class ObjectTagSerializer(BaseSinkSerializer, serializers.ModelSerializer):
|
|
|
329
409
|
|
|
330
410
|
|
|
331
411
|
class TaxonomySerializer(BaseSinkSerializer, serializers.ModelSerializer):
|
|
332
|
-
"""
|
|
412
|
+
"""
|
|
413
|
+
Serializer for the Taxonomy model.
|
|
414
|
+
|
|
415
|
+
``taxonomy_type`` is ``competency`` for a taxonomy backed by an openedx-core
|
|
416
|
+
CompetencyTaxonomy row and ``tags`` otherwise, computed the way the platform's
|
|
417
|
+
taxonomy REST serializer does it (openedx_tagging ADR 0013,
|
|
418
|
+
competency-taxonomy-detection). It is the last field
|
|
419
|
+
because sink inserts are positional CSV and the column was added last.
|
|
420
|
+
"""
|
|
421
|
+
|
|
422
|
+
taxonomy_type = serializers.SerializerMethodField()
|
|
333
423
|
|
|
334
424
|
class Meta:
|
|
335
425
|
"""Meta class for the TaxonomySerializer."""
|
|
@@ -340,4 +430,12 @@ class TaxonomySerializer(BaseSinkSerializer, serializers.ModelSerializer):
|
|
|
340
430
|
"name",
|
|
341
431
|
"dump_id",
|
|
342
432
|
"time_last_dumped",
|
|
433
|
+
"taxonomy_type",
|
|
343
434
|
]
|
|
435
|
+
|
|
436
|
+
def get_taxonomy_type(self, instance):
|
|
437
|
+
"""Return ``competency`` or ``tags``, through openedx-core's public CBE API."""
|
|
438
|
+
competency_api = get_competency_api()
|
|
439
|
+
if competency_api and competency_api.is_competency_taxonomy(instance):
|
|
440
|
+
return "competency"
|
|
441
|
+
return "tags"
|
platform_plugin_aspects-3.0.0/src/platform_plugin_aspects/sinks/student_competency_status_sink.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""Student Competency Status sinks: per competency, and per competency and course"""
|
|
2
|
+
|
|
3
|
+
from platform_plugin_aspects.sinks.base_sink import ModelBaseSink
|
|
4
|
+
from platform_plugin_aspects.sinks.serializers import (
|
|
5
|
+
StudentCompetencyCourseStatusSerializer,
|
|
6
|
+
StudentCompetencyStatusSerializer,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class StudentCompetencyStatusSink(ModelBaseSink): # pylint: disable=abstract-method
|
|
11
|
+
"""
|
|
12
|
+
Sink for the openedx-core StudentCompetencyStatus model: a learner's current mastery status for one competency
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
model = "student_competency_status"
|
|
16
|
+
unique_key = "id"
|
|
17
|
+
clickhouse_table_name = "student_competency_status"
|
|
18
|
+
timestamp_field = "time_last_dumped"
|
|
19
|
+
name = "Student Competency Status"
|
|
20
|
+
serializer_class = StudentCompetencyStatusSerializer
|
|
21
|
+
|
|
22
|
+
def get_queryset(self, start_pk=None):
|
|
23
|
+
return super().get_queryset(start_pk).select_related("user", "tag", "status")
|
|
24
|
+
|
|
25
|
+
def get_object(self, item_id):
|
|
26
|
+
return self.get_queryset().get(id=item_id)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class StudentCompetencyCourseStatusSink(
|
|
30
|
+
ModelBaseSink
|
|
31
|
+
): # pylint: disable=abstract-method
|
|
32
|
+
"""
|
|
33
|
+
Sink for openedx-core StudentCompetencyCriteriaGroupStatus rows of course-level groups.
|
|
34
|
+
|
|
35
|
+
A course-level group (one with a course run) holds the learner's status for one competency
|
|
36
|
+
in one course, the only place AttemptedNotDemonstrated is stored per competency and course.
|
|
37
|
+
Root and leaf group rows are not sunk: nothing in Aspects reads them, and they would
|
|
38
|
+
multiply the rows.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
model = "student_competency_course_status"
|
|
42
|
+
unique_key = "id"
|
|
43
|
+
clickhouse_table_name = "student_competency_course_status"
|
|
44
|
+
timestamp_field = "time_last_dumped"
|
|
45
|
+
name = "Student Competency Course Status"
|
|
46
|
+
serializer_class = StudentCompetencyCourseStatusSerializer
|
|
47
|
+
|
|
48
|
+
@staticmethod
|
|
49
|
+
def is_course_level(status):
|
|
50
|
+
"""Return True if ``status`` belongs to a course-level group, the only rows this sink dumps."""
|
|
51
|
+
return status.group.course_id is not None
|
|
52
|
+
|
|
53
|
+
def get_queryset(self, start_pk=None):
|
|
54
|
+
return (
|
|
55
|
+
super()
|
|
56
|
+
.get_queryset(start_pk)
|
|
57
|
+
.filter(group__course__isnull=False)
|
|
58
|
+
.select_related("user", "status", "group__tag", "group__course")
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
def get_object(self, item_id):
|
|
62
|
+
return self.get_queryset().get(id=item_id)
|
|
@@ -6,6 +6,7 @@ from platform_plugin_aspects.sinks.serializers import (
|
|
|
6
6
|
TagSerializer,
|
|
7
7
|
TaxonomySerializer,
|
|
8
8
|
)
|
|
9
|
+
from platform_plugin_aspects.utils import get_competency_api
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class TagSink(ModelBaseSink): # pylint: disable=abstract-method
|
|
@@ -33,6 +34,14 @@ class TaxonomySink(ModelBaseSink): # pylint: disable=abstract-method
|
|
|
33
34
|
name = "Taxonomy"
|
|
34
35
|
serializer_class = TaxonomySerializer
|
|
35
36
|
|
|
37
|
+
def get_queryset(self, start_pk=None):
|
|
38
|
+
"""Join each taxonomy's CompetencyTaxonomy row, so taxonomy_type costs no query per row."""
|
|
39
|
+
queryset = super().get_queryset(start_pk)
|
|
40
|
+
competency_api = get_competency_api()
|
|
41
|
+
if competency_api is None:
|
|
42
|
+
return queryset
|
|
43
|
+
return competency_api.select_competency_taxonomies(queryset)
|
|
44
|
+
|
|
36
45
|
|
|
37
46
|
class ObjectTagSink(ModelBaseSink): # pylint: disable=abstract-method
|
|
38
47
|
"""
|
|
@@ -10,6 +10,9 @@ from platform_plugin_aspects.sinks.serializers import (
|
|
|
10
10
|
CourseOverviewSerializer,
|
|
11
11
|
DateTimeJSONEncoder,
|
|
12
12
|
PathwayEnrollmentSerializer,
|
|
13
|
+
StudentCompetencyCourseStatusSerializer,
|
|
14
|
+
StudentCompetencyStatusSerializer,
|
|
15
|
+
TaxonomySerializer,
|
|
13
16
|
)
|
|
14
17
|
from test_utils.helpers import course_key_factory
|
|
15
18
|
|
|
@@ -132,3 +135,119 @@ class TestPathwayEnrollmentSerializer(TestCase):
|
|
|
132
135
|
|
|
133
136
|
assert actor_id == "29e5b22b-b457-49fa-9633-6c0123305d18"
|
|
134
137
|
mock_get_or_create_xapi_actor_id.assert_called_once_with(enrollment.user)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class TestStudentCompetencyStatusSerializer(TestCase):
|
|
141
|
+
"""
|
|
142
|
+
Test StudentCompetencyStatusSerializer
|
|
143
|
+
"""
|
|
144
|
+
|
|
145
|
+
def test_fields(self):
|
|
146
|
+
"""
|
|
147
|
+
Test the exact field order: sink inserts are positional, so it is the ClickHouse column order.
|
|
148
|
+
"""
|
|
149
|
+
assert StudentCompetencyStatusSerializer.Meta.fields == [
|
|
150
|
+
"id",
|
|
151
|
+
"actor_id",
|
|
152
|
+
"tag_id",
|
|
153
|
+
"taxonomy_id",
|
|
154
|
+
"status_id",
|
|
155
|
+
"status_name",
|
|
156
|
+
"created",
|
|
157
|
+
"modified",
|
|
158
|
+
"dump_id",
|
|
159
|
+
"time_last_dumped",
|
|
160
|
+
]
|
|
161
|
+
|
|
162
|
+
@patch("platform_plugin_aspects.sinks.serializers.get_or_create_xapi_actor_id")
|
|
163
|
+
def test_get_actor_id(self, mock_get_xapi_actor_id):
|
|
164
|
+
"""
|
|
165
|
+
Test that the learner is serialized as their xAPI actor id.
|
|
166
|
+
"""
|
|
167
|
+
mock_get_xapi_actor_id.return_value = "29e5b22b-b457-49fa-9633-6c0123305d18"
|
|
168
|
+
status = Mock()
|
|
169
|
+
|
|
170
|
+
actor_id = StudentCompetencyStatusSerializer().get_actor_id(status)
|
|
171
|
+
|
|
172
|
+
assert actor_id == "29e5b22b-b457-49fa-9633-6c0123305d18"
|
|
173
|
+
mock_get_xapi_actor_id.assert_called_once_with(status.user)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
class TestStudentCompetencyCourseStatusSerializer(TestCase):
|
|
177
|
+
"""
|
|
178
|
+
Test StudentCompetencyCourseStatusSerializer
|
|
179
|
+
"""
|
|
180
|
+
|
|
181
|
+
def setUp(self):
|
|
182
|
+
self.serializer = StudentCompetencyCourseStatusSerializer()
|
|
183
|
+
|
|
184
|
+
def test_fields(self):
|
|
185
|
+
"""
|
|
186
|
+
Test the exact field order: sink inserts are positional, so it is the ClickHouse column order.
|
|
187
|
+
|
|
188
|
+
The row carries the group's competency and course, and no group tree
|
|
189
|
+
(no parent_group_id or group_level).
|
|
190
|
+
"""
|
|
191
|
+
assert self.serializer.Meta.fields == [
|
|
192
|
+
"id",
|
|
193
|
+
"actor_id",
|
|
194
|
+
"group_id",
|
|
195
|
+
"tag_id",
|
|
196
|
+
"taxonomy_id",
|
|
197
|
+
"course_key",
|
|
198
|
+
"status_id",
|
|
199
|
+
"status_name",
|
|
200
|
+
"created",
|
|
201
|
+
"modified",
|
|
202
|
+
"dump_id",
|
|
203
|
+
"time_last_dumped",
|
|
204
|
+
]
|
|
205
|
+
|
|
206
|
+
@patch("platform_plugin_aspects.sinks.serializers.get_or_create_xapi_actor_id")
|
|
207
|
+
def test_get_actor_id(self, mock_get_or_create_xapi_actor_id):
|
|
208
|
+
"""
|
|
209
|
+
Test that the learner is serialized as their xAPI actor id.
|
|
210
|
+
"""
|
|
211
|
+
mock_get_or_create_xapi_actor_id.return_value = (
|
|
212
|
+
"29e5b22b-b457-49fa-9633-6c0123305d18"
|
|
213
|
+
)
|
|
214
|
+
status = Mock()
|
|
215
|
+
|
|
216
|
+
assert (
|
|
217
|
+
self.serializer.get_actor_id(status)
|
|
218
|
+
== "29e5b22b-b457-49fa-9633-6c0123305d18"
|
|
219
|
+
)
|
|
220
|
+
mock_get_or_create_xapi_actor_id.assert_called_once_with(status.user)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
class TestTaxonomySerializer(TestCase):
|
|
224
|
+
"""
|
|
225
|
+
Test TaxonomySerializer
|
|
226
|
+
"""
|
|
227
|
+
|
|
228
|
+
def test_taxonomy_type_is_last(self):
|
|
229
|
+
"""
|
|
230
|
+
Test that taxonomy_type is the last field, matching the ClickHouse column order.
|
|
231
|
+
"""
|
|
232
|
+
assert TaxonomySerializer.Meta.fields[-1] == "taxonomy_type"
|
|
233
|
+
|
|
234
|
+
@patch("platform_plugin_aspects.sinks.serializers.get_competency_api")
|
|
235
|
+
def test_taxonomy_type(self, mock_get_competency_api):
|
|
236
|
+
"""
|
|
237
|
+
Test that the type comes from openedx-core's is_competency_taxonomy.
|
|
238
|
+
"""
|
|
239
|
+
api = mock_get_competency_api.return_value
|
|
240
|
+
api.is_competency_taxonomy.return_value = True
|
|
241
|
+
assert TaxonomySerializer().get_taxonomy_type(Mock()) == "competency"
|
|
242
|
+
api.is_competency_taxonomy.return_value = False
|
|
243
|
+
assert TaxonomySerializer().get_taxonomy_type(Mock()) == "tags"
|
|
244
|
+
|
|
245
|
+
@patch(
|
|
246
|
+
"platform_plugin_aspects.sinks.serializers.get_competency_api",
|
|
247
|
+
return_value=None,
|
|
248
|
+
)
|
|
249
|
+
def test_taxonomy_type_without_cbe(self, _):
|
|
250
|
+
"""
|
|
251
|
+
Test that every taxonomy is "tags" when openedx-core has no competency taxonomies.
|
|
252
|
+
"""
|
|
253
|
+
assert TaxonomySerializer().get_taxonomy_type(Mock()) == "tags"
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Test the student competency status sink module.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from unittest.mock import Mock, patch
|
|
6
|
+
|
|
7
|
+
from platform_plugin_aspects.sinks import (
|
|
8
|
+
StudentCompetencyCourseStatusSink,
|
|
9
|
+
StudentCompetencyStatusSink,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@patch("platform_plugin_aspects.sinks.ModelBaseSink.get_queryset")
|
|
14
|
+
def test_get_queryset(mock_get_queryset):
|
|
15
|
+
"""
|
|
16
|
+
Test the get_queryset method.
|
|
17
|
+
"""
|
|
18
|
+
sink = StudentCompetencyStatusSink(None, None)
|
|
19
|
+
|
|
20
|
+
sink.get_queryset()
|
|
21
|
+
|
|
22
|
+
mock_get_queryset.assert_called_once_with(None)
|
|
23
|
+
mock_get_queryset.return_value.select_related.assert_called_once_with(
|
|
24
|
+
"user", "tag", "status"
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@patch("platform_plugin_aspects.sinks.ModelBaseSink.get_queryset")
|
|
29
|
+
def test_group_status_get_queryset(mock_get_queryset):
|
|
30
|
+
"""
|
|
31
|
+
Test the group status sink keeps course-level groups and loads their tag and course.
|
|
32
|
+
"""
|
|
33
|
+
sink = StudentCompetencyCourseStatusSink(None, None)
|
|
34
|
+
|
|
35
|
+
sink.get_queryset()
|
|
36
|
+
|
|
37
|
+
mock_get_queryset.assert_called_once_with(None)
|
|
38
|
+
mock_get_queryset.return_value.filter.assert_called_once_with(
|
|
39
|
+
group__course__isnull=False
|
|
40
|
+
)
|
|
41
|
+
mock_get_queryset.return_value.filter.return_value.select_related.assert_called_once_with(
|
|
42
|
+
"user", "status", "group__tag", "group__course"
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@patch.object(StudentCompetencyStatusSink, "get_queryset")
|
|
47
|
+
def test_status_get_object(mock_get_queryset):
|
|
48
|
+
"""
|
|
49
|
+
Test a single dump goes through get_queryset, so it loads the row's user, tag and status in one query.
|
|
50
|
+
"""
|
|
51
|
+
sink = StudentCompetencyStatusSink(None, None)
|
|
52
|
+
|
|
53
|
+
result = sink.get_object(7)
|
|
54
|
+
|
|
55
|
+
mock_get_queryset.return_value.get.assert_called_once_with(id=7)
|
|
56
|
+
assert result == mock_get_queryset.return_value.get.return_value
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@patch.object(StudentCompetencyCourseStatusSink, "get_queryset")
|
|
60
|
+
def test_course_status_get_object(mock_get_queryset):
|
|
61
|
+
"""
|
|
62
|
+
Test a single dump goes through get_queryset, so it skips root and leaf groups too.
|
|
63
|
+
"""
|
|
64
|
+
sink = StudentCompetencyCourseStatusSink(None, None)
|
|
65
|
+
|
|
66
|
+
result = sink.get_object(7)
|
|
67
|
+
|
|
68
|
+
mock_get_queryset.return_value.get.assert_called_once_with(id=7)
|
|
69
|
+
assert result == mock_get_queryset.return_value.get.return_value
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def test_is_course_level():
|
|
73
|
+
"""
|
|
74
|
+
Test only statuses of groups with a course run are course-level.
|
|
75
|
+
"""
|
|
76
|
+
assert StudentCompetencyCourseStatusSink.is_course_level(
|
|
77
|
+
Mock(group=Mock(course_id=3))
|
|
78
|
+
)
|
|
79
|
+
assert not StudentCompetencyCourseStatusSink.is_course_level(
|
|
80
|
+
Mock(group=Mock(course_id=None))
|
|
81
|
+
)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Test the tag sink module.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from unittest.mock import Mock, patch
|
|
6
|
+
|
|
7
|
+
from platform_plugin_aspects.sinks import TaxonomySink
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@patch("platform_plugin_aspects.sinks.tag_sink.get_competency_api")
|
|
11
|
+
@patch("platform_plugin_aspects.sinks.ModelBaseSink.get_queryset")
|
|
12
|
+
def test_taxonomy_get_queryset(mock_get_queryset, mock_get_competency_api):
|
|
13
|
+
"""
|
|
14
|
+
Test the taxonomy sink joins CompetencyTaxonomy through openedx-core's API.
|
|
15
|
+
"""
|
|
16
|
+
api = Mock()
|
|
17
|
+
mock_get_competency_api.return_value = api
|
|
18
|
+
|
|
19
|
+
result = TaxonomySink(None, None).get_queryset()
|
|
20
|
+
|
|
21
|
+
api.select_competency_taxonomies.assert_called_once_with(
|
|
22
|
+
mock_get_queryset.return_value
|
|
23
|
+
)
|
|
24
|
+
assert result == api.select_competency_taxonomies.return_value
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@patch("platform_plugin_aspects.sinks.tag_sink.get_competency_api", return_value=None)
|
|
28
|
+
@patch("platform_plugin_aspects.sinks.ModelBaseSink.get_queryset")
|
|
29
|
+
def test_taxonomy_get_queryset_without_cbe(mock_get_queryset, _):
|
|
30
|
+
"""
|
|
31
|
+
Test the taxonomy sink still works when openedx-core has no competency taxonomies.
|
|
32
|
+
"""
|
|
33
|
+
assert TaxonomySink(None, None).get_queryset() == mock_get_queryset.return_value
|
|
@@ -11,6 +11,8 @@ from platform_plugin_aspects.signals import (
|
|
|
11
11
|
on_catalog_pathway_saved_txn,
|
|
12
12
|
on_externalid_saved_txn,
|
|
13
13
|
on_pathway_enrollment_saved_txn,
|
|
14
|
+
on_student_competency_course_status_saved_txn,
|
|
15
|
+
on_student_competency_status_saved_txn,
|
|
14
16
|
on_user_retirement,
|
|
15
17
|
receive_course_publish,
|
|
16
18
|
)
|
|
@@ -88,6 +90,60 @@ class SignalHandlersTestCase(TestCase):
|
|
|
88
90
|
object_id="7",
|
|
89
91
|
)
|
|
90
92
|
|
|
93
|
+
@patch("platform_plugin_aspects.signals.transaction")
|
|
94
|
+
def test_on_student_competency_status_saved(self, mock_transaction):
|
|
95
|
+
"""
|
|
96
|
+
Test that on_student_competency_status_saved_txn defers the dump to a robust on_commit.
|
|
97
|
+
"""
|
|
98
|
+
instance = Mock()
|
|
99
|
+
sender = Mock()
|
|
100
|
+
on_student_competency_status_saved_txn(sender, instance)
|
|
101
|
+
|
|
102
|
+
mock_transaction.on_commit.assert_called_once()
|
|
103
|
+
assert mock_transaction.on_commit.call_args.kwargs == {"robust": True}
|
|
104
|
+
|
|
105
|
+
@patch("platform_plugin_aspects.signals.transaction")
|
|
106
|
+
def test_on_student_competency_course_status_saved(self, mock_transaction):
|
|
107
|
+
"""
|
|
108
|
+
Test that on_student_competency_course_status_saved_txn defers the dump to a robust on_commit.
|
|
109
|
+
"""
|
|
110
|
+
instance = Mock()
|
|
111
|
+
sender = Mock()
|
|
112
|
+
on_student_competency_course_status_saved_txn(sender, instance)
|
|
113
|
+
|
|
114
|
+
mock_transaction.on_commit.assert_called_once()
|
|
115
|
+
assert mock_transaction.on_commit.call_args.kwargs == {"robust": True}
|
|
116
|
+
|
|
117
|
+
@patch("platform_plugin_aspects.tasks.dump_data_to_clickhouse")
|
|
118
|
+
@patch(
|
|
119
|
+
"platform_plugin_aspects.signals.StudentCompetencyCourseStatusSink.is_enabled"
|
|
120
|
+
)
|
|
121
|
+
@patch("platform_plugin_aspects.signals.transaction")
|
|
122
|
+
def test_course_status_queues_only_enabled_course_level_rows(
|
|
123
|
+
self, mock_transaction, mock_is_enabled, mock_dump_task
|
|
124
|
+
):
|
|
125
|
+
"""
|
|
126
|
+
Test that a course status is queued only when the sink is enabled and the group is course-level.
|
|
127
|
+
"""
|
|
128
|
+
mock_transaction.on_commit.side_effect = lambda fn, robust: fn()
|
|
129
|
+
course_row = Mock(id=7, group=Mock(course_id=3))
|
|
130
|
+
root_row = Mock(id=8, group=Mock(course_id=None))
|
|
131
|
+
|
|
132
|
+
mock_is_enabled.return_value = False
|
|
133
|
+
on_student_competency_course_status_saved_txn(Mock(), course_row)
|
|
134
|
+
mock_dump_task.delay.assert_not_called()
|
|
135
|
+
|
|
136
|
+
mock_is_enabled.return_value = True
|
|
137
|
+
on_student_competency_course_status_saved_txn(Mock(), root_row)
|
|
138
|
+
mock_dump_task.delay.assert_not_called()
|
|
139
|
+
|
|
140
|
+
on_student_competency_course_status_saved_txn(Mock(), course_row)
|
|
141
|
+
mock_dump_task.delay.assert_called_once_with(
|
|
142
|
+
sink_module="platform_plugin_aspects.sinks.student_competency_status_sink",
|
|
143
|
+
sink_name="StudentCompetencyCourseStatusSink",
|
|
144
|
+
object_id="7",
|
|
145
|
+
)
|
|
146
|
+
|
|
91
147
|
@patch("platform_plugin_aspects.tasks.dump_data_to_clickhouse")
|
|
92
148
|
def test_on_user_retirement(self, mock_dump_task):
|
|
93
149
|
"""
|
|
@@ -4,6 +4,7 @@ Test utils.
|
|
|
4
4
|
|
|
5
5
|
from unittest.mock import Mock, patch
|
|
6
6
|
|
|
7
|
+
import pytest
|
|
7
8
|
from django.conf import settings
|
|
8
9
|
from django.core.exceptions import ImproperlyConfigured
|
|
9
10
|
from django.test import TestCase
|
|
@@ -13,6 +14,7 @@ from platform_plugin_aspects.utils import (
|
|
|
13
14
|
generate_guest_token,
|
|
14
15
|
generate_superset_context,
|
|
15
16
|
get_ccx_courses,
|
|
17
|
+
get_competency_api,
|
|
16
18
|
get_model,
|
|
17
19
|
get_or_create_xapi_actor_id,
|
|
18
20
|
get_tags_for_block,
|
|
@@ -324,3 +326,38 @@ class TestUtils(TestCase):
|
|
|
324
326
|
|
|
325
327
|
with self.assertRaises(ValueError):
|
|
326
328
|
get_or_create_xapi_actor_id(Mock())
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
@patch("platform_plugin_aspects.utils.import_module")
|
|
332
|
+
@patch("platform_plugin_aspects.utils.apps.get_model")
|
|
333
|
+
def test_get_competency_api(mock_get_model, mock_import_module):
|
|
334
|
+
"""
|
|
335
|
+
Test the CBE API is imported once openedx-core has the CompetencyTaxonomy model.
|
|
336
|
+
"""
|
|
337
|
+
assert get_competency_api() == mock_import_module.return_value
|
|
338
|
+
|
|
339
|
+
mock_get_model.assert_called_once_with("openedx_learning", "CompetencyTaxonomy")
|
|
340
|
+
mock_import_module.assert_called_once_with("openedx_learning.api")
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
@patch("platform_plugin_aspects.utils.import_module")
|
|
344
|
+
@patch("platform_plugin_aspects.utils.apps.get_model", side_effect=LookupError)
|
|
345
|
+
def test_get_competency_api_without_cbe(_, mock_import_module):
|
|
346
|
+
"""
|
|
347
|
+
Test there is no CBE API when openedx-core has no CompetencyTaxonomy model.
|
|
348
|
+
"""
|
|
349
|
+
assert get_competency_api() is None
|
|
350
|
+
mock_import_module.assert_not_called()
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
@patch(
|
|
354
|
+
"platform_plugin_aspects.utils.import_module",
|
|
355
|
+
side_effect=ImportError("broken"),
|
|
356
|
+
)
|
|
357
|
+
@patch("platform_plugin_aspects.utils.apps.get_model")
|
|
358
|
+
def test_get_competency_api_raises_a_broken_import(_, __):
|
|
359
|
+
"""
|
|
360
|
+
Test an import error with the model present is raised, not reported as "no CBE".
|
|
361
|
+
"""
|
|
362
|
+
with pytest.raises(ImportError):
|
|
363
|
+
get_competency_api()
|
{platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/utils.py
RENAMED
|
@@ -11,6 +11,7 @@ import uuid
|
|
|
11
11
|
from importlib import import_module
|
|
12
12
|
from urllib.parse import urljoin
|
|
13
13
|
|
|
14
|
+
from django.apps import apps
|
|
14
15
|
from django.conf import settings
|
|
15
16
|
from django.core.exceptions import ImproperlyConfigured
|
|
16
17
|
from django.urls import reverse
|
|
@@ -212,6 +213,20 @@ def _superset_user_data(user: XBlockUser) -> dict:
|
|
|
212
213
|
}
|
|
213
214
|
|
|
214
215
|
|
|
216
|
+
def get_competency_api():
|
|
217
|
+
"""
|
|
218
|
+
Return ``openedx_learning.api`` if this openedx-core has competency taxonomies, else None.
|
|
219
|
+
|
|
220
|
+
Only a missing CompetencyTaxonomy model means "no CBE". Once the model exists, an
|
|
221
|
+
import error is a real breakage and is raised, not reported as "no competencies".
|
|
222
|
+
"""
|
|
223
|
+
try:
|
|
224
|
+
apps.get_model("openedx_learning", "CompetencyTaxonomy")
|
|
225
|
+
except LookupError:
|
|
226
|
+
return None
|
|
227
|
+
return import_module("openedx_learning.api")
|
|
228
|
+
|
|
229
|
+
|
|
215
230
|
def get_model(model_setting):
|
|
216
231
|
"""Load a model from a setting."""
|
|
217
232
|
MODEL_CONFIG = getattr(settings, "EVENT_SINK_CLICKHOUSE_MODEL_CONFIG", {})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: platform-plugin-aspects
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0
|
|
4
4
|
Summary: Aspects plugins for edx-platform
|
|
5
5
|
Author-email: Open edX Project <oscm@openedx.org>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -78,9 +78,25 @@ Below are the existing sink names and their corresponding object names (as neede
|
|
|
78
78
|
``CatalogPathway`` model and marks the pathway deleted in ``catalog_pathway``.
|
|
79
79
|
- ``PathwayEnrollmentSink`` - Listens for the ``post_save`` Django signal on the openedx-core
|
|
80
80
|
``PathwayEnrollment`` model. Object name: ``pathway_enrollment``
|
|
81
|
+
- ``StudentCompetencyStatusSink`` - Listens for the ``post_save`` Django signal on the openedx-core
|
|
82
|
+
``StudentCompetencyStatus`` model (a learner's mastery status for one competency). Object name:
|
|
83
|
+
``student_competency_status``
|
|
84
|
+
- ``StudentCompetencyCourseStatusSink`` - Listens for the ``post_save`` Django signal on the
|
|
85
|
+
openedx-core ``StudentCompetencyCriteriaGroupStatus`` model, course-level groups only (a learner's
|
|
86
|
+
mastery status for one competency in one course run, with the competency and course key). Object name:
|
|
87
|
+
``student_competency_course_status``
|
|
81
88
|
- ``UserRetirementSink`` - Listen for the ``USER_RETIRE_LMS_MISC`` Django signal and
|
|
82
89
|
remove the user PII information from ClickHouse. This is a special sink with no assigned object name.
|
|
83
90
|
|
|
91
|
+
The competency sinks need an openedx-core with competency-based education (the
|
|
92
|
+
``CompetencyTaxonomy`` model). Without it they stay inactive and ``TaxonomySink`` writes every
|
|
93
|
+
taxonomy's ``taxonomy_type`` as ``tags``. Their ``EVENT_SINK_CLICKHOUSE_MODEL_CONFIG`` keys are
|
|
94
|
+
``student_competency_status``, ``student_competency_course_status`` and ``competency_taxonomy``.
|
|
95
|
+
|
|
96
|
+
Apply the matching tutor-contrib-aspects ClickHouse migrations before upgrading to a version that
|
|
97
|
+
adds sink columns, such as ``taxonomy_type`` on ``taxonomy``. Sink inserts are positional CSV and
|
|
98
|
+
tolerate one bad row, so a single-row dump against the old schema is dropped without an error.
|
|
99
|
+
|
|
84
100
|
Commands
|
|
85
101
|
========
|
|
86
102
|
|
|
@@ -60,6 +60,7 @@ src/platform_plugin_aspects/sinks/course_overview_sink.py
|
|
|
60
60
|
src/platform_plugin_aspects/sinks/external_id_sink.py
|
|
61
61
|
src/platform_plugin_aspects/sinks/pathway_enrollment_sink.py
|
|
62
62
|
src/platform_plugin_aspects/sinks/serializers.py
|
|
63
|
+
src/platform_plugin_aspects/sinks/student_competency_status_sink.py
|
|
63
64
|
src/platform_plugin_aspects/sinks/tag_sink.py
|
|
64
65
|
src/platform_plugin_aspects/sinks/user_profile_sink.py
|
|
65
66
|
src/platform_plugin_aspects/sinks/user_retire_sink.py
|
|
@@ -70,6 +71,8 @@ src/platform_plugin_aspects/sinks/tests/test_course_overview_sink.py
|
|
|
70
71
|
src/platform_plugin_aspects/sinks/tests/test_external_id_sink.py
|
|
71
72
|
src/platform_plugin_aspects/sinks/tests/test_pathway_enrollment_sink.py
|
|
72
73
|
src/platform_plugin_aspects/sinks/tests/test_serializers.py
|
|
74
|
+
src/platform_plugin_aspects/sinks/tests/test_student_competency_status_sink.py
|
|
75
|
+
src/platform_plugin_aspects/sinks/tests/test_tag_sink.py
|
|
73
76
|
src/platform_plugin_aspects/sinks/tests/test_user_profile_sink.py
|
|
74
77
|
src/platform_plugin_aspects/sinks/tests/test_user_retire_sink.py
|
|
75
78
|
src/platform_plugin_aspects/static/css/superset.css
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"src/platform_plugin_aspects/sinks/external_id_sink.py",
|
|
77
77
|
"src/platform_plugin_aspects/sinks/pathway_enrollment_sink.py",
|
|
78
78
|
"src/platform_plugin_aspects/sinks/serializers.py",
|
|
79
|
+
"src/platform_plugin_aspects/sinks/student_competency_status_sink.py",
|
|
79
80
|
"src/platform_plugin_aspects/sinks/tag_sink.py",
|
|
80
81
|
"src/platform_plugin_aspects/sinks/tests/test_base_sink.py",
|
|
81
82
|
"src/platform_plugin_aspects/sinks/tests/test_catalog_pathway_sink.py",
|
|
@@ -84,6 +85,8 @@
|
|
|
84
85
|
"src/platform_plugin_aspects/sinks/tests/test_external_id_sink.py",
|
|
85
86
|
"src/platform_plugin_aspects/sinks/tests/test_pathway_enrollment_sink.py",
|
|
86
87
|
"src/platform_plugin_aspects/sinks/tests/test_serializers.py",
|
|
88
|
+
"src/platform_plugin_aspects/sinks/tests/test_student_competency_status_sink.py",
|
|
89
|
+
"src/platform_plugin_aspects/sinks/tests/test_tag_sink.py",
|
|
87
90
|
"src/platform_plugin_aspects/sinks/tests/test_user_profile_sink.py",
|
|
88
91
|
"src/platform_plugin_aspects/sinks/tests/test_user_retire_sink.py",
|
|
89
92
|
"src/platform_plugin_aspects/sinks/user_profile_sink.py",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/apps.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/tasks.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/urls.py
RENAMED
|
File without changes
|
{platform_plugin_aspects-2.2.1 → platform_plugin_aspects-3.0.0}/src/platform_plugin_aspects/views.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|