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

Fixing lookup of old studentactivity #121

Merged
merged 1 commit into from
Feb 29, 2024
Merged
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
11 changes: 10 additions & 1 deletion lms/djangoapps/ci_program/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,23 @@ def _get_or_infer_block_id(
block_id = activity_log[0].module_state_key.block_id
if block_id == 'course' and course_key:
latest_course_id = course_key.html_id().split(':')[1]
course_xblock = module_tree[latest_course_id]
course_xblock = self._find_course(latest_course_id, module_tree)
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]
block_id = section_block[1] if section_block else None
return block_id

def _find_course(self, course_id, module_tree):
if course_id in module_tree:
return module_tree[course_id]
else:
for key in module_tree:
if course_id.startswith(key.rsplit('+', 1)[0]):
return module_tree[key]
return {}

def _read_module_tree_from_mongo(self, user):
if self.course_codes.exists():
aggregate_query = self._create_aggregate_query()
Expand Down
Loading