From 77f30696557baeb3f0e16d60cad88cc230e2823f Mon Sep 17 00:00:00 2001 From: Nick Parlante Date: Wed, 8 Oct 2014 16:03:06 -0700 Subject: [PATCH] Extended Feedback and Hints for Problems Extends the common capa response types (string, numeric, multiple choice, checkbox, dropdown) with feedback and hint capabilities. "Feedback" refers to feedback shown to the student when they check the problem, looking at their specific answer. "Hints" refers to a Hint button in LMS which the student can click at any time to see hints for that problem. The implementation extends the markdown syntax to include feedback and hints. There are new Feedback-and-Hint specific templates in Studio when the author clicks to add a new problem. --- CHANGELOG.rst | 2 + .../component_settings_editor_helpers.py | 6 +- .../contentstore/views/component.py | 22 +- ...d-xblock-component-menu-problem.underscore | 23 +- common/lib/capa/capa/capa_problem.py | 53 +- common/lib/capa/capa/inputtypes.py | 18 +- common/lib/capa/capa/responsetypes.py | 451 ++++++++- common/lib/capa/capa/tests/__init__.py | 14 +- .../capa/capa/tests/response_xml_factory.py | 11 +- .../capa/tests/test_files/extended_hints.xml | 50 + .../test_files/extended_hints_checkbox.xml | 117 +++ .../test_files/extended_hints_dropdown.xml | 42 + .../extended_hints_multiple_choice.xml | 34 + .../extended_hints_numeric_input.xml | 37 + .../test_files/extended_hints_text_input.xml | 78 ++ .../test_files/extended_hints_with_errors.xml | 13 + .../capa/tests/test_hint_functionality.py | 507 ++++++++++ .../lib/capa/capa/tests/test_responsetypes.py | 6 + common/lib/xmodule/xmodule/capa_base.py | 77 +- common/lib/xmodule/xmodule/capa_module.py | 2 + .../lib/xmodule/xmodule/css/capa/display.scss | 38 +- .../xmodule/js/spec/problem/edit_spec.coffee | 12 +- .../js/spec/problem/edit_spec_hint.coffee | 936 ++++++++++++++++++ .../xmodule/js/src/capa/display.coffee | 16 + .../xmodule/js/src/problem/edit.coffee | 267 ++++- .../problem/checkboxes_response_hint.yaml | 70 ++ .../templates/problem/multiplechoice.yaml | 6 +- .../problem/multiplechoice_hint.yaml | 46 + .../problem/numericalresponse_hint.yaml | 54 + .../problem/optionresponse_hint.yaml | 51 + .../problem/string_response_hint.yaml | 54 + .../xmodule/xmodule/tests/test_capa_module.py | 119 ++- common/test/acceptance/pages/lms/problem.py | 21 + .../acceptance/tests/lms/test_lms_problems.py | 75 ++ lms/templates/problem.html | 7 +- 35 files changed, 3210 insertions(+), 125 deletions(-) create mode 100644 common/lib/capa/capa/tests/test_files/extended_hints.xml create mode 100644 common/lib/capa/capa/tests/test_files/extended_hints_checkbox.xml create mode 100644 common/lib/capa/capa/tests/test_files/extended_hints_dropdown.xml create mode 100644 common/lib/capa/capa/tests/test_files/extended_hints_multiple_choice.xml create mode 100644 common/lib/capa/capa/tests/test_files/extended_hints_numeric_input.xml create mode 100644 common/lib/capa/capa/tests/test_files/extended_hints_text_input.xml create mode 100644 common/lib/capa/capa/tests/test_files/extended_hints_with_errors.xml create mode 100644 common/lib/capa/capa/tests/test_hint_functionality.py create mode 100644 common/lib/xmodule/xmodule/js/spec/problem/edit_spec_hint.coffee create mode 100644 common/lib/xmodule/xmodule/templates/problem/checkboxes_response_hint.yaml create mode 100644 common/lib/xmodule/xmodule/templates/problem/multiplechoice_hint.yaml create mode 100644 common/lib/xmodule/xmodule/templates/problem/numericalresponse_hint.yaml create mode 100644 common/lib/xmodule/xmodule/templates/problem/optionresponse_hint.yaml create mode 100644 common/lib/xmodule/xmodule/templates/problem/string_response_hint.yaml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f9d007c62e..5d6383562c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -47,6 +47,8 @@ LMS: Support adding students to a cohort via the instructor dashboard. TNL-163 LMS: Show cohorts on the new instructor dashboard. TNL-161 +LMS: Extended hints feature + LMS: Mobile API available for courses that opt in using the Course Advanced Setting "Mobile Course Available" (only used in limited closed beta). diff --git a/cms/djangoapps/contentstore/features/component_settings_editor_helpers.py b/cms/djangoapps/contentstore/features/component_settings_editor_helpers.py index 743f54f829..f295a3517d 100644 --- a/cms/djangoapps/contentstore/features/component_settings_editor_helpers.py +++ b/cms/djangoapps/contentstore/features/component_settings_editor_helpers.py @@ -59,12 +59,12 @@ def click_new_component_button(step, component_button_css): def _click_advanced(): - css = 'ul.problem-type-tabs a[href="#tab2"]' + css = 'ul.problem-type-tabs a[href="#tab3"]' world.css_click(css) # Wait for the advanced tab items to be displayed - tab2_css = 'div.ui-tabs-panel#tab2' - world.wait_for_visible(tab2_css) + tab3_css = 'div.ui-tabs-panel#tab3' + world.wait_for_visible(tab3_css) def _find_matching_link(category, component_type): diff --git a/cms/djangoapps/contentstore/views/component.py b/cms/djangoapps/contentstore/views/component.py index cd670e8243..8169f5499e 100644 --- a/cms/djangoapps/contentstore/views/component.py +++ b/cms/djangoapps/contentstore/views/component.py @@ -227,7 +227,7 @@ def get_component_templates(courselike, library=False): """ Returns the applicable component templates that can be used by the specified course or library. """ - def create_template_dict(name, cat, boilerplate_name=None, is_common=False): + def create_template_dict(name, cat, boilerplate_name=None, tab="common"): """ Creates a component template dict. @@ -235,14 +235,14 @@ def get_component_templates(courselike, library=False): display_name: the user-visible name of the component category: the type of component (problem, html, etc.) boilerplate_name: name of boilerplate for filling in default values. May be None. - is_common: True if "common" problem, False if "advanced". May be None, as it is only used for problems. + tab: common(default)/advanced/hint, which tab it goes in """ return { "display_name": name, "category": cat, "boilerplate_name": boilerplate_name, - "is_common": is_common + "tab": tab } component_display_names = { @@ -268,8 +268,8 @@ def get_component_templates(courselike, library=False): # add the default template with localized display name # TODO: Once mixins are defined per-application, rather than per-runtime, # this should use a cms mixed-in class. (cpennington) - display_name = xblock_type_display_name(category, _('Blank')) - templates_for_category.append(create_template_dict(display_name, category)) + display_name = xblock_type_display_name(category, _('Blank')) # this is the Blank Advanced problem + templates_for_category.append(create_template_dict(display_name, category, None, 'advanced')) categories.add(category) # add boilerplates @@ -277,12 +277,20 @@ def get_component_templates(courselike, library=False): for template in component_class.templates(): filter_templates = getattr(component_class, 'filter_templates', None) if not filter_templates or filter_templates(template, courselike): + # Tab can be 'common' 'advanced' 'hint' + # Default setting is common/advanced depending on the presence of markdown + tab = 'common' + if template['metadata'].get('markdown') is None: + tab = 'advanced' + # Then the problem can override that with a tab: setting + tab = template['metadata'].get('tab', tab) + templates_for_category.append( create_template_dict( _(template['metadata'].get('display_name')), # pylint: disable=translation-of-non-string category, template.get('template_id'), - template['metadata'].get('markdown') is not None + tab ) ) @@ -297,7 +305,7 @@ def get_component_templates(courselike, library=False): log.warning('Unable to load xblock type %s to read display_name', component, exc_info=True) else: templates_for_category.append( - create_template_dict(component_display_name, component, boilerplate_name) + create_template_dict(component_display_name, component, boilerplate_name, 'advanced') ) categories.add(component) diff --git a/cms/templates/js/add-xblock-component-menu-problem.underscore b/cms/templates/js/add-xblock-component-menu-problem.underscore index aca3c34e79..301064935c 100644 --- a/cms/templates/js/add-xblock-component-menu-problem.underscore +++ b/cms/templates/js/add-xblock-component-menu-problem.underscore @@ -4,13 +4,16 @@ <%= gettext("Common Problem Types") %>
  • - <%= gettext("Advanced") %> + <%= gettext("Common Problems with Hints and Feedback") %> +
  • +
  • + <%= gettext("Advanced") %>