Skip to content

Commit

Permalink
Merge branch 'main' into huniafatima/deprecate-edx-sphinx-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
huniafatima-arbi authored Oct 2, 2024
2 parents dfec69c + a14fb39 commit e93f52d
Show file tree
Hide file tree
Showing 20 changed files with 300 additions and 403 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04]
python-version: ['3.11']
python-version: ['3.12']
toxenv: [django42, quality, pii_check]

steps:
Expand All @@ -38,7 +38,7 @@ jobs:
run: tox

- name: Run coverage
if: matrix.python-version == '3.11' && matrix.toxenv == 'django42'
if: matrix.python-version == '3.12' && matrix.toxenv == 'django42'
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ github.token }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upgrade-python-requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: openedx/.github/.github/workflows/upgrade-python-requirements.yml@master
with:
branch: ${{ github.event.inputs.branch || 'main' }}
python_version: "3.8"
python_version: "3.12"
# optional parameters below; fill in if you'd like github or email notifications
# user_reviewers: ""
# team_reviewers: ""
Expand Down
33 changes: 29 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,50 @@ MAINTAINER [email protected]

# make; necessary to provision the container

# ENV variables for Python 3.12 support
ARG PYTHON_VERSION=3.12
ENV TZ=UTC
ENV TERM=xterm-256color
ENV DEBIAN_FRONTEND=noninteractive

# software-properties-common is needed to setup Python 3.12 env
RUN apt-get update && \
apt-get install -y software-properties-common && \
apt-add-repository -y ppa:deadsnakes/ppa

# If you add a package here please include a comment above describing what it is used for
RUN apt-get update && apt-get -qy install --no-install-recommends \
build-essential \
language-pack-en \
locales \
python3.8 \
python3-pip \
libmysqlclient-dev \
pkg-config \
libssl-dev \
python3-dev \
gcc \
make \
git
git \
curl \
python3-pip \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-dev \
python${PYTHON_VERSION}-distutils

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN pip install --upgrade pip setuptools
# delete apt package lists because we do not need them inflating our image
RUN rm -rf /var/lib/apt/lists/*

# need to use virtualenv pypi package with Python 3.12
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION}
RUN pip install virtualenv

# Create virtual environment with Python 3.12
ENV VIRTUAL_ENV=/edx/venvs/edx-exams
RUN virtualenv -p python${PYTHON_VERSION} $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

# python is python3
RUN ln -s /usr/bin/python3 /usr/bin/python

RUN locale-gen en_US.UTF-8
Expand Down
7 changes: 5 additions & 2 deletions edx_exams/apps/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ def update_attempt_status(attempt_id, to_status):
if not allowed_to_start:
raise ExamIllegalStatusTransition(error_msg)

attempt_obj.start_time = datetime.now(pytz.UTC)
attempt_obj.allowed_time_limit_mins = _calculate_allowed_mins(attempt_obj.user, attempt_obj.exam)
# Once start time, and end time by extension, has been set further transitions to started
# must not update this value
if not attempt_obj.start_time:
attempt_obj.start_time = datetime.now(pytz.UTC)
attempt_obj.allowed_time_limit_mins = _calculate_allowed_mins(attempt_obj.user, attempt_obj.exam)

course_key = CourseKey.from_string(attempt_obj.exam.course_id)
usage_key = UsageKey.from_string(attempt_obj.exam.content_id)
Expand Down
5 changes: 1 addition & 4 deletions edx_exams/apps/core/signals/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ def listen_for_course_access_role_added(sender, signal, **kwargs): # pylint: di
if role not in COURSE_STAFF_ROLES:
return

user, _ = User.objects.get_or_create(
username=user_data.pii.username,
email=user_data.pii.email,
)
user, _ = User.objects.get_or_create(username=user_data.pii.username)
CourseStaffRole.objects.get_or_create(
user=user,
course_id=course_key,
Expand Down
15 changes: 15 additions & 0 deletions edx_exams/apps/core/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,21 @@ def test_cannot_start_if_other_attempts_active(self):
update_attempt_status(self.exam_attempt.id, ExamAttemptStatus.started)
self.assertIn('another exam attempt is currently active!', str(exc.exception))

def test_ready_to_submit_to_started(self):
"""
Test transition to started after initial start time has been set. This should not
alter the existing start time.
"""
with freeze_time(timezone.now()):
self.exam_attempt.status = ExamAttemptStatus.ready_to_submit
self.exam_attempt.start_time = timezone.now()-timedelta(minutes=10)
self.exam_attempt.allowed_time_limit_mins = 30
self.exam_attempt.save()

update_attempt_status(self.exam_attempt.id, ExamAttemptStatus.started)
self.exam_attempt.refresh_from_db()
self.assertEqual(self.exam_attempt.start_time, timezone.now()-timedelta(minutes=10))


class TestGetAttemptById(ExamsAPITestCase):
"""
Expand Down
26 changes: 26 additions & 0 deletions edx_exams/apps/core/tests/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,29 @@ def test_course_access_role_remove_single_role(self):
roles,
['instructor']
)

def test_course_access_role_email_change(self):
"""
Test that if a user updates their email, additional course staff roles are able to be added.
"""
role_event_data = self._get_event_data(self.course_id, self.existing_user.username, 'staff')
event_metadata = self._get_event_metadata(COURSE_ACCESS_ROLE_ADDED)
event_kwargs = {
'course_access_role_data': role_event_data,
'metadata': event_metadata,
}
listen_for_course_access_role_added(None, COURSE_ACCESS_ROLE_ADDED, **event_kwargs)

self.existing_user.email = '[email protected]'
self.existing_user.save()

other_course = 'course-v1:another-course-2024'
role_event_data = self._get_event_data(other_course, self.existing_user.username, 'staff')
event_metadata = self._get_event_metadata(COURSE_ACCESS_ROLE_ADDED)
event_kwargs = {
'course_access_role_data': role_event_data,
'metadata': event_metadata,
}
listen_for_course_access_role_added(None, COURSE_ACCESS_ROLE_ADDED, **event_kwargs)

self.assertEqual(len(CourseStaffRole.objects.filter(user=self.existing_user)), 2)
6 changes: 6 additions & 0 deletions edx_exams/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@
EXAMS_DASHBOARD_MFE_URL,
)

CSRF_TRUSTED_ORIGINS = (
'http://localhost:2001',
LEARNING_MICROFRONTEND_URL,
EXAMS_DASHBOARD_MFE_URL,
)

ALLOWED_HOSTS = ['*']

#####################################################################
Expand Down
45 changes: 19 additions & 26 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# make upgrade
Expand All @@ -10,24 +10,22 @@ asgiref==3.8.1
# via
# django
# django-cors-headers
async-timeout==4.0.3
# via redis
attrs==24.2.0
# via
# -r requirements/base.in
# lti-consumer-xblock
# openedx-events
bleach==6.1.0
# via lti-consumer-xblock
boto3==1.35.9
boto3==1.35.22
# via fs-s3fs
botocore==1.35.9
botocore==1.35.22
# via
# boto3
# s3transfer
certifi==2024.8.30
# via requests
cffi==1.17.0
cffi==1.17.1
# via
# cryptography
# pynacl
Expand All @@ -45,15 +43,15 @@ coreapi==2.3.3
# openapi-codec
coreschema==0.0.4
# via coreapi
cryptography==43.0.0
cryptography==43.0.1
# via
# pyjwt
# social-auth-core
defusedxml==0.8.0rc2
# via
# python3-openid
# social-auth-core
django==4.2.15
django==4.2.16
# via
# -c requirements/common_constraints.txt
# -r requirements/base.in
Expand Down Expand Up @@ -99,7 +97,7 @@ django-extensions==3.2.3
# via -r requirements/base.in
django-filter==24.3
# via lti-consumer-xblock
django-model-utils==4.5.1
django-model-utils==5.0.0
# via -r requirements/base.in
django-rest-swagger==2.2.0
# via -r requirements/base.in
Expand Down Expand Up @@ -128,9 +126,9 @@ drf-jwt==1.19.2
# via edx-drf-extensions
drf-yasg==1.21.7
# via edx-api-doc-tools
edx-api-doc-tools==1.8.0
edx-api-doc-tools==2.0.0
# via -r requirements/base.in
edx-auth-backends==4.3.0
edx-auth-backends==4.4.0
# via -r requirements/base.in
edx-ccx-keys==1.3.0
# via
Expand All @@ -148,28 +146,28 @@ edx-django-utils==5.15.0
# edx-rest-api-client
# edx-toggles
# openedx-events
edx-drf-extensions==10.3.0
edx-drf-extensions==10.4.0
# via -r requirements/base.in
edx-event-bus-kafka==5.8.1
# via -r requirements/base.in
edx-event-bus-redis==0.5.0
# via -r requirements/base.in
edx-opaque-keys[django]==2.10.0
edx-opaque-keys[django]==2.11.0
# via
# -r requirements/base.in
# edx-ccx-keys
# edx-drf-extensions
# lti-consumer-xblock
# openedx-events
edx-rest-api-client==5.7.1
edx-rest-api-client==6.0.0
# via -r requirements/base.in
edx-toggles==5.2.0
# via
# edx-event-bus-kafka
# edx-event-bus-redis
edx-token-utils==0.2.1
# via -r requirements/base.in
fastavro==1.9.5
fastavro==1.9.7
# via openedx-events
fs==2.4.16
# via
Expand All @@ -180,7 +178,7 @@ fs-s3fs==1.1.1
# via openedx-django-pyfs
future==1.0.0
# via pyjwkest
idna==3.8
idna==3.10
# via requests
inflection==0.5.1
# via drf-yasg
Expand Down Expand Up @@ -226,7 +224,7 @@ openapi-codec==1.3.2
# via django-rest-swagger
openedx-django-pyfs==3.7.0
# via lti-consumer-xblock
openedx-events==9.12.0
openedx-events==9.14.1
# via
# -r requirements/base.in
# edx-event-bus-kafka
Expand Down Expand Up @@ -258,7 +256,7 @@ pyjwt[crypto]==2.9.0
# social-auth-core
pymemcache==4.0.0
# via -r requirements/base.in
pymongo==4.8.0
pymongo==4.9.1
# via edx-opaque-keys
pynacl==1.5.0
# via edx-django-utils
Expand All @@ -270,7 +268,7 @@ python-slugify==8.0.4
# via code-annotations
python3-openid==3.2.0
# via social-auth-core
pytz==2024.1
pytz==2024.2
# via
# -r requirements/base.in
# drf-yasg
Expand All @@ -290,7 +288,6 @@ requests==2.32.3
# edx-rest-api-client
# pyjwkest
# requests-oauthlib
# slumber
# social-auth-core
requests-oauthlib==2.0.0
# via social-auth-core
Expand All @@ -312,8 +309,6 @@ six==1.16.0
# fs-s3fs
# pyjwkest
# python-dateutil
slumber==0.7.1
# via edx-rest-api-client
social-auth-app-django==5.4.2
# via edx-auth-backends
social-auth-core==4.5.4
Expand All @@ -330,14 +325,12 @@ stevedore==5.3.0
text-unidecode==1.3
# via python-slugify
typing-extensions==4.12.2
# via
# asgiref
# edx-opaque-keys
# via edx-opaque-keys
uritemplate==4.1.1
# via
# coreapi
# drf-yasg
urllib3==1.26.20
urllib3==2.2.3
# via
# botocore
# requests
Expand Down
16 changes: 6 additions & 10 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# make upgrade
Expand All @@ -14,27 +14,23 @@ coverage==7.6.1
# via -r requirements/ci.in
distlib==0.3.8
# via virtualenv
filelock==3.15.4
filelock==3.16.1
# via
# tox
# virtualenv
packaging==24.1
# via
# pyproject-api
# tox
platformdirs==4.2.2
platformdirs==4.3.6
# via
# tox
# virtualenv
pluggy==1.5.0
# via tox
pyproject-api==1.7.1
pyproject-api==1.8.0
# via tox
tomli==2.0.1
# via
# pyproject-api
# tox
tox==4.18.0
tox==4.20.0
# via -r requirements/ci.in
virtualenv==20.26.3
virtualenv==20.26.5
# via tox
Loading

0 comments on commit e93f52d

Please sign in to comment.