From e4edc5d1db85c13906772869e6ef34e07832c962 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Wed, 14 Jan 2015 10:05:05 +0800
Subject: [PATCH 1/5] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E4=BF=AE=E6=94=B9?=
=?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=8A=A8=E6=80=81=E5=8A=A0=E8=BD=BD=202.?=
=?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BC=96=E8=BE=91=E5=AE=8C=E6=88=90=E5=90=8E?=
=?UTF-8?q?=E9=97=AE=E5=8D=B7=E5=A4=B4=E9=A1=B5=E9=9D=A2=203.=E5=A2=9E?=
=?UTF-8?q?=E5=8A=A0=E9=97=AE=E5=8D=B7=E6=8C=89=E9=92=AE=E7=9A=84css?=
=?UTF-8?q?=E6=A0=B7=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/poll/_poll_form.html.erb | 59 +++++++++++++++++++++++++++++
app/views/poll/_show_head.html.erb | 8 ++++
app/views/poll/edit.html.erb | 13 +------
app/views/poll/index.html.erb | 5 +++
app/views/poll/new.html.erb | 60 +-----------------------------
public/stylesheets/polls.css | 5 +++
6 files changed, 79 insertions(+), 71 deletions(-)
create mode 100644 app/views/poll/_poll_form.html.erb
create mode 100644 app/views/poll/_show_head.html.erb
diff --git a/app/views/poll/_poll_form.html.erb b/app/views/poll/_poll_form.html.erb
new file mode 100644
index 000000000..0387bb9c6
--- /dev/null
+++ b/app/views/poll/_poll_form.html.erb
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+ <%= render :partial => 'edit_head'%>
+
+
+
+
+
+
+
+
+
+
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/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"%>
-
-
-
-
-<%= render :partial => 'edit_head'%>
-
-
-
-
-
-
-
-
-
-
+<%= render :partial => 'poll_form'%>
\ No newline at end of file
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;}
From eb2498c62c6af8f3af92641d6bd5796964ec56cf Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Wed, 14 Jan 2015 14:23:41 +0800
Subject: [PATCH 2/5] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E6=96=B0=E5=A2=9E?=
=?UTF-8?q?=E5=8D=95=E9=80=89=E9=A2=98=E3=80=81=E6=96=B0=E5=A2=9E=E9=80=89?=
=?UTF-8?q?=E9=A1=B9=E3=80=81=E5=88=A0=E9=99=A4=E9=80=89=E9=A1=B9=E7=AD=89?=
=?UTF-8?q?js=202.=E4=BF=AE=E6=94=B9=E9=97=AE=E5=8D=B7layout=E5=A2=9E?=
=?UTF-8?q?=E5=8A=A0=203.=E5=A2=9E=E5=8A=A0=E6=96=B0=E5=A2=9E=E5=8D=95?=
=?UTF-8?q?=E9=80=89=E9=A2=98=E7=A1=AE=E5=AE=9A=E6=8C=89=E9=92=AE=E7=9A=84?=
=?UTF-8?q?=E8=B7=AF=E7=94=B1=E4=BB=A5=E5=8F=8A=E7=9B=B8=E5=85=B3action?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/poll_controller.rb | 8 ++--
app/views/poll/_edit_MC.html.erb | 55 +++++++++++-------------
app/views/poll/_poll_form.html.erb | 17 ++++++++
app/views/poll/_question_answer.html.erb | 11 +++++
config/routes.rb | 2 +-
5 files changed, 58 insertions(+), 35 deletions(-)
create mode 100644 app/views/poll/_question_answer.html.erb
diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb
index 9177e044b..e1439b7f9 100644
--- a/app/controllers/poll_controller.rb
+++ b/app/controllers/poll_controller.rb
@@ -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,8 @@ class PollController < ApplicationController
end
#添加单选题
- def add_mc
-
+ def create_poll_question
+ a = 1
end
private
diff --git a/app/views/poll/_edit_MC.html.erb b/app/views/poll/_edit_MC.html.erb
index 73d967ca9..492126827 100644
--- a/app/views/poll/_edit_MC.html.erb
+++ b/app/views/poll/_edit_MC.html.erb
@@ -1,33 +1,26 @@
-
-
\ 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
index 0387bb9c6..a8ad46694 100644
--- a/app/views/poll/_poll_form.html.erb
+++ b/app/views/poll/_poll_form.html.erb
@@ -10,6 +10,22 @@
function add_MCQ(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_MCQ') %>");}
function add_single(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_single') %>");}
function add_mulit(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_mulit') %>");}
+ //单选题
+ function add_single_answer(doc)
+ {
+ doc.parent().after("<%= escape_javascript(render :partial => 'question_answer') %>");
+ }
+ function remove_single_answer(doc)
+ {
+ if(doc.parent().siblings("li").length == 0)
+ {
+ doc.parent().parent().parent().parent().parent().parent().remove();
+ }
+ else
+ {
+ doc.parent().remove();
+ }
+ }
@@ -45,6 +61,7 @@
<%= render :partial => 'edit_head'%>
+ <%#= render :partial => 'edit_MC'%>
diff --git a/app/views/poll/_question_answer.html.erb b/app/views/poll/_question_answer.html.erb
new file mode 100644
index 000000000..765d71787
--- /dev/null
+++ b/app/views/poll/_question_answer.html.erb
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index af0b75ae7..d2d0c73a8 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -61,7 +61,7 @@ RedmineApp::Application.routes.draw do
resources :poll do
member do
get 'statistics_result'
- get 'add_mc'
+ post 'create_poll_question'
end
end
From 0433f7c87f551b4544e267b335c571a36bde130a Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Wed, 14 Jan 2015 15:35:04 +0800
Subject: [PATCH 3/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=B0=E5=BB=BA?=
=?UTF-8?q?=E5=8D=95=E9=80=89=E9=A2=98=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/poll_controller.rb | 25 +++++++++++++++++++++++--
app/views/poll/_edit_MC.html.erb | 11 ++++++++---
app/views/poll/_poll_form.html.erb | 4 +++-
config/locales/zh.yml | 2 ++
db/schema.rb | 12 ------------
5 files changed, 36 insertions(+), 18 deletions(-)
diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb
index b3fdf5087..99287e2cd 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]
@@ -85,7 +85,28 @@ class PollController < ApplicationController
#添加单选题
def create_poll_question
- a = 1
+ 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
+ }
+ @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
private
diff --git a/app/views/poll/_edit_MC.html.erb b/app/views/poll/_edit_MC.html.erb
index 492126827..bf120a20a 100644
--- a/app/views/poll/_edit_MC.html.erb
+++ b/app/views/poll/_edit_MC.html.erb
@@ -4,15 +4,20 @@