From 3620fd93d9d13fb0ca66f69dfdf1a7b46aff38d2 Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Tue, 8 Jan 2013 12:13:39 -0500 Subject: [PATCH] Create a result container and put results into it --- .../xmodule/combined_open_ended_module.py | 9 +++++++++ .../xmodule/css/combinedopenended/display.scss | 7 +++++++ .../js/src/combinedopenended/display.coffee | 17 +++++++++++++++++ lms/templates/combined_open_ended.html | 4 ++++ lms/templates/combined_open_ended_results.html | 3 +++ lms/templates/combined_open_ended_status.html | 9 ++------- lms/templates/open_ended_evaluation.html | 2 +- 7 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 lms/templates/combined_open_ended_results.html diff --git a/common/lib/xmodule/xmodule/combined_open_ended_module.py b/common/lib/xmodule/xmodule/combined_open_ended_module.py index 4537985d33..c6ed8b2ed1 100644 --- a/common/lib/xmodule/xmodule/combined_open_ended_module.py +++ b/common/lib/xmodule/xmodule/combined_open_ended_module.py @@ -248,6 +248,14 @@ class CombinedOpenEndedModule(XModule): pass return return_html + def get_results(self, get): + task_number=get['task_number'] + self.update_task_states() + response_dict=self.get_last_response(task_number) + context = {'results' : response_dict['post_assessment']} + html = render_to_string('combined_open_ended_results.html', context) + return html + def handle_ajax(self, dispatch, get): """ This is called by courseware.module_render, to handle an AJAX call. @@ -262,6 +270,7 @@ class CombinedOpenEndedModule(XModule): handlers = { 'next_problem': self.next_problem, 'reset': self.reset, + 'get_results' : self.get_results } if dispatch not in handlers: diff --git a/common/lib/xmodule/xmodule/css/combinedopenended/display.scss b/common/lib/xmodule/xmodule/css/combinedopenended/display.scss index 5ac7066c6d..d8e36361a6 100644 --- a/common/lib/xmodule/xmodule/css/combinedopenended/display.scss +++ b/common/lib/xmodule/xmodule/css/combinedopenended/display.scss @@ -32,6 +32,13 @@ section.combined-open-ended { width: 53%; } + .result-container + { + float:left; + width: 93%; + position:relative; + } + &:after { content:"."; diff --git a/common/lib/xmodule/xmodule/js/src/combinedopenended/display.coffee b/common/lib/xmodule/xmodule/js/src/combinedopenended/display.coffee index e868186bde..922f4082b0 100644 --- a/common/lib/xmodule/xmodule/js/src/combinedopenended/display.coffee +++ b/common/lib/xmodule/xmodule/js/src/combinedopenended/display.coffee @@ -18,11 +18,17 @@ class @CombinedOpenEnded @reset_button.click @reset @next_problem_button = @$('.next-step-button') @next_problem_button.click @next_problem + + @show_results_button=@$('.show-results-button') + @show_results_button.click @show_results + # valid states: 'initial', 'assessing', 'post_assessment', 'done' Collapsible.setCollapsibles(@el) @submit_evaluation_button = $('.submit-evaluation-button') @submit_evaluation_button.click @message_post + @results_container = $('.result-container') + # Where to put the rubric once we load it @el = $(element).find('section.open-ended-child') @errors_area = @$('.error') @@ -49,6 +55,17 @@ class @CombinedOpenEnded $: (selector) -> $(selector, @el) + show_results: (event) => + status_item = $(event.target).parent().parent() + status_number = status_item.data('status-number') + data = {'task_number' : status_number} + $.postWithPrefix "#{@ajax_url}/get_results", data, (response) => + if response.success + @results_container.after(response.html).remove() + @Collapsible.setCollapsibles(@results_container) + else + @errors_area.html(response.error) + rebind: () => # rebind to the appropriate function for the current state @submit_button.unbind('click') diff --git a/lms/templates/combined_open_ended.html b/lms/templates/combined_open_ended.html index 5cd5d76e4c..4c0aaa1042 100644 --- a/lms/templates/combined_open_ended.html +++ b/lms/templates/combined_open_ended.html @@ -15,5 +15,9 @@ + +
+

Results


+
diff --git a/lms/templates/combined_open_ended_results.html b/lms/templates/combined_open_ended_results.html new file mode 100644 index 0000000000..12af086cfe --- /dev/null +++ b/lms/templates/combined_open_ended_results.html @@ -0,0 +1,3 @@ +
+ ${results | n} +
\ No newline at end of file diff --git a/lms/templates/combined_open_ended_status.html b/lms/templates/combined_open_ended_status.html index c8a0177edd..6109df2f26 100644 --- a/lms/templates/combined_open_ended_status.html +++ b/lms/templates/combined_open_ended_status.html @@ -9,13 +9,8 @@ Step ${status['task_number']} (${status['human_state']}) : ${status['score']} / ${status['max_score']} %if status['type']=="openended": -
-
- Show feedback from step ${status['task_number']} -
-
- ${status['post_assessment']} -
+ %endif
diff --git a/lms/templates/open_ended_evaluation.html b/lms/templates/open_ended_evaluation.html index da3f38b6a9..71ce6d5056 100644 --- a/lms/templates/open_ended_evaluation.html +++ b/lms/templates/open_ended_evaluation.html @@ -20,4 +20,4 @@ - \ No newline at end of file +incorrect-icon.png \ No newline at end of file