From fee0facd39211f8c5de105e7479611bfc11a656b Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Tue, 6 Nov 2012 09:30:59 -0500 Subject: [PATCH] Add in some docs for tests, factor out class name in js --- .../js/src/selfassessment/display.coffee | 32 ++++++++++--------- .../lib/xmodule/xmodule/tests/test_export.py | 1 + .../lib/xmodule/xmodule/tests/test_import.py | 4 ++- .../self_assessment/policies/2012_Fall.json | 16 ++-------- 4 files changed, 24 insertions(+), 29 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee b/common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee index 99ccccb6b6..566131cd79 100644 --- a/common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee +++ b/common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee @@ -1,25 +1,27 @@ -$(document).on('click', 'section.sa-wrapper input#show', ( -> - post_url=$('section.sa-wrapper input#ajax_url').attr('url') +wrapper_name='section.sa-wrapper' + +$(document).on('click', "#{wrapper_name} input#show", ( -> + post_url=$("#{wrapper_name} input#ajax_url").attr('url') final_url="#{post_url}/sa_show" - answer=$('section.sa-wrapper textarea#answer').val() + answer=$("#{wrapper_name} textarea#answer").val() $.post final_url, {'student_answer' : answer }, (response) -> if response.success - $('section.sa-wrapper input#show').remove() - $('section.sa-wrapper textarea#answer').remove() - $('section.sa-wrapper p#rubric').append("Your answer: #{answer}") - $('section.sa-wrapper p#rubric').append(response.rubric) + $("#{wrapper_name} input#show").remove() + $("#{wrapper_name} textarea#answer").remove() + $("#{wrapper_name} p#rubric").append("Your answer: #{answer}") + $("#{wrapper_name} p#rubric").append(response.rubric) else - $('section.sa-wrapper input#show').remove() - $('section.sa-wrapper p#rubric').append(response.message) + $("#{wrapper_name} input#show").remove() + $("#{wrapper_name} p#rubric").append(response.message) )); -$(document).on('click', 'section.sa-wrapper input#save', ( -> - assessment=$('section.sa-wrapper #assessment').find(':selected').text() - post_url=$('section.sa-wrapper input#ajax_url').attr('url') +$(document).on('click', "#{wrapper_name} input#save", ( -> + assessment=$("#{wrapper_name} #assessment").find(':selected').text() + post_url=$("#{wrapper_name} input#ajax_url").attr('url') final_url="#{post_url}/sa_save" - hint=$('section.sa-wrapper textarea#hint').val() + hint=$("#{wrapper_name} textarea#hint").val() $.post final_url, {'assessment':assessment, 'hint':hint}, (response) -> if response.success - $('section.sa-wrapper p#save_message').append(response.message) - $('section.sa-wrapper input#save').remove() + $("#{wrapper_name} p#save_message").append(response.message) + $("#{wrapper_name} input#save").remove() )); diff --git a/common/lib/xmodule/xmodule/tests/test_export.py b/common/lib/xmodule/xmodule/tests/test_export.py index de3aeda77c..aeebc6da6b 100644 --- a/common/lib/xmodule/xmodule/tests/test_export.py +++ b/common/lib/xmodule/xmodule/tests/test_export.py @@ -115,4 +115,5 @@ class RoundTripTestCase(unittest.TestCase): self.check_export_roundtrip(DATA_DIR, "full") def test_selfassessment_roundtrip(self): + #Test selfassessment xmodule to see if it exports correctly self.check_export_roundtrip(DATA_DIR,"self_assessment") diff --git a/common/lib/xmodule/xmodule/tests/test_import.py b/common/lib/xmodule/xmodule/tests/test_import.py index 34ea8da537..9e8199629a 100644 --- a/common/lib/xmodule/xmodule/tests/test_import.py +++ b/common/lib/xmodule/xmodule/tests/test_import.py @@ -314,7 +314,8 @@ class ImportTestCase(unittest.TestCase): def test_selfassessment_import(self): ''' - Check to see if definition_from_xml and definition_to_xml in self_assessment_module.py function. + Check to see if definition_from_xml in self_assessment_module.py + works properly. Pulls data from the self_assessment directory in the test data directory. ''' modulestore = XMLModuleStore(DATA_DIR, course_dirs=['self_assessment']) @@ -322,4 +323,5 @@ class ImportTestCase(unittest.TestCase): sa_id = "edX/sa_test/2012_Fall" location = Location(["i4x", "edX", "sa_test", "selfassessment", "SampleQuestion"]) sa_sample = modulestore.get_instance(sa_id, location) + #10 attempts is hard coded into SampleQuestion, which is the url_name of a selfassessment xml tag self.assertEqual(sa_sample.metadata['attempts'], '10') \ No newline at end of file diff --git a/common/test/data/self_assessment/policies/2012_Fall.json b/common/test/data/self_assessment/policies/2012_Fall.json index 23da0a6d96..aae4670296 100644 --- a/common/test/data/self_assessment/policies/2012_Fall.json +++ b/common/test/data/self_assessment/policies/2012_Fall.json @@ -2,23 +2,13 @@ "course/2012_Fall": { "graceperiod": "2 days 5 hours 59 minutes 59 seconds", "start": "2015-07-17T12:00", - "display_name": "Toy Course", + "display_name": "Self Assessment Test", "graded": "true" }, "chapter/Overview": { "display_name": "Overview" }, - "videosequence/Toy_Videos": { - "display_name": "Toy Videos", - "format": "Lecture Sequence" + "selfassessment/SampleQuestion": { + "display_name": "Sample Question", }, - "html/secret:toylab": { - "display_name": "Toy lab" - }, - "video/Video_Resources": { - "display_name": "Video Resources" - }, - "video/Welcome": { - "display_name": "Welcome" - } }