Skip to content

Commit 50b2c33

Browse files
Merge pull request #129 from Code-Institute-Org/fix_activity_log_courses
Fix activity log courses
2 parents ac07cbc + d96c62e commit 50b2c33

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

.github/workflows/python-app.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ jobs:
1313

1414
steps:
1515
- uses: actions/checkout@v2
16-
- name: Install AWS CLI
17-
run: sudo apt-get update -y && sudo apt-get install -y awscli
1816
- run: docker info
1917
- name: Docker Login
2018
run: AWS_DEFAULT_REGION=eu-west-1 AWS_ACCESS_KEY_ID=${{secrets.AWS_ACCESS_KEY}} AWS_SECRET_ACCESS_KEY=${{secrets.AWS_SECRET_ACCESS_KEY}} aws ecr get-login-password | docker login --username AWS --password-stdin 949266541515.dkr.ecr.eu-west-1.amazonaws.com/ci-edx-platform

lms/djangoapps/ci_program/models.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,14 @@ def _get_or_infer_block_id(
302302
children = course_xblock.get('fields', {}).get('children')
303303
if children:
304304
activity_state = json.loads(activity_log[0].state)
305-
section_block = children[activity_state.get('position', 1) - 1]
305+
# Bugs have occured when student was enrolled in multiple runs
306+
# of the same course where the number of children was different
307+
child_index = activity_state.get('position', 1) - 1
308+
if len(children) > child_index:
309+
section_block = children[child_index]
310+
else:
311+
log.warning("Activity log position out of sync with course: %s %s", child_index, course_key)
312+
section_block = children[0]
306313
block_id = section_block[1] if section_block else None
307314
return block_id
308315

0 commit comments

Comments
 (0)