Fixed bugs and some modification in module "survey_b"

This commit is contained in:
Manson Wang 2013-09-12 16:55:41 +08:00 committed by chris
parent ae79694b44
commit cb0f126aad
17 changed files with 175 additions and 58 deletions

View File

@ -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

View File

@ -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

View File

@ -89,4 +89,4 @@ class Panel::SurveyB::BackEnd::SurveyBController < OrbitBackendController
end
end
end
end

View File

@ -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

View File

@ -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

View File

@ -1,11 +1,36 @@
<div id= "poststuff">
<div id="post-body">
<%= @period.errors.full_messages.join ', ' %>
<div class="control-group">
<%= f.datetime_picker :start_date, :picker_type => 'separated', :label => t('survey.postdate') %>
</div>
<div class="control-group">
<%= f.datetime_picker :end_date, :picker_type => 'separated', :label => t('survey.deadline') %>
<div id="sub-wiget" style="float: none;">
<div id="widget-title" class="widget-box widget-size-300">
<div class="widget-action clear tip" title="問卷標題">
<a href="#" class="action"><i class="icon-exclamation-sign icon-white"></i></a>
</div>
<h3 class="widget-title"><i class="icons-calendar"></i><%= t('survey_b.period_title') %></h3>
<div class="widget-content clear">
<div class="control-group">
<%= f.text_field :title %>
</div>
</div>
</div>
<br/>
<div id="widget-date" class="widget-box widget-size-300">
<div class="widget-action clear tip" title="<%= t('survey_b.period') %>">
<a href="#" class="action"><i class="icon-exclamation-sign icon-white"></i></a>
</div>
<h3 class="widget-title"><i class="icons-calendar"></i><%= t('survey_b.period') %></h3>
<div class="widget-content clear">
<div class="control-group">
<%= f.datetime_picker :start_date, :picker_type => 'separated', :label => t('survey.postdate') %>
</div>
<div class="control-group">
<%= f.datetime_picker :end_date, :picker_type => 'separated', :label => t('survey.deadline') %>
</div>
</div>
</div>
</div>
<div class="form-actions">
@ -15,5 +40,4 @@
</div>
</div>
</div>

View File

@ -1,4 +1,7 @@
<tr class="with_action">
<td>
<%= link_to period.title, panel_survey_b_front_end_survey_b_index_path(:period => period, :standalone => true), :target=>"_blank" %>
</td>
<td>
<a href="<%= result_panel_survey_b_back_end_survey_b_index_path(:period => period.id)%>">
<%= display_date_time period.start_date %>
@ -14,4 +17,16 @@
</ul>
</div>
</td>
</tr>
<td>
<% status_type = t('survey_b.status_types') %>
<% if period.start_date > Time.now %>
<span class="label label-info"><%= status_type[:type2] %></span>
<% end %>
<% if period.start_date <= Time.now and period.end_date >= Time.now %>
<span class="label label-success"><%= status_type[:type1] %></span>
<% end %>
<% if period.end_date < Time.now %>
<span class="label"><%= status_type[:type3] %></span>
<% end %>
</td>
</tr>

View File

@ -1,5 +1,4 @@
<h1><%= t(:edit) + t('survey_b.period') %></h1>
<%= form_for @period, :url => panel_survey_b_back_end_period_path(@period), :html => {:class => 'clear'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>

View File

@ -1,7 +1,9 @@
<table class="table main-list">
<thead>
<tr>
<th class="span1"><%= t('survey_b.period') %></th>
<th width="20%"><%= t('survey_b.period_title') %></th>
<th width="20%"><%= t('survey_b.period') %></th>
<th><%= t('survey_b.status') %></th>
</tr>
</thead>
<tbody id="tbody_survey_periods" class="sort-holder">

View File

@ -1,9 +1,11 @@
<% if @period %>
<h1>
<h1><%= @period.title %></h1>
<h4>
<%= t('survey_b.period') %>:
<%= display_date_time @period.start_date %>
-
<%= display_date_time @period.end_date %>
</h1>
</h4>
<% end %>
<table class="table main-list">

View File

@ -1,21 +1,28 @@
<h1><%= @item.title %></h1>
<h1><%= @period.title %></h1>
<div>
<section>
<div class="o-question">
<%= 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 %>
<p>
<%= @setting.announcement.gsub("\n", '<br />').html_safe %>
</p>
<br />
<p>
<%= f.check_box :agree, :name => :agree %>
<%= f.label :agree, t('survey_b.agree_check'), :style => "display:inline" %>
</p>
<% 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>
<%= p @setting.announcement.gsub("\n", '<br />').html_safe %>
</p>
<br />
<p>
<%= f.check_box :agree, :name => :agree %>
<%= f.label :agree, t('survey_b.agree_check'), :style => "display:inline" %>
</p>
<div class="o-question-action">
<%= f.submit t('submit'), :class => 'survey-submit' %>
</div>
<div class="o-question-action">
<%= f.submit t('submit'), :class => 'survey-submit' %>
</div>
<% end %>
<% else %>
<% status_type = t('survey_b.status_types') %>
<p class="text-warning"><h4><%= t('survey_b.survey_b') + status_type[@period.get_status_type.to_sym] %></h4></p>
<% end %>
</div>
</section>

View File

@ -1,6 +1,6 @@
<% # encoding: utf-8 %>
<% institutions = t('survey_b.institutions') %>
<h1><%= @item.title %></h1>
<h1><%= @period.title %></h1>
<div>
<section>
<div class="o-question">

View File

@ -0,0 +1,6 @@
<h1><%= t('survey_b.no_survey') %></h1>
<script type="text/javascript">
$(document).ready().delay(2000).queue(function() {
window.location.href = "<%= root_path %>";
});
</script>

View File

@ -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:
- 很滿意

View File

@ -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:
- 很滿意

View File

@ -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" ,

0
vendor/built_in_modules/survey_b/test/dummy/script/rails vendored Executable file → Normal file
View File