Skip to content

Conversation

@andrii-hantkovskyi
Copy link

Description

Extends the ContentDate and UserDate models in edx-when to support enhanced assignment metadata and future scheduling use cases.

ContentDate model changes:

  • Added assignment_title, course_name, and subsection_name fields to improve tracking and display of assignment metadata.
  • Added indexes to support efficient filtering and lookup by assignment and subsection per course.

UserDate model changes:

  • Added first_component_block_id for referencing the starting block of a user’s assignment attempt.
  • Added user_date_value to explicitly store user-specific dates.
  • Indexed both new fields for improved query performance.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jun 25, 2025
@openedx-webhooks
Copy link

Thanks for the pull request, @andrii-hantkovskyi!

This repository is currently maintained by @openedx/openedx-unmaintained.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@andrii-hantkovskyi andrii-hantkovskyi force-pushed the rg/extend-date-models-to-support-assignments branch from 6857b51 to 582089c Compare June 25, 2025 11:45
@andrii-hantkovskyi andrii-hantkovskyi self-assigned this Jul 1, 2025
@andrii-hantkovskyi andrii-hantkovskyi removed their assignment Jul 14, 2025
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Jul 15, 2025
@mphilbrick211 mphilbrick211 added the FC Relates to an Axim Funded Contribution project label Jul 15, 2025
Copy link

@e0d e0d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to discuss my questions before moving forward with this PR.

name='first_component_block_id',
field=opaque_keys.edx.django.models.UsageKeyField(blank=True, db_index=True, max_length=255, null=True),
),
migrations.AddField(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it necessary to add this new field?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user_date_value field is currently unnecessary, removed.

name='subsection_name',
field=models.CharField(blank=True, db_index=True, default='', max_length=255),
),
migrations.AddField(
Copy link

Choose a reason for hiding this comment

The 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?

Copy link

@Serj-N Serj-N Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first_component_block_id field will be included in the response of the "all-course-dates" api endpoint.
Calculating this value in runtime is not trivial, and having it here on UserDate makes it much easier.

Copy link

Choose a reason for hiding this comment

The 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 ContentDate? How does it different or related to the location field in ContentDate.

Copy link

Choose a reason for hiding this comment

The 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 ContentDate. I believe @e0d is totally right.

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.

Copy link

@Serj-N Serj-N Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The location attribute on ContentDate is the key of the assignment block itself, and it is not user-specific.
The first_component_block_id attribute on UserDate is the key of the first unit of the block available to the user, which means it is user-specific.
Here is a possible scenario that may help explain it:

  1. We have a subsection with Unit 1 followed by Unit 2 followed by Unit 3.
  2. Two users - User A and User B - have access to this subsection as an assignment.
  3. However, User A belongs to a cohort that does not have access to Unit 1.
  4. In this case, ContentDate.location will be the same for the two users (the subsection), but UserDate.first_component_block_id will differ: Unit 1 for User B, but Unit 2 for User A.

That's the logic behind putting first_component_block_id on the UserDate model.

Copy link

@cmltaWt0 cmltaWt0 Sep 10, 2025

Choose a reason for hiding this comment

The 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 first_available_block_id.

Copy link

Choose a reason for hiding this comment

The 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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cmltaWt0 @e0d The following code should help clarify the meaning of first_component_block_id and why it is considered user-specific in the existing codebase. In the get_course_assignments() function we have these lines (abbreviated):

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 first_component_block_id is based on the course structure (block_data) - which is collected for a specfic user and only includes what they have access to.

operations = [
migrations.AddField(
model_name='contentdate',
name='assignment_title',
Copy link

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?

Copy link

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_title is computed in the get_course_assignments() function, in a loop over course blocks:
title = block_data.get_xblock_field(subsection_key, 'display_name', _('Assignment'))

@e0d
Copy link

e0d commented Aug 5, 2025

Checking in with a large site using edx_when, they have over 3M rows in edx_when_contentdate and around 43K in edx_when_userdate. We should consider this vis-a-via the migrations and approach to applying indices.

@Serj-N
Copy link

Serj-N commented Aug 19, 2025

Checking in with a large site using edx_when, they have over 3M rows in edx_when_contentdate and around 43K in edx_when_userdate. We should consider this vis-a-via the migrations and approach to applying indices.

@e0d Thank you for sharing this, we'll definitely take this into account.

@Serj-N
Copy link

Serj-N commented Aug 27, 2025

@e0d Hi! This PR has been updated and is now ready for another round of review.

name='subsection_name',
field=models.CharField(blank=True, db_index=True, default='', max_length=255),
),
migrations.AddField(
Copy link

Choose a reason for hiding this comment

The 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 ContentDate. I believe @e0d is totally right.

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.

@Serj-N
Copy link

Serj-N commented Oct 13, 2025

@e0d @cmltaWt0
This PR should most likely be closed due to contribution rights. Please see this new PR instead.

@e0d
Copy link

e0d commented Dec 17, 2025

Closing this as it's been replaced by #343

@e0d e0d closed this Dec 17, 2025
@github-project-automation github-project-automation bot moved this from In Eng Review to Done in Contributions Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FC Relates to an Axim Funded Contribution project open-source-contribution PR author is not from Axim or 2U

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants