Skip to content
Open
Show file tree
Hide file tree
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
126 changes: 126 additions & 0 deletions lms/djangoapps/instructor/docs/decisions/0003-ora-api-spec.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
Instructor Dashboard – Open Response Assessment (ORA) API Specification
======================================================================

Status
======
Accepted

Context
=======

The Instructor Dashboard is being migrated to a Micro-Frontend (MFE) architecture,
which requires stable, well-defined, and RESTful API endpoints.

The existing Open Response Assessment (ORA) functionality exposes summary and
detailed assessment data through legacy endpoints that are tightly coupled to
server-rendered views. These endpoints do not meet the requirements for MFE
consumption, including consistent URL patterns, centralized permission handling,
and standardized API documentation.

To support the migration, a new versioned ORA API is required that follows
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes a lot of sense. The only concern I have is that edx-ora2 is currently a separate library, but it looks like at some point someone built coupled APIs into the current instructor dash for its data. It's unlikely that we would not install edx-ora2 into the platform, but it's still not a great pattern. As you build out the new APIs, be mindful to continue to use the OraAggregateData interface.

As for this PR, it would be good to mention some of the above and be clear that it's a known issue but we're not gonna fix it as a part of this improvement. In the future, we could consider moving the rest-endpoints to the edx-ora2 library and plug-them into the instructor dash but that work won't be a part of this change.

RESTful principles and aligns with existing Instructor v2 APIs.

Additionally, ORA functionality is implemented in the edx-ora2 library, which
is maintained as a separate Django app from the main platform. Historically,
Instructor Dashboard APIs have been implemented directly in the platform and
coupled to ORA data sources, rather than being owned by or exposed directly from
edx-ora2. While edx-ora2 is expected to be installed in the platform, this
cross-app coupling is not an ideal long-term pattern.

As part of this work, the new versioned ORA APIs will continue to rely on the
existing OraAggregateData interface to retrieve assessment data. This ensures
consistency with current ORA behavior and avoids introducing tighter coupling or
duplicate business logic as part of this migration.

Refactoring or relocating these REST endpoints into the edx-ora2 library
itself—so that the Instructor Dashboard consumes them as an external dependency—
is acknowledged as a potential future improvement. However, this architectural
change is explicitly out of scope for the current effort.

To support the MFE migration in the short term, this work introduces a new
versioned ORA API that follows RESTful principles and aligns with existing
Instructor v2 APIs, while preserving current data access patterns and interfaces.

Decisions
=========

1. RESTful Resource-Oriented Design
----------------------------------

Introduce a versioned API under ``/api/instructor/v2/`` using resource-oriented
URLs and clear HTTP semantics.

**Summary endpoint**

.. code-block:: http

GET /api/instructor/v2/courses/{course_key}/ora/summary/

Returns aggregated ORA statistics for a course, including:

- Total units
- Total assessments
- Total responses
- Counts by assessment type (training, peer, self, waiting, staff)
- Number of final grades received

**Assessments list endpoint**

.. code-block:: http

GET /api/instructor/v2/courses/{course_key}/ora/

Returns a collection of Open Response Assessments (ORAs) for the specified course.
Each item in the response represents a single assessment and includes
per-assessment metrics such as response counts, grading progress, and assessment
state.

2. Permission-Based Tab Configuration
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this section on tabs apply to the ORA api or just to the instructor dashboard mfe in general?

------------------------------------

Server-side logic determines which Instructor Dashboard tabs are available to
the current user based on their roles, course configuration, and feature flags.
Only authorized tabs are returned, each including URLs that map directly to the
corresponding MFE routes.

3. Serializer-Based Business Logic
---------------------------------

Use Django REST Framework serializers (``ORASSummarizerSerializer`` and
Copy link
Contributor

Choose a reason for hiding this comment

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

My recommendation would be ORASummarySerializer.

``ORASerializer``) to encapsulate all business logic, including:

- Data aggregation and formatting
- Permission enforcement
- Enrollment and course queries

Views remain thin and focused on request handling.
Comment on lines +90 to +96
Copy link
Contributor

Choose a reason for hiding this comment

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

I glossed over this in the course info and grading specs, but based on my understanding, a serializer shouldn't be responsible for all business logic and shouldn't deal with permission enforcement. (Also enrollment and course queries don't really apply to the ORA endpoints, right?). They should just be focused on data representation and validation.

I agree the views should be thin, but the serializers are just one piece of that strategy.


4. OpenAPI Specification
------------------------

Maintain an OpenAPI specification at:

::

../references/instructor-v2-ora-api-spec.yaml

Comment on lines +101 to +106
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be removed as it is redundant.

Maintain an OpenAPI specification at ``../references/instructor-v2-ora-api-spec.yaml`` to guide implementation.
This static specification serves as a reference during development, but ``/api-docs/`` is the source of truth for what is actually deployed.
Once implementation is complete and the endpoints are live in ``/api-docs/``, the static spec file will be deleted to avoid maintaining outdated documentation.

Consequences
============

- Reduced MFE page load latency by replacing multiple client requests with a
small number of API calls
Comment on lines +114 to +115
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we replacing mulitple ORA related endpoints or just introducing similar, but modernized endpoints?

- Centralized business logic ensures consistent permission checks and data
formatting
- Simplified client-side logic for the Instructor Dashboard MFE
- OpenAPI documentation enables type-safe client generation and easier
integration

References
==========

- OpenAPI Specification: ``../references/instructor-v2-ora-api-spec.yaml``
- Live API Documentation: ``/api-docs/``
Loading
Loading