Skip to content

Commit

Permalink
fixed import issue and added config value to hide assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
hari-crystal committed Feb 16, 2024
1 parent 22341a2 commit af8e685
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
4 changes: 2 additions & 2 deletions edx_sga/management/commands/sga_migrate_submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 7 additions & 4 deletions edx_sga/sga.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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>{solution}</solution>"
wrapped = "<solution>{}</solution>".format(solution)
try:
child = etree.fromstring(wrapped)
except: # pylint: disable=bare-except
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion edx_sga/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions edx_sga/templates/staff_graded_assignment/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<label>
<% if (uploaded) { %>
{% trans "Upload a different file" %}
<% } else if (enable_hide_assignment) { %>
{% trans "Upload" %}
<% } else { %>
{% trans "Upload your assignment" %}
<% } %>
Expand All @@ -38,7 +40,11 @@
<a href="<%= annotatedUrl %>"><%= annotated.filename %></a><br/>
<% } %>
<% } else if (uploaded) { %>
{% trans "This assignment has not yet been graded." %}
<% if (enable_hide_assignment) { %>
{% trans "" %}
<% } else {%>
{% trans "This assignment has not yet been graded." %}
<% } %>
<% } %>
</p>
<% if (upload_allowed) { %>
Expand Down Expand Up @@ -146,7 +152,7 @@

<section aria-hidden="true" class="modal staff-modal" id="grade-{{ id }}" style="height: 75%" tabindex="-1">
<div class="inner-wrapper" style="color: black; overflow: auto;">
<header><h2><span class="display_name">{{ display_name }}</span> - {% trans "Staff Graded Assignment" %}</h2></header>
<header><h2><span class="display_name">{{ display_name }}</span> - {% if enable_hide_assignment %} {% trans "Staff Graded" %} {% else %} {% trans "Staff Graded Assignment" %} {% endif %}</h2></header>
<br/>
<div>
<a class="instructor-info-action button btn-download-all" href="#" id="download-init-button">{% trans "Download All Submissions" %}</a>
Expand Down
4 changes: 2 additions & 2 deletions edx_sga/tests/integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit af8e685

Please sign in to comment.