From b76c99eb17ef78740a81dded6ec51c2c5ceb1ab0 Mon Sep 17 00:00:00 2001
From: Arslan
Date: Thu, 14 Nov 2024 17:39:00 +0500
Subject: [PATCH] feat: add canvas integration support
---
lms/djangoapps/instructor/views/api.py | 3 +++
lms/djangoapps/instructor_task/views.py | 5 +++++
.../instructor_dashboard/instructor_dashboard.js | 3 +++
lms/static/js/instructor_dashboard/util.js | 6 ++++--
.../html-datatable.underscore | 16 ++++++++++++++++
.../instructor_dashboard_2.html | 2 +-
6 files changed, 32 insertions(+), 3 deletions(-)
create mode 100644 lms/templates/instructor/instructor_dashboard_2/html-datatable.underscore
diff --git a/lms/djangoapps/instructor/views/api.py b/lms/djangoapps/instructor/views/api.py
index 2b1f28e4ceac..2a3b4f9a66ac 100644
--- a/lms/djangoapps/instructor/views/api.py
+++ b/lms/djangoapps/instructor/views/api.py
@@ -2456,6 +2456,9 @@ def _list_instructor_tasks(request, course_id, serialize_data=None):
else:
# Specifying for single problem's history
tasks = task_api.get_instructor_task_history(course_id, module_state_key)
+ elif request.GET.get('include_canvas') is not None:
+ from ol_openedx_canvas_integration.task_helpers import get_filtered_instructor_tasks
+ tasks = get_filtered_instructor_tasks(course_id, request.user)
else:
# If no problem or student, just get currently running tasks
tasks = task_api.get_running_instructor_tasks(course_id)
diff --git a/lms/djangoapps/instructor_task/views.py b/lms/djangoapps/instructor_task/views.py
index 51e2812577fe..5907b315ec19 100644
--- a/lms/djangoapps/instructor_task/views.py
+++ b/lms/djangoapps/instructor_task/views.py
@@ -138,6 +138,7 @@ def get_task_completion_info(instructor_task): # lint-amnesty, pylint: disable=
student = None
problem_url = None
+ entrance_exam_url = None
email_id = None
try:
task_input = json.loads(instructor_task.task_input)
@@ -192,6 +193,10 @@ def get_task_completion_info(instructor_task): # lint-amnesty, pylint: disable=
else: # num_succeeded < num_attempted
# Translators: {action} is a past-tense verb that is localized separately. {succeeded} and {attempted} are counts. # lint-amnesty, pylint: disable=line-too-long
msg_format = _("Problem {action} for {succeeded} of {attempted} students")
+ elif task_input and task_input.get('course_key'):
+ from ol_openedx_canvas_integration.utils import get_task_output_formatted_message
+ msg_format = get_task_output_formatted_message(task_output)
+ succeeded = True
elif email_id is not None:
# this reports on actions on bulk emails
if num_attempted == 0:
diff --git a/lms/static/js/instructor_dashboard/instructor_dashboard.js b/lms/static/js/instructor_dashboard/instructor_dashboard.js
index f87e9db8e814..14f47fce6f36 100644
--- a/lms/static/js/instructor_dashboard/instructor_dashboard.js
+++ b/lms/static/js/instructor_dashboard/instructor_dashboard.js
@@ -176,6 +176,9 @@ such that the value can be defined later than this assignment (file load order).
}, {
constructor: window.InstructorDashboard.sections.ECommerce,
$element: idashContent.find('.' + CSS_IDASH_SECTION + '#e-commerce')
+ }, {
+ constructor: window.InstructorDashboard.sections.CanvasIntegration,
+ $element: idashContent.find('.' + CSS_IDASH_SECTION + '#canvas_integration')
}, {
constructor: window.InstructorDashboard.sections.Membership,
$element: idashContent.find('.' + CSS_IDASH_SECTION + '#membership')
diff --git a/lms/static/js/instructor_dashboard/util.js b/lms/static/js/instructor_dashboard/util.js
index 8e39f4d03e66..39544a0bce1a 100644
--- a/lms/static/js/instructor_dashboard/util.js
+++ b/lms/static/js/instructor_dashboard/util.js
@@ -51,7 +51,8 @@
enableColumnReorder: false,
autoHeight: true,
rowHeight: 100,
- forceFitColumns: true
+ forceFitColumns: true,
+ enableTextSelectionOnCells: true
};
columns = [
{
@@ -492,7 +493,8 @@
enableCellNavigation: true,
enableColumnReorder: false,
rowHeight: 30,
- forceFitColumns: true
+ forceFitColumns: true,
+ enableTextSelectionOnCells: true
};
columns = [
{
diff --git a/lms/templates/instructor/instructor_dashboard_2/html-datatable.underscore b/lms/templates/instructor/instructor_dashboard_2/html-datatable.underscore
new file mode 100644
index 000000000000..89da91b17881
--- /dev/null
+++ b/lms/templates/instructor/instructor_dashboard_2/html-datatable.underscore
@@ -0,0 +1,16 @@
+
+
<%- title %>
+
+ <%_.forEach(header, function (h) {%>
+ <%- h %> |
+ <%})%>
+
+ <%_.forEach(data, function (row) {%>
+
+ <%_.forEach(row, function (value) {%>
+ <%- value %> |
+ <%})%>
+
+ <%})%>
+
+
diff --git a/lms/templates/instructor/instructor_dashboard_2/instructor_dashboard_2.html b/lms/templates/instructor/instructor_dashboard_2/instructor_dashboard_2.html
index 6fe80e7fdea0..0bb0b6054735 100644
--- a/lms/templates/instructor/instructor_dashboard_2/instructor_dashboard_2.html
+++ b/lms/templates/instructor/instructor_dashboard_2/instructor_dashboard_2.html
@@ -92,7 +92,7 @@
## Include Underscore templates
<%block name="header_extras">
-% for template_name in ["cohorts", "discussions", "enrollment-code-lookup-links", "cohort-editor", "cohort-group-header", "cohort-selector", "cohort-form", "notification", "cohort-state", "divided-discussions-inline", "divided-discussions-course-wide", "cohort-discussions-category", "cohort-discussions-subcategory", "certificate-allowlist", "certificate-allowlist-editor", "certificate-bulk-allowlist", "certificate-invalidation", "membership-list-widget"]:
+% for template_name in ["cohorts", "discussions", "enrollment-code-lookup-links", "cohort-editor", "cohort-group-header", "cohort-selector", "cohort-form", "notification", "cohort-state", "divided-discussions-inline", "divided-discussions-course-wide", "cohort-discussions-category", "cohort-discussions-subcategory", "certificate-allowlist", "certificate-allowlist-editor", "certificate-bulk-allowlist", "certificate-invalidation", "membership-list-widget", "html-datatable"]: