Skip to content

Add changes for Estimated Time to Complete#249

Open
becdavid wants to merge 13 commits into
develop/teak.masterfrom
dev/nalexa3/CourseEstimatedTime
Open

Add changes for Estimated Time to Complete#249
becdavid wants to merge 13 commits into
develop/teak.masterfrom
dev/nalexa3/CourseEstimatedTime

Conversation

@becdavid
Copy link
Copy Markdown

No description provided.

feanil and others added 13 commits December 16, 2025 10:15
We previously fixed this when the CourseLimitedStaffRole was applied to
a course but did not handle the case where the role is applied to a user
for a whole org.  The underlying issue is that the CourseLimitedStaffRole
is a subclass of the CourseStaffRole and much of the system assumes that
subclesses are for giving more access not less access.

To prevent that from happening for the case of the CourseLimitedStaffRole,
when we do CourseStaffRole access checks, we use the strict_role_checking
context manager to ensure that we're not accidentally granting the
limited_staff role too much access.
Co-authored-by: ayesha waris <73840786+ayesha-waris@users.noreply.github.com>
- Added time normalization helpers to parse and convert mixed time
  formats into seconds, including clip-aware video duration adjustment.
- Implemented aggregated estimated-time calculators for unit,
  subsection, section, and course levels.
- Added recalculation logic for component edits triggered by override
  toggles and video clip field changes.
- Synced ancestor estimated_time values after create, update, move,
  and delete operations to maintain container totals.
- Updated save logic to align HTML reading-time estimates automatically
  when overrides are disabled.
- Enforced course-level show_estimated_time behavior, locking block-level
  visibility when the course setting is enabled.
- Extended XBlock info responses with estimated_time, show_estimated_time,
  and override_estimated_time fields.
- Improved resilience with safer defaults and fallback behavior for
  missing or malformed time values.
- Triggered estimated-time recalculation when course-level estimated_time
  is edited or when override_estimated_time is disabled to restore
  derived totals.
- Moved recalculation behind estimated_time field availability checks
  to prevent execution on courses where the feature is not enabled.
- Refreshed returned course metadata post-recalculation to ensure the
  response includes newly aggregated values.
- Refined aggregation utilities to consistently compute estimated times from
  component-level values up through units, subsections, sections,
  and course totals.
- Improved HTML reading-time estimation flow with fallback
  behavior for default timing.
- Added estimated_time and show_estimated_time to serializable and
  auth-denied fields to ensure consistent frontend access.
- Implemented safe defaults ('00:01:00' and False) in
  BlockSerializer.to_representation to prevent undefined values.
- Excluded estimated-time fields from CourseMetadata editable fields
  to prevent accidental modification via Studio advanced settings.
- Initialized estimated_time, show_estimated_time, and
  override_estimated_time as null in the XBlockInfo model.
- Added the estimated-time-editor template to course outline JS
  spec fixtures for testing coverage.
…modals

- Implemented EstimatedTimeEditor class to handle estimated_time (HH:MM:SS),
  show_estimated_time, and override_estimated_time fields.
- Added logic to enforce course-level "show_estimated_time" locking,
  disabling the toggle and showing a helper message when enabled globally.
- Integrated EstimatedTimeEditor into the "Basic" tab for both Chapters
  (Sections) and Sequentials (Subsections).
- Modified requestData to correctly synchronize metadata changes only when
  values differ from the initial model state.
- Utilized timepicker initialization for the new estimated-time inputs
  to ensure a consistent UI with existing date/time editors.
…tes, and serializers

- Updated serializers.py to include show_estimated_time and effort
  metadata with a safe default of '00:01:00' for missing values.
- Updated vert_module.html to render a learner-facing "Estimated Time
  to Complete" label with localized minute/minutes pluralization.
- Updated models.py to persist estimated_time and show_estimated_time
  within the CourseOverview, allowing access on the Course Home page.
- Updated utils.py to ensure estimated-time fields are requested when
  fetching blocks for the course outline.
- Standardized metadata flow from the course-level settings through
  to individual unit rendering templates.
…ersistence

- Added RelativeTime and Boolean override fields to HTML, CAPA, and
  Video XBlocks to support granular pacing controls.
- Implemented calculate_estimated_time in CAPA blocks using
  readtime for automated HTML-based estimation with manual overrides.
- Updated CourseOverview models to persist estimated-time settings,
  ensuring metadata is available on the course home page.
- Modified serializers and utility helpers to include show_estimated_time
  and estimated_time in the course outline block tree.
- Enhanced vert_module.html to render "Estimated Time to Complete"
  labels when enabled by course settings.
… XBlock fields

- Added core XModuleFields (estimated_time, show_estimated_time,
  override_estimated_time) to standardize the feature across all modules.
- Updated seq_block to compute minute-based estimates and implement
  the course-to-unit visibility cascade.
- Enhanced vertical_block to calculate and expose estimated_time_minutes
  to the unit fragment context for frontend rendering.
- Implemented attribute fetching with safe defaults to ensure
  compatibility across various block types.
- Standardized time conversion logic, using ceiling division to ensure
  a 1-minute minimum for any component with estimated effort.
- Created test_estimated_time.py to verify XModuleField definitions,
  default values, and HH:MM:SS conversion logic.
- Created test_estimated_time_backend.py as a diagnostic script to
  verify field accessibility via the Modulestore in a Tutor environment.
- Included validation for HTML reading-time calculation logic,
  including image weighting and WPM-based word counts.
- Note: These tests were used in the beginning of implementation and will likely
  need to be updated to match the current state of the feature.
…or_spec

- Created estimated-time-edit.underscore to provide the UI for setting
  completion time, overrides, and learner-facing visibility.
- Implemented course-level lock messaging in the template to handle
  global estimated-time visibility settings.
- Added EstimatedTimeEditor spec to validate field initialization,
  HH:MM:SS string conversion, and getRequestData change detection.
- Note: These files are preserved for historical implementation context
  and these files have no impact on the estimated time feature implementation
  These files can be modified and/or removed.
…ogic

Keep the estimated-time rendering snippets in the outline template for historical
traceability and future iteration. This includes:
 - conditional display when show_estimated_time is enabled
 - HH:MM:SS to rounded-minute conversion for UI text
 - secondary estimated_time status block with override label

No confirmed functional behavior change was noticed when modifying this file. It is likely that the changes in this file are not needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants