Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: sumac release support #11

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: Lint Commit Messages
on: [pull_request]

jobs:
commitlint:
uses: openedx/.github/.github/workflows/commitlint.yml@master
25 changes: 25 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: labeler

on:
pull_request:
branches:
- 'master'

jobs:
labeler:
runs-on: ubuntu-latest
name: Label the PR size
steps:
- uses: codelytv/pr-size-labeler@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
xs_max_size: '10'
s_max_size: '100'
m_max_size: '500'
l_max_size: '1000'
fail_if_xl: 'true'
message_if_xl: >
This PR exceeds the recommended size of 1000 lines.
Please make sure you are NOT addressing multiple issues with one PR.
Note this PR might be rejected due to its size.
github_api_url: 'api.github.com'
40 changes: 40 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Test suite workflow

on:
pull_request:
branches:
- 'master'

jobs:
Running-test:
runs-on: ubuntu-latest
strategy:
max-parallel: 2
matrix:
python-version: ["3.11"]
django: ["42"]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Cache dependency
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements/test.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Dev Requirements
run: |
make install-dev-dependencies
- name: Run Python Tests
run: |
export TOXENV=${TOX_ENV//./}
make run-tests
env:
TOX_ENV: py${{matrix.python-version}}-django${{matrix.django}}
31 changes: 30 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
.DEFAULT_GOAL := help

ifdef TOXENV
TOX := tox -- #to isolate each tox environment if TOXENV is defined
endif

.PHONY: dev.clean dev.build dev.run upgrade help requirements
.PHONY: extract_translations compile_translations
.PHONY: detect_changed_source_translations dummy_translations build_dummy_translations
Expand All @@ -17,6 +21,15 @@ TRANSLATIONS_DIR := $(PACKAGE_NAME)/translations
help:
@perl -nle'print $& if m{^[\.a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}'

install-dev-dependencies: ## install tox
pip install -r requirements/tox.txt

clean: ## delete most git-ignored files
find . -name '__pycache__' -exec rm -rf {} +
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +

# Define PIP_COMPILE_OPTS=-v to get more information during make upgrade.
PIP_COMPILE = pip-compile --upgrade $(PIP_COMPILE_OPTS)

Expand All @@ -33,12 +46,16 @@ upgrade: ## update the requirements/*.txt files with the latest packages satisfy
$(PIP_COMPILE) -o requirements/quality.txt requirements/quality.in
$(PIP_COMPILE) -o requirements/ci.txt requirements/ci.in
$(PIP_COMPILE) -o requirements/dev.txt requirements/dev.in
$(PIP_COMPILE) -o requirements/tox.txt requirements/tox.in

requirements: ## install development environment requirements
pip install -r requirements/pip.txt
pip install -qr requirements/pip-tools.txt
pip install -r requirements/dev.txt

test_requirements:
pip install -r requirements/test.txt

dev.clean:
-docker rm $(REPO_NAME)-dev
-docker rmi $(REPO_NAME)-dev
Expand Down Expand Up @@ -77,4 +94,16 @@ push_translations: extract_translations ## push translations to transifex
cd $(PACKAGE_NAME) && i18n_tool transifex push

symlink_translations:
if [ ! -d "$(TRANSLATIONS_DIR)" ]; then ln -s locale/ $(TRANSLATIONS_DIR); fi
if [ ! -d "$(TRANSLATIONS_DIR)" ]; then ln -s locale/ $(TRANSLATIONS_DIR); fi

test-python: clean ## Run test suite.
$(TOX) pip install -r requirements/test.txt --exists-action w
$(TOX) coverage run --source="." -m pytest ./webhook_xblock --ignore-glob='**/integration/*'
$(TOX) coverage report -m --fail-under=71

quality: clean ## Run quality test.
$(TOX) pycodestyle ./webhook_xblock
$(TOX) pylint ./webhook_xblock --rcfile=./setup.cfg
$(TOX) isort --check-only --diff ./webhook_xblock --skip ./webhook_xblock/migrations

run-tests: test-python quality
102 changes: 61 additions & 41 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## Webhook XBlock
Webhook XBlock
==============

This repository provides an X-block that triggers a webhook by sending a payload with basic information
about the course and student to a configurable URL.
about the course and student to a configurable URL.

The XBlock can be set in three modes:
* Send the payload every time the user visits the course unit
Expand All @@ -10,52 +11,71 @@ The XBlock can be set in three modes:

Other **available configurations** are:
* Add a text to the component to show to the student
* Configure the button text (in case the student is allow to send the payload)
* Configure the button text (in case the student is allowed to send the payload)
* Send extra information in the payload
* Send the student's course grade


Description of the payload
------------------
---------------------------

* payload_name: A string to help identify the course component that is sending the payload.
* anonymous_student_id: A string that contains an anonymized identifier of the student.
* timestamp: Timestamp for when the student visits the xblock component.
* student_is_active: Boolean that indicates whether the student is active in the platform.
* student_email: Email of the student.
* student_date_joined: Timestamp for when the student got registered in the platform.
* student_username: Username of the student.
* **payload_name**: A string to help identify the course component that is sending the payload.
* **anonymous_student_id**: A string that contains an anonymized identifier of the student.
* **timestamp**: Timestamp for when the student visits the XBlock component.
* **student_is_active**: Boolean that indicates whether the student is active on the platform.
* **student_email**: Email of the student.
* **student_date_joined**: Timestamp for when the student got registered on the platform.
* **student_username**: Username of the student.

If the *Send course grade* option is enabled, three extra fields are added:
* passed: Boolean representing whether the course has been passed according to the course's grading policy.
* percent: A float representing the overall grade for the course.
* letter_grade: A letter grade as defined in grading policy (e.g. 'A' 'B' 'C') or None.

```
{
'payload_name': 'course-started',
'anonymous_student_id': '8db9fe4e00b4f713d37187bb363fb7cc',
'percent': 0.0,
'timestamp': '2021-07-26T07:28:47.243653',
'passed': False,
'student_is_active': True,
'student_email': 'test@example.com',
'course_id': 'course-v1:edunext+01+test',
'student_date_joined': '2021-04-22T13:15:43.457066-05:00',
'student_username': 'testUser',
'letter_grade': None
}
```

Enabling XBlock in Studio
------------------

You can enable the Webhook XBlock in Studio by
modifying the advanced settings for your course:

* Navigate to **Settings** -> **Advanced Settings** and go to the **Advanced Module List** setting.
* To enable the XBlock for your course, add `"webhook-xblock"` to the list and save the changes.

* **passed**: Boolean representing whether the course has been passed according to the course's grading policy.
* **percent**: A float representing the overall grade for the course.
* **letter_grade**: A letter grade as defined in grading policy (e.g., 'A', 'B', 'C') or None.


.. code-block:: JSON
{
'payload_name': 'course-started',
'anonymous_student_id': '8db9fe4e00b4f713d37187bb363fb7cc',
'percent': 0.0,
'timestamp': '2021-07-26T07:28:47.243653',
'passed': False,
'student_is_active': True,
'student_email': 'test@example.com',
'course_id': 'course-v1:edunext+01+test',
'student_date_joined': '2021-04-22T13:15:43.457066-05:00',
'student_username': 'testUser',
'letter_grade': None
}


Compatibility Notes
--------------------

+------------------+---------------+
| Open edX Release | Version |
+==================+===============+
| Ironwood | < 1.0.0 |
+------------------+---------------+
| Juniper | < 1.0.0 |
+------------------+---------------+
| Koa | < 1.0.0 |
+------------------+---------------+
| Lilac | < 1.0.0 |
+------------------+---------------+
| Maple | < 1.0.0 |
+------------------+---------------+
| Nutmeg | < 1.0.0 |
+------------------+---------------+
| Olive | < 1.0.0 |
+------------------+---------------+
| Palm | < 1.0.0 |
+------------------+---------------+
| Quince | < 1.0.0 |
+------------------+---------------+
| Redwood | >= 1.0.0 |
+------------------+---------------+
| Sumac | >= 1.0.0 |
+------------------+---------------+

Usage
=======
Expand Down
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
if __name__ == "__main__":
os.environ.setdefault(
"DJANGO_SETTINGS_MODULE",
"webhook_xblock.locale.settings"
"webhook_xblock.settings.test"
)

execute_from_command_line(sys.argv)
93 changes: 76 additions & 17 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,83 @@
#
# This file is autogenerated by pip-compile
# To update, run:
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# make upgrade
#
appdirs==1.4.4 # via fs
fs==2.4.13 # via xblock
lxml==4.6.3 # via xblock
mako==1.1.4 # via xblock-utils
markupsafe==1.1.1 # via mako, xblock
python-dateutil==2.8.2 # via xblock
pytz==2021.1 # via fs, xblock
pyyaml==5.3.1 # via xblock
simplejson==3.17.3 # via xblock-utils
six==1.16.0 # via fs, python-dateutil
typing==3.7.4.3 # via fs
web-fragments==1.1.0 # via xblock, xblock-utils
webob==1.8.7 # via xblock
xblock-utils==2.1.3 # via -r requirements/base.in
xblock==1.4.2 # via -r requirements/base.in, xblock-utils
appdirs==1.4.4
# via fs
asgiref==3.8.1
# via django
boto3==1.35.89
# via fs-s3fs
botocore==1.35.89
# via
# boto3
# s3transfer
django==4.2.17
# via
# -c https://raw.githubusercontent.com/openedx/edx-lint/master/edx_lint/files/common_constraints.txt
# openedx-django-pyfs
fs==2.4.16
# via
# fs-s3fs
# openedx-django-pyfs
# xblock
fs-s3fs==1.1.1
# via openedx-django-pyfs
jmespath==1.0.1
# via
# boto3
# botocore
lazy==1.6
# via xblock
lxml==5.3.0
# via xblock
mako==1.3.8
# via
# xblock
# xblock-utils
markupsafe==3.0.2
# via
# mako
# xblock
openedx-django-pyfs==3.7.0
# via xblock
python-dateutil==2.9.0.post0
# via
# botocore
# xblock
pytz==2024.2
# via xblock
pyyaml==6.0.2
# via xblock
s3transfer==0.10.4
# via boto3
simplejson==3.19.3
# via
# xblock
# xblock-utils
six==1.17.0
# via
# fs
# fs-s3fs
# python-dateutil
sqlparse==0.5.3
# via django
urllib3==2.3.0
# via botocore
web-fragments==2.2.0
# via
# xblock
# xblock-utils
webob==1.8.9
# via xblock
xblock[django]==5.1.0
# via
# -r requirements/base.in
# xblock-utils
xblock-utils==4.0.0
# via -r requirements/base.in

# The following packages are considered to be unsafe in a requirements file:
# setuptools
Loading
Loading