Commit db501ebee70e191dcff42104a321f986b7bd3a04
Committed by
Paulo Meireles
1 parent
34a1e40f
Exists in
master
and in
23 other branches
[Mezuro] Finished metric_configuration (missing some functional tests)
Showing
12 changed files
with
192 additions
and
224 deletions
Show diff stats
plugins/mezuro/controllers/myprofile/mezuro_plugin_metric_configuration_controller.rb
| @@ -34,73 +34,64 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle | @@ -34,73 +34,64 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle | ||
| 34 | @metric = @metric_configuration.metric | 34 | @metric = @metric_configuration.metric |
| 35 | @reading_group_names_and_ids = reading_group_names_and_ids | 35 | @reading_group_names_and_ids = reading_group_names_and_ids |
| 36 | end | 36 | end |
| 37 | -=begin | ||
| 38 | - def new_compound_metric_configuration | ||
| 39 | - @configuration_content = profile.articles.find(params[:id]) | ||
| 40 | - @metric_configurations = @configuration_content.metric_configurations | ||
| 41 | - if configuration_content_has_errors? | ||
| 42 | - redirect_to_error_page @configuration_content.errors[:base] | ||
| 43 | - end | ||
| 44 | - end | ||
| 45 | - | ||
| 46 | 37 | ||
| 47 | - def edit_compound_metric_configuration | 38 | + def update |
| 48 | @configuration_content = profile.articles.find(params[:id]) | 39 | @configuration_content = profile.articles.find(params[:id]) |
| 49 | - @metric_configuration = Kalibro::MetricConfiguration.find_by_configuration_name_and_metric_name(@configuration_content.name, params[:metric_name]) | ||
| 50 | - @metric_configurations = @configuration_content.metric_configurations | ||
| 51 | - @metric = @metric_configuration.metric | ||
| 52 | - end | ||
| 53 | - | ||
| 54 | - | ||
| 55 | - def create_compound_metric_configuration | ||
| 56 | - id = params[:id] | ||
| 57 | - metric_name = params[:metric_configuration][:metric][:name] | ||
| 58 | - metric_configuration = Kalibro::MetricConfiguration.new(params[:metric_configuration]) | ||
| 59 | - metric_configuration.save | 40 | + configuration_id = @configuration_content.configuration_id |
| 41 | + metric_configurations = Kalibro::MetricConfiguration.metric_configurations_of(configuration_id) | ||
| 42 | + metric_configuration = find_metric_configuration(metric_configurations, params[:metric_configuration][:id].to_i) | ||
| 43 | + metric_configuration.update_attributes params[:metric_configuration] | ||
| 60 | if metric_configuration_has_errors? metric_configuration | 44 | if metric_configuration_has_errors? metric_configuration |
| 61 | redirect_to_error_page metric_configuration.errors[0].message | 45 | redirect_to_error_page metric_configuration.errors[0].message |
| 62 | else | 46 | else |
| 63 | - redirect_to "/myprofile/#{profile.identifier}/plugin/mezuro/metric_configuration/edit_compound_metric_configuration?id=#{id}&metric_name=#{metric_name.gsub(/\s/, '+')}" | 47 | + redirect_to "/#{profile.identifier}/#{@configuration_content.slug}" |
| 64 | end | 48 | end |
| 65 | end | 49 | end |
| 66 | 50 | ||
| 67 | - def update_metric_configuration | ||
| 68 | - @configuration_content = profile.articles.find(params[:id]) | ||
| 69 | - metric_name = params[:metric_configuration][:metric][:name] | ||
| 70 | - metric_configuration = Kalibro::MetricConfiguration.find_by_configuration_name_and_metric_name(@configuration_content.name, metric_name) | ||
| 71 | - metric_configuration.update_attributes params[:metric_configuration] | 51 | + def remove |
| 52 | + configuration_content = profile.articles.find(params[:id]) | ||
| 53 | + configuration_id = configuration_content.configuration_id | ||
| 54 | + metric_configurations = Kalibro::MetricConfiguration.metric_configurations_of(configuration_id) | ||
| 55 | + metric_configuration = find_metric_configuration(metric_configurations, params[:metric_configuration_id].to_i) | ||
| 56 | + metric_configuration.destroy | ||
| 72 | if metric_configuration_has_errors? metric_configuration | 57 | if metric_configuration_has_errors? metric_configuration |
| 73 | redirect_to_error_page metric_configuration.errors[0].message | 58 | redirect_to_error_page metric_configuration.errors[0].message |
| 74 | else | 59 | else |
| 75 | - redirect_to "/#{profile.identifier}/#{@configuration_content.slug}" | 60 | + redirect_to "/#{profile.identifier}/#{configuration_content.slug}" |
| 76 | end | 61 | end |
| 77 | end | 62 | end |
| 78 | - | ||
| 79 | - def update_compound_metric_configuration | 63 | + |
| 64 | + def new_compound | ||
| 80 | @configuration_content = profile.articles.find(params[:id]) | 65 | @configuration_content = profile.articles.find(params[:id]) |
| 81 | - metric_name = params[:metric_configuration][:metric][:name] | ||
| 82 | - metric_configuration = Kalibro::MetricConfiguration.find_by_configuration_name_and_metric_name(@configuration_content.name, metric_name) | ||
| 83 | - metric_configuration.update_attributes params[:metric_configuration] | ||
| 84 | - if metric_configuration_has_errors? metric_configuration | ||
| 85 | - redirect_to_error_page metric_configuration.errors[0].message | ||
| 86 | - else | ||
| 87 | - redirect_to "/#{profile.identifier}/#{@configuration_content.slug}" | 66 | + @metric_configurations = @configuration_content.metric_configurations |
| 67 | + @reading_group_names_and_ids = reading_group_names_and_ids | ||
| 68 | + if configuration_content_has_errors? | ||
| 69 | + redirect_to_error_page @configuration_content.errors[:base] | ||
| 88 | end | 70 | end |
| 89 | end | 71 | end |
| 90 | 72 | ||
| 91 | - def remove_metric_configuration | ||
| 92 | - configuration_content = profile.articles.find(params[:id]) | ||
| 93 | - metric_name = params[:metric_name] | ||
| 94 | - metric_configuration = Kalibro::MetricConfiguration.find_by_configuration_name_and_metric_name(configuration_content.name, metric_name) | ||
| 95 | - metric_configuration.destroy | 73 | + def create_compound |
| 74 | + metric_configuration = Kalibro::MetricConfiguration.new(params[:metric_configuration]) | ||
| 75 | + metric_configuration.save | ||
| 76 | + | ||
| 96 | if metric_configuration_has_errors? metric_configuration | 77 | if metric_configuration_has_errors? metric_configuration |
| 97 | redirect_to_error_page metric_configuration.errors[0].message | 78 | redirect_to_error_page metric_configuration.errors[0].message |
| 98 | else | 79 | else |
| 99 | - redirect_to "/#{profile.identifier}/#{configuration_content.slug}" | 80 | + id = params[:id] |
| 81 | + redirect_to "/myprofile/#{profile.identifier}/plugin/mezuro/metric_configuration/edit_compound?id=#{id}&metric_configuration_id=#{metric_configuration.id}" | ||
| 100 | end | 82 | end |
| 101 | end | 83 | end |
| 102 | -=end | ||
| 103 | - | 84 | + |
| 85 | + def edit_compound | ||
| 86 | + @configuration_content = profile.articles.find(params[:id]) | ||
| 87 | + configuration_id = @configuration_content.configuration_id | ||
| 88 | + metric_configurations = Kalibro::MetricConfiguration.metric_configurations_of(configuration_id) | ||
| 89 | + @metric_configuration = find_metric_configuration(metric_configurations, params[:metric_configuration_id].to_i) | ||
| 90 | + @metric = @metric_configuration.metric | ||
| 91 | + @reading_group_names_and_ids = reading_group_names_and_ids | ||
| 92 | + @metric_configurations = metric_configurations | ||
| 93 | + end | ||
| 94 | + | ||
| 104 | private | 95 | private |
| 105 | 96 | ||
| 106 | def find_metric_configuration (metric_configurations, metric_configuration_id) | 97 | def find_metric_configuration (metric_configurations, metric_configuration_id) |
plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb
| @@ -57,6 +57,10 @@ class MezuroPlugin::Helpers::ContentViewerHelper | @@ -57,6 +57,10 @@ class MezuroPlugin::Helpers::ContentViewerHelper | ||
| 57 | ["Count", "COUNT"], ["Standard Deviation", "STANDARD_DEVIATION"]] | 57 | ["Count", "COUNT"], ["Standard Deviation", "STANDARD_DEVIATION"]] |
| 58 | end | 58 | end |
| 59 | 59 | ||
| 60 | + def self.scope_options | ||
| 61 | + [["Class", "CLASS"]] | ||
| 62 | + end | ||
| 63 | + | ||
| 60 | private | 64 | private |
| 61 | 65 | ||
| 62 | def self.discretize_array(array) | 66 | def self.discretize_array(array) |
plugins/mezuro/test/functional/myprofile/mezuro_plugin_metric_configuration_controller_test.rb
| @@ -12,7 +12,7 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase | @@ -12,7 +12,7 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase | ||
| 12 | @controller = MezuroPluginMetricConfigurationController.new | 12 | @controller = MezuroPluginMetricConfigurationController.new |
| 13 | @request = ActionController::TestRequest.new | 13 | @request = ActionController::TestRequest.new |
| 14 | @response = ActionController::TestResponse.new | 14 | @response = ActionController::TestResponse.new |
| 15 | - @profile = fast_create(Community) | 15 | + @profile = fast_create(Community) #FIXME Should be a person, not a community |
| 16 | 16 | ||
| 17 | @configuration = ConfigurationFixtures.configuration | 17 | @configuration = ConfigurationFixtures.configuration |
| 18 | @created_configuration = ConfigurationFixtures.created_configuration | 18 | @created_configuration = ConfigurationFixtures.created_configuration |
| @@ -34,8 +34,8 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase | @@ -34,8 +34,8 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase | ||
| 34 | @metric_configuration = MetricConfigurationFixtures.amloc_metric_configuration | 34 | @metric_configuration = MetricConfigurationFixtures.amloc_metric_configuration |
| 35 | @metric_configuration_hash = MetricConfigurationFixtures.amloc_metric_configuration_hash | 35 | @metric_configuration_hash = MetricConfigurationFixtures.amloc_metric_configuration_hash |
| 36 | @created_metric_configuration = MetricConfigurationFixtures.created_metric_configuration | 36 | @created_metric_configuration = MetricConfigurationFixtures.created_metric_configuration |
| 37 | -=begin | ||
| 38 | @compound_metric_configuration = MetricConfigurationFixtures.sc_metric_configuration | 37 | @compound_metric_configuration = MetricConfigurationFixtures.sc_metric_configuration |
| 38 | +=begin | ||
| 39 | @compound_metric_configuration_hash = MetricConfigurationFixtures.sc_metric_configuration_hash | 39 | @compound_metric_configuration_hash = MetricConfigurationFixtures.sc_metric_configuration_hash |
| 40 | 40 | ||
| 41 | 41 | ||
| @@ -46,7 +46,7 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase | @@ -46,7 +46,7 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase | ||
| 46 | =end | 46 | =end |
| 47 | end | 47 | end |
| 48 | 48 | ||
| 49 | - should 'test choose metric' do | 49 | + should 'choose metric' do |
| 50 | Kalibro::BaseTool.expects(:all).returns([@base_tool]) | 50 | Kalibro::BaseTool.expects(:all).returns([@base_tool]) |
| 51 | get :choose_metric, :profile => @profile.identifier, :id => @configuration_content.id | 51 | get :choose_metric, :profile => @profile.identifier, :id => @configuration_content.id |
| 52 | assert_equal @configuration_content, assigns(:configuration_content) | 52 | assert_equal @configuration_content, assigns(:configuration_content) |
| @@ -54,7 +54,7 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase | @@ -54,7 +54,7 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase | ||
| 54 | assert_response 200 | 54 | assert_response 200 |
| 55 | end | 55 | end |
| 56 | 56 | ||
| 57 | - should 'test new native metric configuration' do | 57 | + should 'initialize native' do |
| 58 | Kalibro::BaseTool.expects(:find_by_name).with(@base_tool.name).returns(@base_tool) | 58 | Kalibro::BaseTool.expects(:find_by_name).with(@base_tool.name).returns(@base_tool) |
| 59 | Kalibro::ReadingGroup.expects(:all).returns([@reading_group]) | 59 | Kalibro::ReadingGroup.expects(:all).returns([@reading_group]) |
| 60 | get :new_native, :profile => @profile.identifier, :id => @configuration_content.id, :base_tool_name => @base_tool.name, :metric_name => @metric.name | 60 | get :new_native, :profile => @profile.identifier, :id => @configuration_content.id, :base_tool_name => @base_tool.name, :metric_name => @metric.name |
| @@ -65,7 +65,7 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase | @@ -65,7 +65,7 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase | ||
| 65 | assert_response 200 | 65 | assert_response 200 |
| 66 | end | 66 | end |
| 67 | 67 | ||
| 68 | - should 'test create native metric configuration' do | 68 | + should 'create native' do |
| 69 | #Kalibro::MetricConfiguration.expects(:new).returns(@created_metric_configuration) #FIXME need .with(some_hash). | 69 | #Kalibro::MetricConfiguration.expects(:new).returns(@created_metric_configuration) #FIXME need .with(some_hash). |
| 70 | #@created_metric_configuration.expects(:save).returns(true) | 70 | #@created_metric_configuration.expects(:save).returns(true) |
| 71 | =begin | 71 | =begin |
| @@ -76,7 +76,7 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase | @@ -76,7 +76,7 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase | ||
| 76 | =end | 76 | =end |
| 77 | end | 77 | end |
| 78 | 78 | ||
| 79 | - should 'test edit native metric configuration' do | 79 | + should 'edit native' do |
| 80 | Kalibro::MetricConfiguration.expects(:metric_configurations_of).with(@configuration.id).returns([@metric_configuration]) | 80 | Kalibro::MetricConfiguration.expects(:metric_configurations_of).with(@configuration.id).returns([@metric_configuration]) |
| 81 | Kalibro::ReadingGroup.expects(:all).returns([@reading_group]) | 81 | Kalibro::ReadingGroup.expects(:all).returns([@reading_group]) |
| 82 | get :edit_native, :profile => @profile.identifier, :id => @configuration_content.id, :metric_configuration_id => @metric_configuration.id | 82 | get :edit_native, :profile => @profile.identifier, :id => @configuration_content.id, :metric_configuration_id => @metric_configuration.id |
| @@ -86,18 +86,31 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase | @@ -86,18 +86,31 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase | ||
| 86 | assert_equal [[@reading_group.name,@reading_group.id]], assigns(:reading_group_names_and_ids) | 86 | assert_equal [[@reading_group.name,@reading_group.id]], assigns(:reading_group_names_and_ids) |
| 87 | assert_response 200 | 87 | assert_response 200 |
| 88 | end | 88 | end |
| 89 | -=begin | ||
| 90 | - should 'test new compound metric configuration' do | ||
| 91 | - Kalibro::Configuration.expects(:request).with("Configuration", :get_configuration, { | ||
| 92 | - :configuration_name => @configuration_content.name}).returns({:configuration => @configuration_hash}) | ||
| 93 | - get :new_compound_metric_configuration, :profile => @profile.identifier, :id => @configuration_content.id | 89 | + |
| 90 | + should 'initialize compound' do | ||
| 91 | + Kalibro::ReadingGroup.expects(:all).returns([@reading_group]) | ||
| 92 | + get :new_compound, :profile => @profile.identifier, :id => @configuration_content.id | ||
| 94 | assert_equal @configuration_content, assigns(:configuration_content) | 93 | assert_equal @configuration_content, assigns(:configuration_content) |
| 95 | - assert_equal @configuration.metric_configuration[0].code, assigns(:metric_configurations)[0].code | 94 | + #FIXME mock is not working. configuration_id is not being set. |
| 95 | + #MezuroPlugin::ConfigurationContent.expects(:metric_configurations).returns([@compound_metric_configuration]) | ||
| 96 | + #assert_equal @compound_metric_configuration.code, assigns(:metric_configurations).first.code | ||
| 97 | + assert_equal [[@reading_group.name,@reading_group.id]], assigns(:reading_group_names_and_ids) | ||
| 96 | assert_response 200 | 98 | assert_response 200 |
| 97 | end | 99 | end |
| 98 | 100 | ||
| 99 | - | ||
| 100 | - should 'test edit compound metric configuration' do | 101 | + should 'create compound' do |
| 102 | +=begin TODO ARRUMAR ESTE TESTE!!! | ||
| 103 | + Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :save_metric_configuration, { | ||
| 104 | + :metric_configuration => @compound_metric_configuration.to_hash, | ||
| 105 | + :configuration_name => @compound_metric_configuration.configuration_name}) | ||
| 106 | + get :create_compound_metric_configuration, :profile => @profile.identifier, :id => @configuration_content.id, | ||
| 107 | + :metric_configuration => @compound_hash | ||
| 108 | + assert_response 302 | ||
| 109 | +=end | ||
| 110 | + end | ||
| 111 | + | ||
| 112 | + should 'edit compound' do | ||
| 113 | +=begin TODO ARRUMAR ESTE TESTE!!! | ||
| 101 | Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :get_metric_configuration, { | 114 | Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :get_metric_configuration, { |
| 102 | :configuration_name => @configuration_content.name, | 115 | :configuration_name => @configuration_content.name, |
| 103 | :metric_name => @compound_metric_configuration.metric.name}).returns({:metric_configuration => @compound_metric_configuration_hash}) | 116 | :metric_name => @compound_metric_configuration.metric.name}).returns({:metric_configuration => @compound_metric_configuration_hash}) |
| @@ -111,19 +124,11 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase | @@ -111,19 +124,11 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase | ||
| 111 | assert_equal @compound_metric_configuration.metric.name, assigns(:metric).name | 124 | assert_equal @compound_metric_configuration.metric.name, assigns(:metric).name |
| 112 | assert_equal @configuration.metric_configuration[0].code, assigns(:metric_configurations)[0].code | 125 | assert_equal @configuration.metric_configuration[0].code, assigns(:metric_configurations)[0].code |
| 113 | assert_response 200 | 126 | assert_response 200 |
| 127 | +=end | ||
| 114 | end | 128 | end |
| 115 | 129 | ||
| 116 | - | ||
| 117 | - should 'test compound metric creation' do | ||
| 118 | - Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :save_metric_configuration, { | ||
| 119 | - :metric_configuration => @compound_metric_configuration.to_hash, | ||
| 120 | - :configuration_name => @compound_metric_configuration.configuration_name}) | ||
| 121 | - get :create_compound_metric_configuration, :profile => @profile.identifier, :id => @configuration_content.id, | ||
| 122 | - :metric_configuration => @compound_hash | ||
| 123 | - assert_response 302 | ||
| 124 | - end | ||
| 125 | - | ||
| 126 | - should 'test update native metric configuration' do | 130 | + should 'update' do |
| 131 | +=begin TODO ARRUMAR ESTE TESTE!!! | ||
| 127 | Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :get_metric_configuration, { | 132 | Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :get_metric_configuration, { |
| 128 | :configuration_name => @configuration_content.name, | 133 | :configuration_name => @configuration_content.name, |
| 129 | :metric_name => @metric_configuration.metric.name}).returns({:metric_configuration => @metric_configuration_hash}) | 134 | :metric_name => @metric_configuration.metric.name}).returns({:metric_configuration => @metric_configuration_hash}) |
| @@ -134,30 +139,15 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase | @@ -134,30 +139,15 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase | ||
| 134 | :metric_configuration => @native_hash | 139 | :metric_configuration => @native_hash |
| 135 | assert_equal @configuration_content, assigns(:configuration_content) | 140 | assert_equal @configuration_content, assigns(:configuration_content) |
| 136 | assert_response 302 | 141 | assert_response 302 |
| 142 | +=end | ||
| 137 | end | 143 | end |
| 138 | - | ||
| 139 | - should 'test update compound metric configuration' do | ||
| 140 | - Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :get_metric_configuration, { | ||
| 141 | - :configuration_name => @configuration_content.name, | ||
| 142 | - :metric_name => @compound_metric_configuration.metric.name}).returns({:metric_configuration => @compound_metric_configuration_hash}) | ||
| 143 | - Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :save_metric_configuration, { | ||
| 144 | - :metric_configuration => @compound_metric_configuration.to_hash, | ||
| 145 | - :configuration_name => @compound_metric_configuration.configuration_name}) | ||
| 146 | - get :update_compound_metric_configuration, :profile => @profile.identifier, :id => @configuration_content.id, | ||
| 147 | - :metric_configuration => @compound_hash | ||
| 148 | - assert_equal @configuration_content, assigns(:configuration_content) | 144 | + |
| 145 | + should 'remove' do | ||
| 146 | + Kalibro::MetricConfiguration.expects(:metric_configurations_of).with(@configuration.id).returns([@metric_configuration]) | ||
| 147 | + @metric_configuration.expects(:destroy).returns() | ||
| 148 | + get :remove, :profile => @profile.identifier, :id => @configuration_content.id, :metric_configuration_id => @metric_configuration.id | ||
| 149 | assert_response 302 | 149 | assert_response 302 |
| 150 | end | 150 | end |
| 151 | 151 | ||
| 152 | - should 'test remove metric configuration' do | ||
| 153 | - Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :get_metric_configuration, { | ||
| 154 | - :configuration_name => @configuration_content.name, | ||
| 155 | - :metric_name => @metric.name}).returns({:metric_configuration => @metric_configuration_hash}) | ||
| 156 | - Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :remove_metric_configuration, { | ||
| 157 | - :metric_name => @metric.name, | ||
| 158 | - :configuration_name => @metric_configuration.configuration_name}) | ||
| 159 | - get :remove_metric_configuration, :profile => @profile.identifier, :id => @configuration_content.id, :metric_name => @metric.name | ||
| 160 | - assert_response 302 | ||
| 161 | - end | ||
| 162 | -=end | 152 | + |
| 163 | end | 153 | end |
plugins/mezuro/test/unit/mezuro_plugin/helpers/content_viewer_helper_test.rb
| @@ -60,4 +60,8 @@ class ContentViewerHelperTest < ActiveSupport::TestCase | @@ -60,4 +60,8 @@ class ContentViewerHelperTest < ActiveSupport::TestCase | ||
| 60 | ["Count", "COUNT"], ["Standard Deviation", "STANDARD_DEVIATION"]], @helper.aggregation_options | 60 | ["Count", "COUNT"], ["Standard Deviation", "STANDARD_DEVIATION"]], @helper.aggregation_options |
| 61 | end | 61 | end |
| 62 | 62 | ||
| 63 | + should 'create scope options' do | ||
| 64 | + assert_equal [["Class", "CLASS"]], @helper.scope_options | ||
| 65 | + end | ||
| 66 | + | ||
| 63 | end | 67 | end |
plugins/mezuro/views/content_viewer/show_configuration.rhtml
| @@ -44,7 +44,13 @@ | @@ -44,7 +44,13 @@ | ||
| 44 | </tr> | 44 | </tr> |
| 45 | <% @configuration_content.metric_configurations.each do |metric_configuration| %> | 45 | <% @configuration_content.metric_configurations.each do |metric_configuration| %> |
| 46 | <tr class="metric"> | 46 | <tr class="metric"> |
| 47 | - <td><%= link_to metric_configuration.metric.name, :controller => "mezuro_plugin_metric_configuration", :action => "edit_native", | 47 | + <% if metric_configuration.metric.compound |
| 48 | + edit_action = "edit_compound" | ||
| 49 | + else | ||
| 50 | + edit_action = "edit_native" | ||
| 51 | + end | ||
| 52 | + %> | ||
| 53 | + <td><%= link_to metric_configuration.metric.name, :controller => "mezuro_plugin_metric_configuration", :action => edit_action, | ||
| 48 | :metric_configuration_id => metric_configuration.id, :id => @configuration_content.id, | 54 | :metric_configuration_id => metric_configuration.id, :id => @configuration_content.id, |
| 49 | :profile => @page.profile.identifier %></td> | 55 | :profile => @page.profile.identifier %></td> |
| 50 | <% if metric_configuration.metric.compound %> | 56 | <% if metric_configuration.metric.compound %> |
| @@ -60,8 +66,8 @@ | @@ -60,8 +66,8 @@ | ||
| 60 | <td><%= metric_configuration.weight %></td> | 66 | <td><%= metric_configuration.weight %></td> |
| 61 | <td><%= metric_configuration.aggregation_form %></td> | 67 | <td><%= metric_configuration.aggregation_form %></td> |
| 62 | <% if owner %> | 68 | <% if owner %> |
| 63 | - <td><%= link_to "Remove", :controller => "mezuro_plugin_metric_configuration", :action => "remove_metric_configuration", | ||
| 64 | - :metric_name => metric_configuration.metric.name, :id => @configuration_content.id, | 69 | + <td><%= link_to "Remove", :controller => "mezuro_plugin_metric_configuration", :action => "remove", |
| 70 | + :metric_configuration_id => metric_configuration.id, :id => @configuration_content.id, | ||
| 65 | :profile => @page.profile.identifier %></td> | 71 | :profile => @page.profile.identifier %></td> |
| 66 | <% end %> | 72 | <% end %> |
| 67 | </tr> | 73 | </tr> |
plugins/mezuro/views/mezuro_plugin_metric_configuration/_native_metric_configuration_form.rhtml
| 1 | -<% form_for :metric_configuration, :url => {:action =>"update_native", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %> | 1 | +<% form_for :metric_configuration, :url => {:action =>"update", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %> |
| 2 | <%= hidden_field_tag :id, @configuration_content.id %> | 2 | <%= hidden_field_tag :id, @configuration_content.id %> |
| 3 | <%= f.hidden_field :configuration_id, :value => @configuration_content.configuration_id %> | 3 | <%= f.hidden_field :configuration_id, :value => @configuration_content.configuration_id %> |
| 4 | <%= f.hidden_field :id, :value => @metric_configuration.id %> | 4 | <%= f.hidden_field :id, :value => @metric_configuration.id %> |
| @@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
| 6 | <%= labelled_form_field _('Collector Name:'), f.text_field(:base_tool_name, :value => @base_tool_name, :readonly => true) %> | 6 | <%= labelled_form_field _('Collector Name:'), f.text_field(:base_tool_name, :value => @base_tool_name, :readonly => true) %> |
| 7 | 7 | ||
| 8 | <% f.fields_for :metric do |m| %> | 8 | <% f.fields_for :metric do |m| %> |
| 9 | + <%= m.hidden_field :compound, :value => "false" %> | ||
| 9 | <% @metric.language.each do |language| %> | 10 | <% @metric.language.each do |language| %> |
| 10 | <%= m.hidden_field :language, :multiple => true, :value => language %> | 11 | <%= m.hidden_field :language, :multiple => true, :value => language %> |
| 11 | <% end %> | 12 | <% end %> |
| @@ -17,12 +18,13 @@ | @@ -17,12 +18,13 @@ | ||
| 17 | <%= required labelled_form_field _('Code:'), f.text_field(:code) %> | 18 | <%= required labelled_form_field _('Code:'), f.text_field(:code) %> |
| 18 | 19 | ||
| 19 | <%= required labelled_form_field _('Aggregation Form:'), | 20 | <%= required labelled_form_field _('Aggregation Form:'), |
| 20 | - f.select(:aggregation_form, MezuroPlugin::Helpers::ContentViewerHelper.aggregation_options) %> | 21 | + f.select(:aggregation_form, MezuroPlugin::Helpers::ContentViewerHelper.aggregation_options, |
| 22 | + :selected => @metric_configuration.aggregation_form ) %> | ||
| 21 | 23 | ||
| 22 | <%= required labelled_form_field _('Weight:'), f.text_field(:weight) %> | 24 | <%= required labelled_form_field _('Weight:'), f.text_field(:weight) %> |
| 23 | 25 | ||
| 24 | <%= required labelled_form_field _('Reading Group:'), | 26 | <%= required labelled_form_field _('Reading Group:'), |
| 25 | - f.select(:reading_group_id, @reading_group_names_and_ids) %> | 27 | + f.select(:reading_group_id, @reading_group_names_and_ids, :selected => @metric_configuration.reading_group_id.to_i) %> |
| 26 | 28 | ||
| 27 | <p> | 29 | <p> |
| 28 | <%= f.submit "Save" %> | 30 | <%= f.submit "Save" %> |
plugins/mezuro/views/mezuro_plugin_metric_configuration/choose_metric.html.erb
| 1 | <h2><%= @configuration_content.name%> Configuration</h2> | 1 | <h2><%= @configuration_content.name%> Configuration</h2> |
| 2 | 2 | ||
| 3 | -<%= link_to "New Compound Metric", :controller => "mezuro_plugin_metric_configuration", :action => "new_compound_metric_configuration", | 3 | +<%= link_to "New Compound Metric", :controller => "mezuro_plugin_metric_configuration", :action => "new_compound", |
| 4 | :id => @configuration_content.id %> | 4 | :id => @configuration_content.id %> |
| 5 | 5 | ||
| 6 | <h5>Base Tools:</h5> | 6 | <h5>Base Tools:</h5> |
plugins/mezuro/views/mezuro_plugin_metric_configuration/edit_compound.html.erb
0 → 100644
| @@ -0,0 +1,69 @@ | @@ -0,0 +1,69 @@ | ||
| 1 | +<script src="/plugins/mezuro/javascripts/validations.js" type="text/javascript"></script> | ||
| 2 | +<script src="/javascripts/colorpicker.js" type="text/javascript"></script> | ||
| 3 | +<script src="/javascripts/colorpicker-noosfero.js" type="text/javascript"></script> | ||
| 4 | + | ||
| 5 | +<h2><%= @configuration_content.name %> Configuration</h2> | ||
| 6 | + | ||
| 7 | +<% form_for :metric_configuration, :url => {:action =>"update", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %> | ||
| 8 | + <%= hidden_field_tag :id, @configuration_content.id %> | ||
| 9 | + <%= f.hidden_field :configuration_id, :value => @configuration_content.configuration_id %> | ||
| 10 | + <%= f.hidden_field :id, :value => @metric_configuration.id %> | ||
| 11 | + | ||
| 12 | + <% f.fields_for :metric do |m| %> | ||
| 13 | + <%= m.hidden_field :compound, :value => "true" %> | ||
| 14 | + <%= required labelled_form_field _('Metric Name:'), m.text_field(:name, :value => @metric.name) %> | ||
| 15 | + <%= labelled_form_field _('Description:'), m.text_field(:description, :value => @metric.description) %> | ||
| 16 | + <%= required labelled_form_field _('Script:'), m.text_area(:script, :rows => 5, :value => @metric.script) %> | ||
| 17 | + <%= required labelled_form_field _('Scope:'), | ||
| 18 | + m.select(:scope, MezuroPlugin::Helpers::ContentViewerHelper.scope_options, :selected => @metric.scope) %> | ||
| 19 | + <% end %> | ||
| 20 | + | ||
| 21 | + <%= required labelled_form_field _('Code:'), f.text_field(:code), :value => @metric_configuration.code %> | ||
| 22 | + <%= required labelled_form_field _('Aggregation Form:'), | ||
| 23 | + f.select(:aggregation_form, MezuroPlugin::Helpers::ContentViewerHelper.aggregation_options, | ||
| 24 | + :selected => @metric_configuration.aggregation_form ) %> | ||
| 25 | + <%= required labelled_form_field _('Weight:'), f.text_field(:weight), :value => @metric_configuration.weight %> | ||
| 26 | + <%= required labelled_form_field _('Reading Group:'), f.select(:reading_group_id, @reading_group_names_and_ids, | ||
| 27 | + :selected => @metric_configuration.reading_group_id.to_i) %> | ||
| 28 | + | ||
| 29 | + <p><%= f.submit "Save" %></p> | ||
| 30 | + | ||
| 31 | +<% end %> | ||
| 32 | + | ||
| 33 | +<h5> Ranges </h5><br/> | ||
| 34 | + | ||
| 35 | +<table id="ranges"> | ||
| 36 | + <tr> | ||
| 37 | + <td> | ||
| 38 | + Label | ||
| 39 | + </td> | ||
| 40 | + <td> | ||
| 41 | + Beginning | ||
| 42 | + </td> | ||
| 43 | + <td> | ||
| 44 | + End | ||
| 45 | + </td> | ||
| 46 | + <td> | ||
| 47 | + Grade | ||
| 48 | + </td> | ||
| 49 | + <td> | ||
| 50 | + Color | ||
| 51 | + </td> | ||
| 52 | + </tr> | ||
| 53 | + <% | ||
| 54 | + #if (@metric_configuration.ranges!=nil) | ||
| 55 | + # @metric_configuration.ranges.each do |range| | ||
| 56 | + %> | ||
| 57 | + <%= #render :partial => "mezuro_plugin_range/range", :locals => {:range => range, :id => @configuration_content.id, | ||
| 58 | + #:metric_name => @metric_configuration.metric.name} | ||
| 59 | + %> | ||
| 60 | + <% #end | ||
| 61 | + #end | ||
| 62 | + %> | ||
| 63 | +</table> | ||
| 64 | + | ||
| 65 | +<br/> | ||
| 66 | +<%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_range", :id => @configuration_content.id, :metric_name => @metric.name} %> | ||
| 67 | +<div id="range_form" style="display:none"></div> | ||
| 68 | +<br/> | ||
| 69 | +<%= render :partial => "metric_codes", :locals => {:metric_configurations => @metric_configurations} %> |
plugins/mezuro/views/mezuro_plugin_metric_configuration/edit_compound_metric_configuration.html.erb
| @@ -1,81 +0,0 @@ | @@ -1,81 +0,0 @@ | ||
| 1 | -<script src="/plugins/mezuro/javascripts/validations.js" type="text/javascript"></script> | ||
| 2 | -<script src="/javascripts/colorpicker.js" type="text/javascript"></script> | ||
| 3 | -<script src="/javascripts/colorpicker-noosfero.js" type="text/javascript"></script> | ||
| 4 | - | ||
| 5 | -<h2><%= @configuration_content.name %> Configuration</h2> | ||
| 6 | - | ||
| 7 | -<% form_for :metric_configuration, :url => {:action =>"update_compound_metric_configuration", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %> | ||
| 8 | - <%= hidden_field_tag :id, @configuration_content.id %> | ||
| 9 | - <%= f.hidden_field :configuration_name, :value => @configuration_content.name %> | ||
| 10 | - | ||
| 11 | - <p> | ||
| 12 | - <%= "Metric Name:" + @metric.name %> | ||
| 13 | - </p> | ||
| 14 | - <% f.fields_for :metric do |m| %> | ||
| 15 | - <%= m.hidden_field :name, :value => @metric.name %> | ||
| 16 | - <p> | ||
| 17 | - <%= m.label :description, "Description:" %> | ||
| 18 | - <%= m.text_field "description", :value => @metric.description %> | ||
| 19 | - </p> | ||
| 20 | - <p> | ||
| 21 | - <%= m.label :scope, "Scope:" %> | ||
| 22 | - <%= m.select :scope, [["Class", "CLASS"]], :selected => @metric.scope %> | ||
| 23 | - </p> | ||
| 24 | - <p> | ||
| 25 | - <%= m.label :script, "Script:" %> | ||
| 26 | - <%= m.text_area "script", :value => @metric.script, :rows => 5 %> | ||
| 27 | - </p> | ||
| 28 | - <% end %> | ||
| 29 | - <p> | ||
| 30 | - <%= f.label :code, "Code:" %> | ||
| 31 | - <%= f.text_field "code" %> | ||
| 32 | - </p> | ||
| 33 | - <p> | ||
| 34 | - <%= f.label :aggregation_form, "Aggregation Form:" %> | ||
| 35 | - <%= f.select :aggregation_form, [["Average","AVERAGE"], ["Median", "MEDIAN"], ["Maximum", "MAXIMUM"], ["Minimum", "MINIMUM"], | ||
| 36 | - ["Count", "COUNT"], ["Standard Deviation", "STANDARD_DEVIATION"]] %> | ||
| 37 | - </p> | ||
| 38 | - <p> | ||
| 39 | - <%= f.label :weight, "Weight:" %> | ||
| 40 | - <%= f.text_field :weight %> | ||
| 41 | - </p> | ||
| 42 | - <p> | ||
| 43 | - <%= f.submit "Save" %> | ||
| 44 | - </p> | ||
| 45 | -<% end %> | ||
| 46 | - | ||
| 47 | - | ||
| 48 | -<h5> Ranges </h5><br/> | ||
| 49 | - | ||
| 50 | -<table id="ranges"> | ||
| 51 | - <tr> | ||
| 52 | - <td> | ||
| 53 | - Label | ||
| 54 | - </td> | ||
| 55 | - <td> | ||
| 56 | - Beginning | ||
| 57 | - </td> | ||
| 58 | - <td> | ||
| 59 | - End | ||
| 60 | - </td> | ||
| 61 | - <td> | ||
| 62 | - Grade | ||
| 63 | - </td> | ||
| 64 | - <td> | ||
| 65 | - Color | ||
| 66 | - </td> | ||
| 67 | - </tr> | ||
| 68 | - <% if (@metric_configuration.ranges!=nil) | ||
| 69 | - @metric_configuration.ranges.each do |range| %> | ||
| 70 | - <%= render :partial => "mezuro_plugin_range/range", :locals => {:range => range, :id => @configuration_content.id, | ||
| 71 | - :metric_name => @metric_configuration.metric.name} %> | ||
| 72 | - <% end | ||
| 73 | - end %> | ||
| 74 | -</table> | ||
| 75 | - | ||
| 76 | -<br/> | ||
| 77 | -<%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_range", :id => @configuration_content.id, :metric_name => @metric.name} %> | ||
| 78 | -<div id="range_form" style="display:none"></div> | ||
| 79 | - | ||
| 80 | -<br/> | ||
| 81 | -<%= render :partial => "metric_codes", :locals => {:metric_configurations => @metric_configurations} %> |
plugins/mezuro/views/mezuro_plugin_metric_configuration/new_compound.html.erb
0 → 100644
| @@ -0,0 +1,26 @@ | @@ -0,0 +1,26 @@ | ||
| 1 | +<h2><%= @configuration_content.name %> Configuration</h2> | ||
| 2 | + | ||
| 3 | +<% form_for :metric_configuration, :url => {:action =>"create_compound", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %> | ||
| 4 | + <%= hidden_field_tag :id, @configuration_content.id %> | ||
| 5 | + <%= f.hidden_field :configuration_id, :value => @configuration_content.configuration_id %> | ||
| 6 | + | ||
| 7 | + <% f.fields_for :metric do |m| %> | ||
| 8 | + <%= m.hidden_field :compound, :value => "true" %> | ||
| 9 | + <%= required labelled_form_field _('Metric Name:'), m.text_field(:name) %> | ||
| 10 | + <%= labelled_form_field _('Description:'), m.text_field(:description) %> | ||
| 11 | + <%= required labelled_form_field _('Script:'), m.text_area(:script, :rows => 5) %> | ||
| 12 | + <%= required labelled_form_field _('Scope:'), m.select(:scope, MezuroPlugin::Helpers::ContentViewerHelper.scope_options) %> | ||
| 13 | + <% end %> | ||
| 14 | + | ||
| 15 | + <%= required labelled_form_field _('Code:'), f.text_field(:code) %> | ||
| 16 | + <%= required labelled_form_field _('Aggregation Form:'), f.select(:aggregation_form, MezuroPlugin::Helpers::ContentViewerHelper.aggregation_options) %> | ||
| 17 | + <%= required labelled_form_field _('Weight:'), f.text_field(:weight) %> | ||
| 18 | + <%= required labelled_form_field _('Reading Group:'), | ||
| 19 | + f.select(:reading_group_id, @reading_group_names_and_ids) %> | ||
| 20 | + | ||
| 21 | + <p> <%= f.submit "Add" %> </p> | ||
| 22 | +<% end %> | ||
| 23 | + | ||
| 24 | +<%= render :partial => "metric_codes", :locals => {:metric_configurations => @metric_configurations} %> | ||
| 25 | + | ||
| 26 | + |
plugins/mezuro/views/mezuro_plugin_metric_configuration/new_compound_metric_configuration.html.erb
| @@ -1,44 +0,0 @@ | @@ -1,44 +0,0 @@ | ||
| 1 | -<h2><%= @configuration_content.name %> Configuration</h2> | ||
| 2 | - | ||
| 3 | -<% form_for :metric_configuration, :url => {:action =>"create_compound_metric_configuration", | ||
| 4 | -:controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %> | ||
| 5 | - <%= hidden_field_tag :id, @configuration_content.id %> | ||
| 6 | - <%= f.hidden_field :configuration_name, :value => @configuration_content.name %> | ||
| 7 | - | ||
| 8 | - <% f.fields_for :metric do |m| %> | ||
| 9 | - <p> | ||
| 10 | - <%= m.label :name, "Name:" %> | ||
| 11 | - <%= m.text_field "name" %> | ||
| 12 | - </p> | ||
| 13 | - <p> | ||
| 14 | - <%= m.label :description, "Description:" %> | ||
| 15 | - <%= m.text_field "description" %> | ||
| 16 | - </p> | ||
| 17 | - <p> | ||
| 18 | - <%= m.label :scope, "Scope:" %> | ||
| 19 | - <%= m.select :scope, [["Class", "CLASS"]] %> | ||
| 20 | - </p> | ||
| 21 | - <p> | ||
| 22 | - <%= m.label :script, "Script:" %> | ||
| 23 | - <%= m.text_area "script", :rows => 5 %> | ||
| 24 | - </p> | ||
| 25 | - <% end %> | ||
| 26 | - <p> | ||
| 27 | - <%= f.label :code, "Code:" %> | ||
| 28 | - <%= f.text_field "code" %> | ||
| 29 | - </p> | ||
| 30 | - <p> | ||
| 31 | - <%= f.label :aggregation_form, "Aggregation Form:" %> | ||
| 32 | - <%= f.select :aggregation_form, [["Average","AVERAGE"], ["Median", "MEDIAN"], ["Maximum", "MAXIMUM"], ["Minimum", "MINIMUM"], | ||
| 33 | - ["Count", "COUNT"], ["Standard Deviation", "STANDARD_DEVIATION"]] %> | ||
| 34 | - </p> | ||
| 35 | - <p> | ||
| 36 | - <%= f.label :weight, "Weight:" %> | ||
| 37 | - <%= f.text_field :weight %> | ||
| 38 | - </p> | ||
| 39 | - <p> | ||
| 40 | - <%= f.submit "Add" %> | ||
| 41 | - </p> | ||
| 42 | -<% end %> | ||
| 43 | - | ||
| 44 | -<%= render :partial => "metric_codes", :locals => {:metric_configurations => @metric_configurations} %> |
plugins/mezuro/views/mezuro_plugin_metric_configuration/new_native.html.erb
| @@ -10,6 +10,7 @@ | @@ -10,6 +10,7 @@ | ||
| 10 | <%= labelled_form_field _('Collector Name:'), f.text_field(:base_tool_name, :value => @base_tool_name, :readonly => true) %> | 10 | <%= labelled_form_field _('Collector Name:'), f.text_field(:base_tool_name, :value => @base_tool_name, :readonly => true) %> |
| 11 | 11 | ||
| 12 | <% f.fields_for :metric do |m| %> | 12 | <% f.fields_for :metric do |m| %> |
| 13 | + <%= m.hidden_field :compound, :value => "false" %> | ||
| 13 | <% @metric.language.each do |language| %> | 14 | <% @metric.language.each do |language| %> |
| 14 | <%= m.hidden_field :language, :multiple => true, :value => language %> | 15 | <%= m.hidden_field :language, :multiple => true, :value => language %> |
| 15 | <% end %> | 16 | <% end %> |