From af8e685f28f7c84b1306156be61796ef7d83cb10 Mon Sep 17 00:00:00 2001
From: Hari Haran
Date: Fri, 16 Feb 2024 15:04:51 +0530
Subject: [PATCH] fixed import issue and added config value to hide assignments
---
.../management/commands/sga_migrate_submissions.py | 4 ++--
edx_sga/sga.py | 11 +++++++----
edx_sga/tasks.py | 2 +-
edx_sga/templates/staff_graded_assignment/show.html | 10 ++++++++--
edx_sga/tests/integration_tests.py | 4 ++--
5 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/edx_sga/management/commands/sga_migrate_submissions.py b/edx_sga/management/commands/sga_migrate_submissions.py
index e42127f..2450e50 100644
--- a/edx_sga/management/commands/sga_migrate_submissions.py
+++ b/edx_sga/management/commands/sga_migrate_submissions.py
@@ -7,9 +7,9 @@
from django.core.management.base import BaseCommand, CommandError
from lms.djangoapps.courseware.courses import get_course_by_id
-from lms.djangoapps.courseware.models import StudentModule
+from courseware.models import StudentModule
from opaque_keys.edx.keys import CourseKey
-from common.djangoapps.student.models import anonymous_id_for_user
+from student.models import anonymous_id_for_user
from submissions import api as submissions_api
from xmodule.modulestore.django import modulestore
diff --git a/edx_sga/sga.py b/edx_sga/sga.py
index 4fe01b7..e5ac1ec 100644
--- a/edx_sga/sga.py
+++ b/edx_sga/sga.py
@@ -25,9 +25,9 @@
from django.utils.encoding import force_text
from django.utils.timezone import now as django_now
from django.utils.translation import ugettext as _
-from lms.djangoapps.courseware.models import StudentModule
+from courseware.models import StudentModule
from safe_lxml import etree
-from common.djangoapps.student.models import user_by_anonymous_id
+from student.models import user_by_anonymous_id
from submissions import api as submissions_api
from submissions.models import StudentItem as SubmissionsStudent
from submissions.models import Submission
@@ -39,6 +39,7 @@
from xblockutils.studio_editable import StudioEditableXBlockMixin
from xmodule.contentstore.content import StaticContent
from xmodule.util.duedate import get_extended_due_date
+from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from edx_sga.constants import ITEM_TYPE
from edx_sga.showanswer import ShowAnswerXBlockMixin
@@ -192,7 +193,7 @@ def add_xml_to_node(self, node):
if 'solution' in node.attrib:
# Try outputting it as an XML element if we can
solution = node.attrib['solution']
- wrapped = f"{solution}"
+ wrapped = "{}".format(solution)
try:
child = etree.fromstring(wrapped)
except: # pylint: disable=bare-except
@@ -584,7 +585,8 @@ def student_view(self, context=None):
"student_state": json.dumps(self.student_state()),
"id": self.location.name.replace('.', '_'),
"max_file_size": self.student_upload_max_size(),
- "support_email": settings.TECH_SUPPORT_EMAIL
+ "support_email": settings.TECH_SUPPORT_EMAIL,
+ "enable_hide_assignment": configuration_helpers.get_value_theme('ENABLE_HIDE_ASSIGNMENT', False)
}
if self.show_staff_grading_interface():
context['is_course_staff'] = True
@@ -792,6 +794,7 @@ def student_state(self):
"upload_allowed": self.upload_allowed(submission_data=submission),
"solution": solution,
"base_asset_url": StaticContent.get_base_url_path_for_course_assets(self.location.course_key),
+ "enable_hide_assignment": configuration_helpers.get_value_theme('ENABLE_HIDE_ASSIGNMENT', False)
}
def staff_grading_data(self):
diff --git a/edx_sga/tasks.py b/edx_sga/tasks.py
index 58c00e9..d051484 100644
--- a/edx_sga/tasks.py
+++ b/edx_sga/tasks.py
@@ -9,7 +9,7 @@
from django.core.files.storage import default_storage
from celery import shared_task
from opaque_keys.edx.locator import BlockUsageLocator
-from common.djangoapps.student.models import user_by_anonymous_id
+from student.models import user_by_anonymous_id
from submissions import api as submissions_api
from edx_sga.constants import ITEM_TYPE
diff --git a/edx_sga/templates/staff_graded_assignment/show.html b/edx_sga/templates/staff_graded_assignment/show.html
index d8eb523..360bb4c 100644
--- a/edx_sga/templates/staff_graded_assignment/show.html
+++ b/edx_sga/templates/staff_graded_assignment/show.html
@@ -14,6 +14,8 @@
<% if (upload_allowed) { %>
@@ -146,7 +152,7 @@
-
{{ display_name }} - {% trans "Staff Graded Assignment" %}
+
{{ display_name }} - {% if enable_hide_assignment %} {% trans "Staff Graded" %} {% else %} {% trans "Staff Graded Assignment" %} {% endif %}
{% trans "Download All Submissions" %}
diff --git a/edx_sga/tests/integration_tests.py b/edx_sga/tests/integration_tests.py
index a3adbef..a4fc2da 100644
--- a/edx_sga/tests/integration_tests.py
+++ b/edx_sga/tests/integration_tests.py
@@ -20,11 +20,11 @@
from django.db import transaction
from django.test.utils import override_settings
from lms.djangoapps.courseware import module_render as render
-from lms.djangoapps.courseware.models import StudentModule
+from courseware.models import StudentModule
from lms.djangoapps.courseware.tests.factories import StaffFactory
from opaque_keys.edx.locations import Location
from opaque_keys.edx.locator import CourseLocator
-from common.djangoapps.student.models import UserProfile, anonymous_id_for_user
+from student.models import UserProfile, anonymous_id_for_user
from common.djangoapps.student.tests.factories import AdminFactory
from submissions import api as submissions_api
from submissions.models import StudentItem