Commit e86864395b0f47ac34b4926d2d3c46d95bae75e1
Committed by
Paulo Meireles
1 parent
077b3df7
Exists in
master
and in
29 other branches
[Mezuro] added history to grade value
Showing
6 changed files
with
54 additions
and
27 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
... | ... | @@ -43,8 +43,16 @@ class MezuroPluginProfileController < ProfileController |
43 | 43 | metric_name = params[:metric_name] |
44 | 44 | content = profile.articles.find(params[:id]) |
45 | 45 | module_history = content.result_history(params[:module_name]) |
46 | - date_history = module_history.collect { |x| x.date } | |
47 | - metric_history = module_history.collect { |x| (x.metric_results.select { |y| y.metric.name.delete("() ") == metric_name })[0] } | |
48 | - render :partial => 'content_viewer/metric_history', :locals => {:metric_history => metric_history, :date_history => date_history } | |
46 | + date_history = module_history.collect { |module_result| module_result.date } | |
47 | + score_history = (module_history.collect { |module_result| (module_result.metric_results.select { |metric_result| metric_result.metric.name.delete("() ") == metric_name })[0] }).collect { |metric_result| metric_result.value } | |
48 | + render :partial => 'content_viewer/score_history', :locals => {:score_history => score_history, :date_history => date_history } | |
49 | + end | |
50 | + | |
51 | + def module_grade_history | |
52 | + content = profile.articles.find(params[:id]) | |
53 | + modules_results = content.result_history(params[:module_name]) | |
54 | + date_history = modules_results.collect { |module_result| module_result.date } | |
55 | + score_history = modules_results.collect { |module_result| module_result.grade } | |
56 | + render :partial => 'content_viewer/score_history', :locals => {:date_history => date_history, :score_history => score_history } | |
49 | 57 | end |
50 | 58 | end | ... | ... |
plugins/mezuro/public/javascripts/project_content.js
... | ... | @@ -22,7 +22,8 @@ function display_metric_history() { |
22 | 22 | } |
23 | 23 | |
24 | 24 | function display_grade_history() { |
25 | - alert(jQuery(this).attr('show-grade-history')); | |
25 | + var module_name = jQuery(this).attr('show-grade-history'); | |
26 | + callAction('module_grade_history', {module_name: module_name}, show_grades); | |
26 | 27 | return false; |
27 | 28 | } |
28 | 29 | |
... | ... | @@ -30,6 +31,10 @@ function show_metrics(content) { |
30 | 31 | jQuery('#historical-' + metricName).html(content); |
31 | 32 | } |
32 | 33 | |
34 | +function show_grades(content) { | |
35 | + jQuery('#historical-grade').html(content); | |
36 | +} | |
37 | + | |
33 | 38 | function toggle_mezuro(){ |
34 | 39 | var element = jQuery(this).attr('data-show'); |
35 | 40 | jQuery(element).toggle(); | ... | ... |
plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
... | ... | @@ -20,7 +20,7 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase |
20 | 20 | @project = @project_result.project |
21 | 21 | @name = @project.name |
22 | 22 | |
23 | - @date = "2012-04-13T20:39:41+04:00" | |
23 | + @date = "2012-04-13T20:39:41+04:00" | |
24 | 24 | end |
25 | 25 | |
26 | 26 | should 'not find module result for inexistent project content' do |
... | ... | @@ -92,7 +92,7 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase |
92 | 92 | end |
93 | 93 | |
94 | 94 | should 'get project tree without date' do |
95 | - create_project_content | |
95 | + create_project_content | |
96 | 96 | Kalibro::Client::ProjectResultClient.expects(:last_result).with(@name).returns(@project_result) |
97 | 97 | Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) |
98 | 98 | get :project_tree, :profile => @profile.identifier, :id => @content.id, :module_name => @name |
... | ... | @@ -101,13 +101,23 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase |
101 | 101 | end |
102 | 102 | |
103 | 103 | should 'get project tree from a specific date' do |
104 | - create_project_content | |
104 | + create_project_content | |
105 | 105 | mock_project_result |
106 | 106 | Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) |
107 | 107 | get :project_tree, :profile => @profile.identifier, :id => @content.id, :module_name => @name, :date => "2012-04-13T20:39:41+04:00" |
108 | 108 | assert_response 200 |
109 | 109 | end |
110 | 110 | |
111 | + should 'get grade history' do | |
112 | + create_project_content | |
113 | + client = mock | |
114 | + Kalibro::Client::ModuleResultClient.expects(:new).returns(client) | |
115 | + client.expects(:result_history).returns([@module_result]) | |
116 | + get :module_grade_history, :profile => @profile.identifier, :id => @content.id, :module_name => @name | |
117 | + assert_equal assings(:modules_results)[0].grade, 10.0 | |
118 | + assert_response 200 | |
119 | + end | |
120 | + | |
111 | 121 | private |
112 | 122 | |
113 | 123 | def create_project_content | ... | ... |
plugins/mezuro/views/content_viewer/_metric_history.rhtml
... | ... | @@ -1,10 +0,0 @@ |
1 | -<table width="100%"> | |
2 | - <% cont = 0 %> | |
3 | - <% date_history.each do |date| %> | |
4 | - <tr> | |
5 | - <td width="70%"> <b> <%= date %> </b> </td> | |
6 | - <td width="30%"> <%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_history[cont].value) %> </td> | |
7 | - </tr> | |
8 | - <% cont = cont + 1 %> | |
9 | - <% end %> | |
10 | - </table> |
plugins/mezuro/views/content_viewer/_module_result.rhtml
... | ... | @@ -26,25 +26,29 @@ |
26 | 26 | </tr> |
27 | 27 | <tr class="<%= metric_result.metric.name.delete("() ")%>" style="display: none;"> |
28 | 28 | <td colspan="4"> |
29 | - <div id='historical-<%= metric_result.metric.name.delete("() ") %>'> | |
30 | - <a href="#" show-metric-history="<%= metric_result.metric.name.delete("() ") %>" data-module-name="<%= the_module.name %>" data-metric-name="<%= metric_result.metric.name.delete("() ") %>"> <p style="text-indent: 3em;"> Get Historical Values </p> </a> | |
31 | - </div> | |
29 | + <div id='historical-<%= metric_result.metric.name.delete("() ") %>'> | |
30 | + <a href="#" show-metric-history="<%= metric_result.metric.name.delete("() ") %>" data-module-name="<%= the_module.name %>" data-metric-name="<%= metric_result.metric.name.delete("() ") %>"> <p style="text-indent: 3em;"> Get Historical Values </p> </a> | |
31 | + </div> | |
32 | 32 | </td> |
33 | 33 | <td colspan="3" align="right"> |
34 | 34 | <%= range.comments.nil? ? '' : range.comments %> |
35 | 35 | </td> |
36 | 36 | </tr> |
37 | - <% end %> | |
37 | + <% end %> | |
38 | 38 | <% end %> |
39 | 39 | </tbody> |
40 | 40 | <tfoot> |
41 | 41 | <tr> |
42 | - <td colspan = "4" align = "right"> <a href="#" show-grade-history="<%= module_result.grade %>" > | |
43 | - <strong> | |
44 | - <%= _('Grade:') %> | |
45 | - <%= "%.02f" % module_result.grade %> | |
46 | - </strong> | |
47 | - </a> | |
42 | + <td colspan = "1"> | |
43 | + <div id='historical-grade'> | |
44 | + </td> | |
45 | + <td colspan = "4" align = "right"> | |
46 | + <a href="#" show-grade-history="<%= module_result.module.name %>" > | |
47 | + <strong> | |
48 | + <%= _('Grade:') %> | |
49 | + <%= "%.02f" % module_result.grade %> | |
50 | + </strong> | |
51 | + </a> | |
48 | 52 | </td> |
49 | 53 | </tr> |
50 | 54 | </tfoot> | ... | ... |
plugins/mezuro/views/content_viewer/_score_history.rhtml
0 → 100644
... | ... | @@ -0,0 +1,10 @@ |
1 | +<table width="100%"> | |
2 | + <% cont = 0 %> | |
3 | + <% date_history.each do |date| %> | |
4 | + <tr> | |
5 | + <td width="70%"> <b> <%= date %> </b> </td> | |
6 | + <td width="30%"> <%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(score_history[cont]) %> </td> | |
7 | + </tr> | |
8 | + <% cont = cont + 1 %> | |
9 | + <% end %> | |
10 | + </table> | ... | ... |