From 0dd0f1f81d625fd747df49057272a3a41e5efc06 Mon Sep 17 00:00:00 2001 From: Matjaz Gregoric Date: Tue, 9 Aug 2016 16:28:07 +0800 Subject: [PATCH] Hide 'Reset Attempts' and 'Rescore Problem' on unsupported blocks. CAPA problems have the "Staff Debug Info" button, which allows instructors to "Reset Attempts" and "Rescore problem" for any individual student. XBlocks, such as Drag and Drop v2 do not support those, though the UI was still present. Clicking any of those links would result in an "Unknown Error Occurred" message. This commit hides the two buttons if the associated block does not support them. --- lms/templates/staff_problem_info.html | 6 +++++- openedx/core/lib/xblock_utils.py | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lms/templates/staff_problem_info.html b/lms/templates/staff_problem_info.html index 24ca39783b..36db395c3d 100644 --- a/lms/templates/staff_problem_info.html +++ b/lms/templates/staff_problem_info.html @@ -68,13 +68,17 @@ ${block_content}
[ + % if can_reset_attempts: ${_('Reset Student Attempts')} - % if has_instructor_access: | + % endif + % if has_instructor_access: ${_('Delete Student State')} + % if can_rescore_problem: | ${_('Rescore Student Submission')} % endif + % endif ]
diff --git a/openedx/core/lib/xblock_utils.py b/openedx/core/lib/xblock_utils.py index 757230053c..4474b832b3 100644 --- a/openedx/core/lib/xblock_utils.py +++ b/openedx/core/lib/xblock_utils.py @@ -382,6 +382,8 @@ def add_staff_markup(user, has_instructor_access, disable_staff_debug_info, bloc 'block_content': frag.content, 'is_released': is_released, 'has_instructor_access': has_instructor_access, + 'can_reset_attempts': 'attempts' in block.fields, + 'can_rescore_problem': hasattr(block, 'rescore_problem'), 'disable_staff_debug_info': disable_staff_debug_info, } return wrap_fragment(frag, render_to_string("staff_problem_info.html", staff_context))