Skip to content

Commit 689a9a0

Browse files
committed
New: pass assignment id to assignment overview
1 parent e1e3fcb commit 689a9a0

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

bases/rsptx/admin_server_api/routers/analytics.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,8 +1146,13 @@ async def get_assignmentoverview(
11461146
request: Request,
11471147
user=Depends(auth_manager),
11481148
course=None,
1149+
assignment_id: Optional[int] = None,
11491150
):
1150-
"""Serve the assignment overview report shell page."""
1151+
"""Serve the assignment overview report shell page.
1152+
1153+
If ``assignment_id`` is supplied as a query parameter the template will
1154+
pre-select that assignment and auto-generate the report on page load.
1155+
"""
11511156
engine = create_engine(settings.dburl)
11521157
assignments_df = pd.read_sql_query(
11531158
"""
@@ -1177,6 +1182,7 @@ async def get_assignmentoverview(
11771182
"user": user,
11781183
"course": course,
11791184
"assignments": assignments,
1185+
"auto_assignment_id": assignment_id,
11801186
"is_instructor": True,
11811187
"student_page": False,
11821188
"settings": settings,

components/rsptx/templates/admin/analytics/assignmentoverview.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,8 @@ <h1>Assignment Summary Report</h1>
7171
{% endblock %}
7272

7373
{% block js %}
74+
{% if auto_assignment_id %}
75+
<script>window.AUTO_ASSIGNMENT_ID = {{ auto_assignment_id }};</script>
76+
{% endif %}
7477
<script src="/staticAssets/js/assignmentoverview.js"></script>
7578
{% endblock %}

components/rsptx/templates/staticAssets/js/assignmentoverview.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,17 @@
219219
.replace(/"/g, "&quot;");
220220
}
221221
})();
222+
223+
224+
// -------------------------------------------------------------------------
225+
// Auto-generate if assignment_id was passed as a query parameter.
226+
// Scripts in {% block js %} run after the DOM is ready, so no need to
227+
// wait for DOMContentLoaded — just run directly.
228+
// -------------------------------------------------------------------------
229+
if (window.AUTO_ASSIGNMENT_ID) {
230+
const sel = document.getElementById("assignment-select");
231+
sel.value = String(window.AUTO_ASSIGNMENT_ID);
232+
if (sel.value) {
233+
window.generateReport();
234+
}
235+
}

0 commit comments

Comments
 (0)