diff --git a/app/controllers/admin/cancerpredicts_controller.rb b/app/controllers/admin/cancerpredicts_controller.rb index a6169eb..c459150 100644 --- a/app/controllers/admin/cancerpredicts_controller.rb +++ b/app/controllers/admin/cancerpredicts_controller.rb @@ -413,7 +413,7 @@ class Admin::CancerpredictsController < OrbitAdminController @field_property["comment_text"] = property["comment_text"][locale.to_s] break end - if @field_property["comment_text"] != "" + if @field_property["comment_text"].present? @table_str_right += '' @table_str_right += '' else diff --git a/app/controllers/cancerpredicts_controller.rb b/app/controllers/cancerpredicts_controller.rb index 1999908..de3ff70 100644 --- a/app/controllers/cancerpredicts_controller.rb +++ b/app/controllers/cancerpredicts_controller.rb @@ -1,5 +1,6 @@ # encoding: utf-8 require 'rubyXL' +require "json" class CancerpredictsController < ApplicationController def initialize super @@ -32,7 +33,7 @@ class CancerpredictsController < ApplicationController result['page_title'] = @form_to_show.title_texts[params[:locale]] elsif params['get_mapping_data_from_csv'].to_i == 1 result = {} - result['mapping_data_from_csv'] = YAML.load(@form_to_show.mapping_data_from_csv) rescue {} + result['mapping_data_from_csv'] = JSON.parse(@form_to_show.mapping_data_from_csv) rescue {} else @record = Cancerpredictrecord.new @record.title = @app_title @@ -59,7 +60,7 @@ class CancerpredictsController < ApplicationController # else # result['cal_value'] = 1 # end - mapping_data_from_csv = YAML.load(@form_to_show.mapping_data_from_csv) rescue {} + mapping_data_from_csv = JSON.parse(@form_to_show.mapping_data_from_csv) rescue {} @form_to_show.form_show.each do |num,property| @variable = property[:variable] if @variable.present? @@ -102,13 +103,17 @@ class CancerpredictsController < ApplicationController end end #result['lpv'] = -0.51427548* (result['sex_value']- 0.508312) + 0.05764604* (result['Age_value'] - 61.894501) + 0.49138819*(result['cal_value'] - 0.334399) rescue 'error' - formula = @form_to_show.tmp_lpv_ruby_code - formula_variables = @form_to_show.tmp_lpv_variables_ruby_code - eval(formula) - result['lpv'] = eval(formula_variables.last) + formula_variables = @form_to_show.tmp_lpv_variables + begin + eval_formula(result) + rescue => e + @form_to_show.generate_eval_formula + eval_formula(result) + end + result['lpv'] = instance_variable_get(formula_variables.last) result['lpv_variable'] = {} formula_variables.each do |variable_name| - eval( "result['lpv_variable']['#{variable_name}'] = #{variable_name}" ) + result['lpv_variable']["#{variable_name[1..-1]}"] = instance_variable_get(variable_name) end @years = @form_to_show.years result['table'] = '
'+@form_to_show.table_above_texts[locale].to_s+'
' @@ -141,7 +146,7 @@ class CancerpredictsController < ApplicationController year = year.to_f end year_index = @years.index(year) - @servive_ratio = eval(@form_to_show.tmp_years_settings[year_index]) + @servive_ratio = eval(@form_to_show.tmp_years_settings_for_ruby[year_index]) @servive_ratio = ((1 - @servive_ratio) * 100).round(2) @texts = @form_to_show.text_above_texts[locale].to_s.gsub('