diff --git a/vendor/built_in_modules/survey_b/app/controllers/panel/survey_b/back_end/periods_controller.rb b/vendor/built_in_modules/survey_b/app/controllers/panel/survey_b/back_end/periods_controller.rb index 0b3a1bd22..0c75d6bbc 100644 --- a/vendor/built_in_modules/survey_b/app/controllers/panel/survey_b/back_end/periods_controller.rb +++ b/vendor/built_in_modules/survey_b/app/controllers/panel/survey_b/back_end/periods_controller.rb @@ -4,7 +4,7 @@ class Panel::SurveyB::BackEnd::PeriodsController < OrbitBackendController include OrbitControllerLib::DivisionForDisable before_filter :for_app_manager - + def initialize super @app_title = 'survey_b' @@ -68,13 +68,12 @@ class Panel::SurveyB::BackEnd::PeriodsController < OrbitBackendController def destroy @period = SurveyBPeriod.find(params[:id]) - @period.destroy - respond_to do |format| - - format.html { redirect_to(panel_survey_b_back_end_periods_url) } - format.js + if @period.destroy + format.html { redirect_to(panel_survey_b_back_end_periods_url(:page => params[:page])) } + format.xml { head :ok } + end end end -end +end \ No newline at end of file diff --git a/vendor/built_in_modules/survey_b/app/controllers/panel/survey_b/back_end/settings_controller.rb b/vendor/built_in_modules/survey_b/app/controllers/panel/survey_b/back_end/settings_controller.rb index e60386abe..cc1ab8315 100644 --- a/vendor/built_in_modules/survey_b/app/controllers/panel/survey_b/back_end/settings_controller.rb +++ b/vendor/built_in_modules/survey_b/app/controllers/panel/survey_b/back_end/settings_controller.rb @@ -4,7 +4,7 @@ class Panel::SurveyB::BackEnd::SettingsController < OrbitBackendController include OrbitControllerLib::DivisionForDisable before_filter :for_app_manager - + def initialize super @app_title = 'survey_b' @@ -33,4 +33,4 @@ class Panel::SurveyB::BackEnd::SettingsController < OrbitBackendController end -end +end \ No newline at end of file diff --git a/vendor/built_in_modules/survey_b/app/controllers/panel/survey_b/back_end/survey_b_controller.rb b/vendor/built_in_modules/survey_b/app/controllers/panel/survey_b/back_end/survey_b_controller.rb index fd5613825..20284f5b0 100644 --- a/vendor/built_in_modules/survey_b/app/controllers/panel/survey_b/back_end/survey_b_controller.rb +++ b/vendor/built_in_modules/survey_b/app/controllers/panel/survey_b/back_end/survey_b_controller.rb @@ -89,4 +89,4 @@ class Panel::SurveyB::BackEnd::SurveyBController < OrbitBackendController end end -end +end \ No newline at end of file diff --git a/vendor/built_in_modules/survey_b/app/controllers/panel/survey_b/front_end/survey_b_controller.rb b/vendor/built_in_modules/survey_b/app/controllers/panel/survey_b/front_end/survey_b_controller.rb index 21625bf04..96b06067d 100644 --- a/vendor/built_in_modules/survey_b/app/controllers/panel/survey_b/front_end/survey_b_controller.rb +++ b/vendor/built_in_modules/survey_b/app/controllers/panel/survey_b/front_end/survey_b_controller.rb @@ -2,11 +2,22 @@ class Panel::SurveyB::FrontEnd::SurveyBController < OrbitWidgetController helper ApplicationHelper def index + if params[:period].nil? + @period = SurveyBPeriod.get_current_survey() + else + @period = SurveyBPeriod.find(params[:period]) + end + redirect_standalone panel_survey_b_front_end_survey_b_index_path( :standalone => 'true') do @setting = SurveyBSetting.first_or_create if params[:agree] == '1' + # @period = SurveyBPeriod.first render :index, :layout => 'standalone' else + # Escape from error when announcement is empty + if @setting.announcement.nil? + @setting.announcement = " " + end render :announcement, :layout => 'standalone' end end @@ -64,8 +75,14 @@ class Panel::SurveyB::FrontEnd::SurveyBController < OrbitWidgetController else module_app = ModuleApp.first(:conditions => {:key => 'survey_b'}) @item = Item.where(module_app_id: module_app.id).first - yield + + if @period + yield + else + # render :no_survey + # render :json => "No Survey" + render :no_survey, :layout => 'standalone' + end end end - end \ No newline at end of file diff --git a/vendor/built_in_modules/survey_b/app/models/survey_b_period.rb b/vendor/built_in_modules/survey_b/app/models/survey_b_period.rb index 9ba15a59a..ed7282727 100644 --- a/vendor/built_in_modules/survey_b/app/models/survey_b_period.rb +++ b/vendor/built_in_modules/survey_b/app/models/survey_b_period.rb @@ -2,9 +2,40 @@ class SurveyBPeriod include Mongoid::Document include Mongoid::Timestamps + field :title, :type => String field :start_date, :type => DateTime field :end_date, :type => DateTime validates :start_date, :end_date, :presence => true + def self.get_current_survey + self.where(:start_date.lte => Time.now, :end_date.gte => Time.now).first + end + + def isAvailable? + if start_date <= Time.now and end_date >= Time.now + return true + else + return false + end + end + + def get_status_type + # status type + # reference to config/locales/en.yml and zh-tw.yml + # status_types: + # type1: 調查中 + # type2: 未開始 + # type3: 已結束 + + if start_date <= Time.now and end_date >= Time.now + return "type1" + end + if start_date > Time.now + return "type2" + end + if end_date < Time.now + return "type3" + end + end end \ No newline at end of file diff --git a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/periods/_form.html.erb b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/periods/_form.html.erb index 3704687c8..f27187d31 100644 --- a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/periods/_form.html.erb +++ b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/periods/_form.html.erb @@ -1,11 +1,36 @@
<%= @period.errors.full_messages.join ', ' %> -
- <%= f.datetime_picker :start_date, :picker_type => 'separated', :label => t('survey.postdate') %> -
-
- <%= f.datetime_picker :end_date, :picker_type => 'separated', :label => t('survey.deadline') %> + +
+ +
+
+ +
+

<%= t('survey_b.period_title') %>

+
+
+ <%= f.text_field :title %> +
+
+
+
+
+
+ +
+

<%= t('survey_b.period') %>

+
+
+ <%= f.datetime_picker :start_date, :picker_type => 'separated', :label => t('survey.postdate') %> +
+
+ <%= f.datetime_picker :end_date, :picker_type => 'separated', :label => t('survey.deadline') %> +
+
+
+
@@ -15,5 +40,4 @@
-
\ No newline at end of file diff --git a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/periods/_period.html.erb b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/periods/_period.html.erb index 0eb1f6b7f..d52eaf483 100644 --- a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/periods/_period.html.erb +++ b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/periods/_period.html.erb @@ -1,4 +1,7 @@ + + <%= link_to period.title, panel_survey_b_front_end_survey_b_index_path(:period => period, :standalone => true), :target=>"_blank" %> + <%= display_date_time period.start_date %> @@ -14,4 +17,16 @@
- + + <% status_type = t('survey_b.status_types') %> + <% if period.start_date > Time.now %> + <%= status_type[:type2] %> + <% end %> + <% if period.start_date <= Time.now and period.end_date >= Time.now %> + <%= status_type[:type1] %> + <% end %> + <% if period.end_date < Time.now %> + <%= status_type[:type3] %> + <% end %> + + \ No newline at end of file diff --git a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/periods/edit.html.erb b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/periods/edit.html.erb index 34e3b7d0d..0569ca9ff 100644 --- a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/periods/edit.html.erb +++ b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/periods/edit.html.erb @@ -1,5 +1,4 @@

<%= t(:edit) + t('survey_b.period') %>

- <%= form_for @period, :url => panel_survey_b_back_end_period_path(@period), :html => {:class => 'clear'} do |f| %> <%= render :partial => 'form', :locals => {:f => f} %> <% end %> diff --git a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/periods/index.html.erb b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/periods/index.html.erb index 3174cdeaa..451eda019 100644 --- a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/periods/index.html.erb +++ b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/periods/index.html.erb @@ -1,7 +1,9 @@ - + + + diff --git a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/survey_b/result.html.erb b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/survey_b/result.html.erb index fd8b17970..0fc0a7a66 100644 --- a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/survey_b/result.html.erb +++ b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/survey_b/result.html.erb @@ -1,9 +1,11 @@ <% if @period %> -

+

<%= @period.title %>

+

+ <%= t('survey_b.period') %>: <%= display_date_time @period.start_date %> - <%= display_date_time @period.end_date %> -

+ <% end %>
<%= t('survey_b.period') %><%= t('survey_b.period_title') %><%= t('survey_b.period') %><%= t('survey_b.status') %>
diff --git a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/front_end/survey_b/announcement.html.erb b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/front_end/survey_b/announcement.html.erb index 81b6446f3..0c91f0db9 100644 --- a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/front_end/survey_b/announcement.html.erb +++ b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/front_end/survey_b/announcement.html.erb @@ -1,21 +1,28 @@ -

<%= @item.title %>

+

<%= @period.title %>

+
- <%= form_for :answer, :url => panel_survey_b_front_end_survey_b_index_path, :method => :get, :html => {:class => 'survey_b clear'} do |f| %> - <%= f.hidden_field :standalone, :value => true, :name => :standalone %> -

- <%= @setting.announcement.gsub("\n", '
').html_safe %> -

-
-

- <%= f.check_box :agree, :name => :agree %> - <%= f.label :agree, t('survey_b.agree_check'), :style => "display:inline" %> -

+ <% if @period.isAvailable? %> + <%= form_for :answer, :url => panel_survey_b_front_end_survey_b_index_path, :method => :get, :html => {:class => 'survey_b clear'} do |f| %> + <%= f.hidden_field :standalone, :value => true, :name => :standalone %> + <%= f.hidden_field :period_id, :value => @period.id, :name => :period %> +

+ <%= p @setting.announcement.gsub("\n", '
').html_safe %> +

+
+

+ <%= f.check_box :agree, :name => :agree %> + <%= f.label :agree, t('survey_b.agree_check'), :style => "display:inline" %> +

-
- <%= f.submit t('submit'), :class => 'survey-submit' %> -
+
+ <%= f.submit t('submit'), :class => 'survey-submit' %> +
+ <% end %> + <% else %> + <% status_type = t('survey_b.status_types') %> +

<%= t('survey_b.survey_b') + status_type[@period.get_status_type.to_sym] %>

<% end %>
diff --git a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/front_end/survey_b/index.html.erb b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/front_end/survey_b/index.html.erb index 1df9b82fe..efcf56110 100644 --- a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/front_end/survey_b/index.html.erb +++ b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/front_end/survey_b/index.html.erb @@ -1,6 +1,6 @@ <% # encoding: utf-8 %> <% institutions = t('survey_b.institutions') %> -

<%= @item.title %>

+

<%= @period.title %>

diff --git a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/front_end/survey_b/no_survey.html.erb b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/front_end/survey_b/no_survey.html.erb new file mode 100644 index 000000000..e67353438 --- /dev/null +++ b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/front_end/survey_b/no_survey.html.erb @@ -0,0 +1,6 @@ +

<%= t('survey_b.no_survey') %>

+ \ No newline at end of file diff --git a/vendor/built_in_modules/survey_b/config/locales/en.yml b/vendor/built_in_modules/survey_b/config/locales/en.yml index 6ca249e0b..9bdc9a1a4 100644 --- a/vendor/built_in_modules/survey_b/config/locales/en.yml +++ b/vendor/built_in_modules/survey_b/config/locales/en.yml @@ -14,8 +14,15 @@ en: not_answered: 沒有回答 - period: 問卷期間 - period_title: 問卷期間標題 + period: 調查期間 + period_title: 問卷標題 + no_survey: 尚無滿意度調查 + + status: 狀態 + status_types: + type1: 調查中 + type2: 未開始 + type3: 已結束 no_data: 沒有數據 answered_count: 答題人數 @@ -33,7 +40,7 @@ en: institution8: 駐警隊 institution9: 社科院總務分處 institution10: 醫學院總務分處 - institution11: 總務處秘書室 + # institution11: 總務處秘書室 degrees: - 很滿意 diff --git a/vendor/built_in_modules/survey_b/config/locales/zh_tw.yml b/vendor/built_in_modules/survey_b/config/locales/zh_tw.yml index d3e2b1a94..5744b6bee 100644 --- a/vendor/built_in_modules/survey_b/config/locales/zh_tw.yml +++ b/vendor/built_in_modules/survey_b/config/locales/zh_tw.yml @@ -14,7 +14,15 @@ zh_tw: not_answered: 沒有回答 - period: 問卷期間 + period: 調查期間 + period_title: 問卷標題 + no_survey: 尚無滿意度調查 + + status: 狀態 + status_types: + type1: 調查中 + type2: 未開始 + type3: 已結束 no_data: 沒有數據 answered_count: 答題人數 @@ -32,7 +40,7 @@ zh_tw: institution8: 駐警隊 institution9: 社科院總務分處 institution10: 醫學院總務分處 - institution11: 總務處秘書室 + # institution11: 總務處秘書室 degrees: - 很滿意 diff --git a/vendor/built_in_modules/survey_b/init.rb b/vendor/built_in_modules/survey_b/init.rb index 890065f5c..3540afa9b 100644 --- a/vendor/built_in_modules/survey_b/init.rb +++ b/vendor/built_in_modules/survey_b/init.rb @@ -29,23 +29,23 @@ module SurveyB head_link_path "panel_survey_b_back_end_periods_path" - context_link 'survey_b.result', - :link_path=>"result_panel_survey_b_back_end_survey_b_index_path" , - :priority=>1, - :active_for_action=>{:survey_b=>:result}, - :available_for => [:manager] + # context_link 'survey_b.result', + # :link_path=>"result_panel_survey_b_back_end_survey_b_index_path" , + # :priority=>1, + # :active_for_action=>{:survey_b=>:result}, + # :available_for => [:manager] - context_link 'list_', - :link_path=>"panel_survey_b_back_end_survey_b_index_path" , - :priority=>1, - :active_for_action=>{:survey_b=>:index}, - :available_for => [:manager] + # context_link 'list_', + # :link_path=>"panel_survey_b_back_end_survey_b_index_path" , + # :priority=>1, + # :active_for_action=>{:survey_b=>:index}, + # :available_for => [:manager] - context_link 'survey_b.period', - :link_path=>"panel_survey_b_back_end_periods_path" , - :priority=>1, - :active_for_action=>{:periods=>:index}, - :available_for => [:manager] + # context_link 'survey_b.period', + # :link_path=>"panel_survey_b_back_end_periods_path" , + # :priority=>1, + # :active_for_action=>{:periods=>:index}, + # :available_for => [:manager] context_link 'survey_b.setting', :link_path=>"edit_panel_survey_b_back_end_setting_path" , diff --git a/vendor/built_in_modules/survey_b/test/dummy/script/rails b/vendor/built_in_modules/survey_b/test/dummy/script/rails old mode 100755 new mode 100644