-
Notifications
You must be signed in to change notification settings - Fork 12
feat: add new field for Content-/UserDate models to support assignments #324
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Generated by Django 4.2.22 on 2025-08-20 09:11 | ||
|
|
||
| import opaque_keys.edx.django.models | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('edx_when', '0008_courseversion_block_type'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name='contentdate', | ||
| name='assignment_title', | ||
| field=models.CharField(blank=True, db_index=True, default='', max_length=255), | ||
| ), | ||
| migrations.AddField( | ||
| model_name='contentdate', | ||
| name='course_name', | ||
| field=models.CharField(blank=True, default='', max_length=255), | ||
| ), | ||
| migrations.AddField( | ||
| model_name='contentdate', | ||
| name='subsection_name', | ||
| field=models.CharField(blank=True, db_index=True, default='', max_length=255), | ||
| ), | ||
| migrations.AddField( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this is the first instance of content data in the userdate model. Why do we need to introduce it here?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this specific to the user or would it be the same for each There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This field should not have a User-related context (unless I miss some business requirements) and must be placed in the I want to perf-test the course info API w/ and w/o this field to check on the clear necessity to add it here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
That's the logic behind putting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Should/can we rename the field name then (the current naming is really misleading)? To something like
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should: this naming was not introduced by this PR - it is already used extensively throughout the codebase.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cmltaWt0 @e0d The following code should help clarify the meaning of block_data = get_course_blocks(user, course_usage_key, allow_start_dates_in_future=True, include_completion=True)
...
for section_key in block_data.get_children(course_usage_key):
for subsection_key in block_data.get_children(section_key):
...
first_component_block_id = get_first_component_of_block(subsection_key, block_data)As we can see, the value of |
||
| model_name='userdate', | ||
| name='first_component_block_id', | ||
| field=opaque_keys.edx.django.models.UsageKeyField(blank=True, db_index=True, max_length=255, null=True), | ||
| ), | ||
| migrations.AddIndex( | ||
| model_name='contentdate', | ||
| index=models.Index(fields=['assignment_title', 'course_id'], name='edx_when_assignment_course_idx'), | ||
| ), | ||
| migrations.AddIndex( | ||
| model_name='contentdate', | ||
| index=models.Index(fields=['subsection_name', 'course_id'], name='edx_when_subsection_course_idx'), | ||
| ), | ||
| migrations.AddIndex( | ||
| model_name='userdate', | ||
| index=models.Index(fields=['user', 'first_component_block_id'], name='edx_when_user_first_block_idx'), | ||
| ), | ||
| ] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assignment feels like a pretty robust concept, perhaps it should eventually be a new model entirely. How do we expect the assignment_title to be calculated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I'm stepping in for @andrii-hantkovskyi.
assignment_titleis computed in theget_course_assignments()function, in a loop over course blocks:title = block_data.get_xblock_field(subsection_key, 'display_name', _('Assignment'))