Skip to content

Commit

Permalink
Merge pull request #129 from Code-Institute-Org/fix_activity_log_courses
Browse files Browse the repository at this point in the history
Fix activity log courses
  • Loading branch information
ray-codeinstitute authored Jan 7, 2025
2 parents ac07cbc + d96c62e commit 50b2c33
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Install AWS CLI
run: sudo apt-get update -y && sudo apt-get install -y awscli
- run: docker info
- name: Docker Login
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
Expand Down
9 changes: 8 additions & 1 deletion lms/djangoapps/ci_program/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,14 @@ def _get_or_infer_block_id(
children = course_xblock.get('fields', {}).get('children')
if children:
activity_state = json.loads(activity_log[0].state)
section_block = children[activity_state.get('position', 1) - 1]
# Bugs have occured when student was enrolled in multiple runs
# of the same course where the number of children was different
child_index = activity_state.get('position', 1) - 1
if len(children) > child_index:
section_block = children[child_index]
else:
log.warning("Activity log position out of sync with course: %s %s", child_index, course_key)
section_block = children[0]
block_id = section_block[1] if section_block else None
return block_id

Expand Down

0 comments on commit 50b2c33

Please sign in to comment.