diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 3ea1934f5..fcc1eef61 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -1,5 +1,5 @@ class PollController < ApplicationController - before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result] + before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result,:create_poll_question] before_filter :find_container, :only => [:new,:create, :index] before_filter :is_member_of_course, :only => [:index,:show] before_filter :is_course_teacher, :only => [:new,:create,:edit,:update,:destroy] @@ -54,7 +54,9 @@ class PollController < ApplicationController end def edit - + respond_to do |format| + format.html{render :layout => 'base_courses'} + end end def update @@ -82,8 +84,30 @@ class PollController < ApplicationController end #添加单选题 - def add_mc - + def create_poll_question + question_title = params[:poll_questions_title].nil? || params[:poll_questions_title].empty? ? l(:label_enter_single_title) : params[:poll_questions_title] + option = { + :is_necessary => params[:is_necessary] || true, + :question_title => question_title, + :question_type => params[:question_type] || 1, + :question_number => @poll.poll_questions.count + 1 + } + @poll_questions = @poll.poll_questions.new option + if params[:question_answer] + for i in 1..params[:question_answer].count + answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1] + question_option = { + :answer_position => i, + :answer_text => params[:question_answer].values[i-1] + } + @poll_questions.poll_answers.new question_option + end + end + if @poll_questions.save + respond_to do |format| + format.js + end + end end #提交答案 diff --git a/app/views/poll/_edit_MC.html.erb b/app/views/poll/_edit_MC.html.erb index 73d967ca9..0f031f61c 100644 --- a/app/views/poll/_edit_MC.html.erb +++ b/app/views/poll/_edit_MC.html.erb @@ -1,33 +1,45 @@ -
-
-
- - - - -
-
-
    -
  • - - - - -
  • -
    -
  • - - - - -
  • +<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%> +
    + +
    +
    + + + + + +
    +
    +
      +
    • + + + + +
    • +
      +
    • + + + + +
    • +
      +
    • + + + + +
    • +
      +
    +
    +
    -
-
- +
-
-
- \ No newline at end of file +<% end%> \ No newline at end of file diff --git a/app/views/poll/_poll_form.html.erb b/app/views/poll/_poll_form.html.erb new file mode 100644 index 000000000..473c1df83 --- /dev/null +++ b/app/views/poll/_poll_form.html.erb @@ -0,0 +1,83 @@ + + + + + 问卷调查_问卷编辑 + <%= stylesheet_link_tag 'polls', :media => 'all' %> + + + + + +
+ +
+ +
+
+ + <%= render :partial => 'edit_head'%> + +
+ <% @poll.poll_questions.each do |poll_question|%> + <%= render :partial => 'show_MC', :locals => {:poll_question => poll_question} %> + <% end%> +
+
+ <%#= render :partial => 'edit_MC'%> +
+ +
+ + <%= l(:label_memo_create)%> + +
+
+ +
+ + diff --git a/app/views/poll/_show_MC.html.erb b/app/views/poll/_show_MC.html.erb index b156bc0bc..a33967ffd 100644 --- a/app/views/poll/_show_MC.html.erb +++ b/app/views/poll/_show_MC.html.erb @@ -1,10 +1,13 @@
- 第<%= question_index%>题: + 第<%= poll_question.question_number%>题: - <%= poll_questions.question_title%> - * + <%= poll_question.question_title %> + <%if poll_question.is_necessary == 1%> + * + <%end%> +
@@ -12,24 +15,16 @@
- - - - - - - - - + <% poll_question.poll_answers.reorder("answer_position").each do |poll_answer| %> + + + + <% end %>
- -
- -
- -
+ +
diff --git a/app/views/poll/_show_head.html.erb b/app/views/poll/_show_head.html.erb new file mode 100644 index 000000000..f8a2d58f0 --- /dev/null +++ b/app/views/poll/_show_head.html.erb @@ -0,0 +1,8 @@ +
+

标题标题标题标题标题标题标题

+

描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述 + 描述描述描述描述描述描述描述描述描述描述描述描述 +

+ +
+
\ No newline at end of file diff --git a/app/views/poll/create_poll_question.js.erb b/app/views/poll/create_poll_question.js.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/poll/edit.html.erb b/app/views/poll/edit.html.erb index a35b1d2e7..d346d0699 100644 --- a/app/views/poll/edit.html.erb +++ b/app/views/poll/edit.html.erb @@ -1,13 +1,2 @@ - -<%= form_for(@poll) do |f|%> - <%= f.text_field :polls_name, :required => true, :name => "polls_name"%> - - <%= l(:label_button_ok) %> - -<% end%> +<%= render :partial => 'poll_form'%> diff --git a/app/views/poll/index.html.erb b/app/views/poll/index.html.erb index 150c13382..9d0bd5549 100644 --- a/app/views/poll/index.html.erb +++ b/app/views/poll/index.html.erb @@ -26,6 +26,11 @@ method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml20 mr10") %> <% end%> +
  • + <% if @is_teacher%> + <%= link_to l(:button_edit), edit_poll_path(poll.id), :class => "polls_de fr ml20"%> + <% end%> +
  • <%= format_time poll.created_at%>
  • diff --git a/app/views/poll/new.html.erb b/app/views/poll/new.html.erb index 06ef2fae8..eddb3a590 100644 --- a/app/views/poll/new.html.erb +++ b/app/views/poll/new.html.erb @@ -1,59 +1 @@ - - - - - 问卷调查_问卷编辑 - <%= stylesheet_link_tag 'polls', :media => 'all' %> - - - - - -
    - - - -<%= render :partial => 'edit_head'%> - -
    -
    - - -
    - -
    - - +<%= render :partial => 'poll_form'%> \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index d130cc666..9dae54818 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2249,5 +2249,7 @@ zh: label_MCQ: 多选题 label_single: 单行文字 label_mulit: 多行文字 + label_enter_single_title: 请输入单选题标题 + label_new_answer: 新建选项 diff --git a/config/routes.rb b/config/routes.rb index 931b9f919..28aa7452c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -61,8 +61,8 @@ RedmineApp::Application.routes.draw do resources :poll do member do get 'statistics_result' - get 'add_mc' post 'commit_answer' + post 'create_poll_question' end end diff --git a/db/schema.rb b/db/schema.rb index 53d57d748..2120080a0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -23,18 +23,6 @@ ActiveRecord::Schema.define(:version => 20150114022710) do add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type" add_index "activities", ["user_id"], :name => "index_activities_on_user_id" - create_table "api_keys", :force => true do |t| - t.string "access_token" - t.datetime "expires_at" - t.integer "user_id" - t.boolean "active", :default => true - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "api_keys", ["access_token"], :name => "index_api_keys_on_access_token" - add_index "api_keys", ["user_id"], :name => "index_api_keys_on_user_id" - create_table "applied_projects", :force => true do |t| t.integer "project_id", :null => false t.integer "user_id", :null => false diff --git a/public/stylesheets/polls.css b/public/stylesheets/polls.css index 428ade808..b13cb1da2 100644 --- a/public/stylesheets/polls.css +++ b/public/stylesheets/polls.css @@ -13,6 +13,11 @@ div,html,img,ul,li,p,body,h1,h2,h3,h4,p,a,table,tr,td,fieldset,input,span{ margi #polls .fl{ float: left;} #polls .fr{ float:right;} +/*问卷按钮*/ +.polls_btn{ height:33px;border-top:1px solid #15bed1; border-bottom:1px solid #15bed1;border-right:1px solid #cee6e6; width:225px; padding:7px 0 0 15px; } +.polls_btn a{font-size:14px; color:#444444;font-weight:bold;} +.polls_btn span{ color:#15bed1; font-size:12px; font-weight:normal;} + /*问卷列表*/ .polls_content{ width:615px;} .polls_head{ width:677px; height:48px; background:#eaeaea;}