">
+
+ <%= school.id %>
+ |
- <%= image_tag(school.logo_link,width:46,height:46) %>
+ <%= image_tag(school.logo_link,width:40,height:40) %>
|
From 6091369e02b33042749218e39a401eace43da23c Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Mon, 27 Jul 2015 18:20:20 +0800
Subject: [PATCH 05/39] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AD=A6=E6=A0=A1logo?=
=?UTF-8?q?=E7=9A=84=E4=B8=8A=E4=BC=A0=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BB=A5?=
=?UTF-8?q?=E5=8F=8A=E5=AE=9E=E6=97=B6=E9=A2=84=E8=A7=88=E6=95=88=E6=9E=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/admin_controller.rb | 6 +++---
app/controllers/school_controller.rb | 17 +++++----------
app/views/admin/schools.html.erb | 4 ++--
app/views/school/upload_logo.html.erb | 31 +++++++++++++++++++++++----
config/routes.rb | 14 +++++++++---
public/stylesheets/application.css | 13 ++++++++++-
6 files changed, 60 insertions(+), 25 deletions(-)
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index d2c94f5de..a44b58789 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -340,9 +340,9 @@ class AdminController < ApplicationController
#学校列表
def schools
- @q = params[:school_name]
- if @q
- @schools = School.where("name like '%#{@q}%'")
+ @school_name = params[:school_name]
+ if @school_name
+ @schools = School.where("name like '%#{@school_name}%'")
else
@schools = School.all
end
diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb
index 008fe00fc..3e0c280ac 100644
--- a/app/controllers/school_controller.rb
+++ b/app/controllers/school_controller.rb
@@ -4,28 +4,21 @@ class SchoolController < ApplicationController
def upload
uploaded_io = params[:logo]
- school_id = 0
- schools = School.where("name = ?", params[:school])
-
- schools.each do |s|
- school_id = s.id
- end
-
+ school_id ||= params[:id]
unless uploaded_io.nil?
File.open(Rails.root.join('public', 'images', 'school', school_id.to_s+'.png'), 'wb') do |file|
file.write(uploaded_io.read)
end
-
s1 = School.find(school_id)
s1.logo_link = '/images/school/'+school_id.to_s+'.png'
s1.save
-
-
- end
+ end
+ redirect_to admin_schools_url(:school_name => params[:school_name])
end
def upload_logo
-
+ @school = School.find params[:id]
+ @school_name = params[:school_name]
end
#获取制定学校开设的课程数
diff --git a/app/views/admin/schools.html.erb b/app/views/admin/schools.html.erb
index b5e649dd0..0956981e8 100644
--- a/app/views/admin/schools.html.erb
+++ b/app/views/admin/schools.html.erb
@@ -3,7 +3,7 @@
<%= form_tag({:controller => 'admin', :action => 'schools' }, :method => :get,:id=>"search_course_form") do %>
<%= submit_tag "搜索",:style => "float: right;margin-right: 15px;"%>
-
+
<% end %>
@@ -38,7 +38,7 @@
|
- <%= link_to("上传logo", edit_organization_path(school.id), :class => 'icon icon-copy') %>
+ <%= link_to("修改", upload_logo_school_path(school.id,:school_name => @school_name), :class => 'icon icon-copy') %>
<%#= link_to(l(:button_delete), organization_path(school.id), :method => :delete,:confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
|
diff --git a/app/views/school/upload_logo.html.erb b/app/views/school/upload_logo.html.erb
index 97a3f171c..26da7e081 100644
--- a/app/views/school/upload_logo.html.erb
+++ b/app/views/school/upload_logo.html.erb
@@ -1,5 +1,28 @@
-<%= form_tag({action: :upload},method: "post", multipart: true) do %>
- <%= text_field_tag 'school'%>
- <%= file_field_tag 'logo' %>
- <%= submit_tag('Upload') %>
+
+
+<%= form_tag(upload_school_path(@school.id),method: "post", multipart: true) do %>
+ <%#= text_field_tag 'school'%>
+
diff --git a/app/views/poll/_poll_form.html.erb b/app/views/poll/_poll_form.html.erb
index 74ca9fb32..0a15143fb 100644
--- a/app/views/poll/_poll_form.html.erb
+++ b/app/views/poll/_poll_form.html.erb
@@ -6,23 +6,203 @@ function edit_head(){
$("#polls_description").val($("#polls_description_div").html());
}
- function add_MC(){
+function chooseQuestionType(quest_type,quest_id){
+ $("#div_"+quest_type+"_"+quest_id).css("position", "absolute");
+
+ $("#div_"+quest_type+"_"+quest_id).css("top", $("#add_"+quest_type+"_"+quest_id).offset().top+30);
+
+ $("#div_"+quest_type+"_"+quest_id).css("left", $("#add_"+quest_type+"_"+quest_id).offset().left-10);
+ if( $("#div_"+quest_type+"_"+quest_id).css('display') == 'block') {
+ $("#div_"+quest_type+"_"+quest_id).css('display', 'none');
+ }
+ else{
+ $("#div_"+quest_type+"_"+quest_id).css('display', 'block');
+ }
+}
+
+function add_MC(){
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MC') %>");
$("#poll_questions_title").focus();
- }
- function add_MCQ(){
+}
+
+ function insert_MC(quest_type,quest_num,quest_id){
+ $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(
+ '<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>'+
+ '
'+
+ '
'+
+ ''+
+ ''+
+ ''+
+ ''+
+ ''+
+ ''+
+ ''+
+ '
'+
+ '
'+
+ ''+
+ '
'+
+ '
'+
+ '<% end%>'
+ );
+ $("#poll_questions_title").focus();
+}
+
+function add_MCQ(){
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MCQ') %>");
$("#poll_questions_title").focus();
+}
+
+function insert_MCQ(quest_type,quest_num,quest_id){
+ $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(
+ '<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>'+
+ '
'+
+ '
'+
+ ''+
+ ''+
+ ''+
+ ''+
+ ''+
+ ''+
+ ''+
+ '
'+
+ '
'+
+ ''+
+ '
'+
+ '
'+
+ '<% end%>'
+ );
+ $("#poll_questions_title").focus();
}
+
function add_single(){
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_single') %>");
$("#poll_questions_title").focus();
}
+
+ function insert_SINGLE(quest_type,quest_num,quest_id){
+ $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(
+ '<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>'+
+ '
'+
+ '<% end%>'
+ );
+ $("#poll_questions_title").focus();
+ }
function add_mulit(){
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_mulit') %>");
$("#poll_questions_title").focus();
}
+ function insert_MULIT(quest_type,quest_num,quest_id){
+ $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(
+ '<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>'+
+ '
'+
+ '
'+
+ ''+
+ ''+
+ ''+
+ ''+
+ ''+
+ ''+
+ ''+
+ '
'+
+ '
'+
+ '
'+
+ ''+
+ '
'+
+ '
'+
+ '<% end%>'
+ );
+ $("#poll_questions_title").focus();
+ }
+
//添加标题时确定按钮
function add_poll_question(doc)
{
diff --git a/app/views/poll/_show_MC.html.erb b/app/views/poll/_show_MC.html.erb
index ff8e52f25..9c47894dc 100644
--- a/app/views/poll/_show_MC.html.erb
+++ b/app/views/poll/_show_MC.html.erb
@@ -1,3 +1,6 @@
+
@@ -9,9 +12,11 @@
*
<%end%>
+
<%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id),
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %>
+
-
\ No newline at end of file
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/poll/_show_MCQ.html.erb b/app/views/poll/_show_MCQ.html.erb
index 63b9d1c1f..fb2c03080 100644
--- a/app/views/poll/_show_MCQ.html.erb
+++ b/app/views/poll/_show_MCQ.html.erb
@@ -12,6 +12,7 @@
<%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id),
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %>
+
-
\ No newline at end of file
+
+
+" +
"
" +
"<% if @poll_questions.question_type == 1%>" +
@@ -23,4 +27,4 @@ $("#poll_content").append("
" +
"<% end%>" +
"
" +
"
");
-
+<% end %>
diff --git a/public/stylesheets/polls.css b/public/stylesheets/polls.css
index 353ec3937..83fa5089b 100644
--- a/public/stylesheets/polls.css
+++ b/public/stylesheets/polls.css
@@ -28,7 +28,7 @@ a:hover.pollsbtn{ background:#64bdd9; color:#fff; text-decoration:none;}
#polls div{word-break: break-all;word-wrap: break-word;}
.ur_prefix_content{ color:#656565; text-indent:30px; margin-top:10px; }
.ur_card{border-top:1px solid #dcdcdc;margin-top:20px; color:#3a3a3a;}
-.ur_title{ padding:20px 0px ; float:left; width:604px; }
+.ur_title{ padding:20px 0px ; float:left; width:564px; }
.ur_required{ font-weight: bold; color:red;}
.ur_inputs{ color:#666;}
.ur_table{border-top:1px solid #dcdcdc; background:#fff;}
@@ -101,10 +101,13 @@ a:hover.icon_remove{background:url(images/icons.png) -20px -338px no-repeat;}
.ur_editor02{width:648px; border:1px solid #cbcbcb; padding:10px; margin-bottom:10px;}
a.ur_button_submit{ display:block; width:106px; height:31px; margin:0 auto; background:#15bccf; color:#fff; font-size:16px; text-align:center; padding-top:4px; margin-bottom:10px; }
a:hover.ur_button_submit{ background:#0fa9bb; text-decoration:none;}
+
a.ur_icon_de{ background:url(images/icons.png) 0px -338px no-repeat; width:16px; height:27px; display:block;float:right; margin-top:15px;}
a:hover.ur_icon_de{ background:url(images/icons.png) -20px -338px no-repeat;}
.ur_icon_edit{ background:url(images/icons.png) 0px -272px no-repeat; width:16px; height:27px; display:block;float:right; margin-top:15px; margin-right:10px;}
a:hover.ur_icon_edit{ background:url(images/icons.png) -21px -272px no-repeat;}
+.ur_icon_add{ background:url(images/icons.png) 0px -310px no-repeat; width:16px; height:27px; display:block;float:right; margin-top:15px; margin-right:10px;}
+a:hover.ur_icon_add{background:url(images/icons.png) -20px -310px no-repeat;}
/***弹框***/
.popbox_polls{width:300px;height:100px;position:fixed !important;z-index:100;left:50%;top:50%;margin:-100px 0 0 -150px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;}
From 6b45702f8c403a7f5b37393ae26b9cb8cbf664d0 Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Tue, 28 Jul 2015 11:20:21 +0800
Subject: [PATCH 07/39] =?UTF-8?q?=E7=82=B9=E5=87=BB=E7=A9=BA=E7=99=BD?=
=?UTF-8?q?=E5=A4=84=E5=8F=AF=E4=BB=A5=E8=AE=A9=E5=BC=B9=E5=87=BA=E6=A1=86?=
=?UTF-8?q?=E9=9A=90=E8=97=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/poll/_poll_form.html.erb | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/app/views/poll/_poll_form.html.erb b/app/views/poll/_poll_form.html.erb
index 0a15143fb..b081f4d18 100644
--- a/app/views/poll/_poll_form.html.erb
+++ b/app/views/poll/_poll_form.html.erb
@@ -2,11 +2,24 @@
-
diff --git a/public/javascripts/user.js b/public/javascripts/user.js
new file mode 100644
index 000000000..7c7189066
--- /dev/null
+++ b/public/javascripts/user.js
@@ -0,0 +1,238 @@
+$(function(){
+ if($(".top_new").length==0){
+ $("#RSide").css("min-height",$("#LSide").height()-30);
+ }
+ else{
+ $("#RSide").css("min-height",$("#LSide").height()-87);
+ }
+
+});
+
+//个人动态
+$(function(){
+
+ function init_editor(params){
+ var editor = params.kindutil.create(params.textarea, {
+ resizeType : 1,minWidth:"1px",width:"100%",height:"80px",
+ items:['emoticons'],
+ afterChange:function(){//按键事件
+ nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});
+ },
+ afterCreate:function(){
+ var toolbar = $("div[class='ke-toolbar']",params.div_form);
+ $(".ke-outline>.ke-toolbar-icon",toolbar).append('表情');
+ params.toolbar_container.append(toolbar);
+ }
+ }).loadPlugin('paste');
+ return editor;
+ }
+
+ function nh_check_field(params){
+ var result=true;
+ if(params.content!=undefined){
+ if(params.content.isEmpty()){
+ result=false;
+ }
+ if(params.content.html()!=params.textarea.html() || params.issubmit==true){
+ params.textarea.html(params.content.html());
+ params.content.sync();
+ if(params.content.isEmpty()){
+ params.contentmsg.html('内容不能为空');
+ params.contentmsg.css({color:'#ff0000'});
+ }else{
+ params.contentmsg.html('填写正确');
+ params.contentmsg.css({color:'#008000'});
+ }
+ params.contentmsg.show();
+ }
+ }
+ return result;
+ }
+ function init_form(params){
+ params.form.submit(function(){
+ var flag = false;
+ if(params.form.attr('data-remote') != undefined ){
+ flag = true
+ }
+ var is_checked = nh_check_field({
+ issubmit:true,
+ content:params.editor,
+ contentmsg:params.contentmsg,
+ textarea:params.textarea
+ });
+ if(is_checked){
+ if(flag){
+ return true;
+ }else{
+ $(this)[0].submit();
+ return false;
+ }
+ }
+ return false;
+ });
+ }
+ function nh_reset_form(params){
+ params.form[0].reset();
+ params.textarea.empty();
+ if(params.editor != undefined){
+ params.editor.html(params.textarea.html());
+ }
+ params.contentmsg.hide();
+ }
+
+ KindEditor.ready(function(K){
+ $("a[nhname='reply_btn']").live('click',function(){
+ var params = {};
+ params.kindutil = K;
+ params.container = $(this).parent('div');
+ params.div_form = $("div[nhname='div_form']",params.container);
+ params.form = $("form",params.div_form);
+ params.textarea = $("textarea[name='user_notes']",params.div_form);
+ params.contentmsg = $("p[nhname='contentmsg']",params.div_form);
+ params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form);
+ params.cancel_btn = $("a[nhname='cancel_btn']",params.div_form);
+ params.submit_btn = $("a[nhname='submit_btn']",params.div_form);
+ if(params.textarea.data('init') == undefined){
+ params.editor = init_editor(params);
+ init_form(params);
+ params.cancel_btn.click(function(){
+ nh_reset_form(params);
+ toggleAndSettingWordsVal(params.div_form, params.textarea);
+ });
+ params.submit_btn.click(function(){
+ params.form.submit();
+ });
+ params.textarea.data('init',1);
+ }
+ params.cancel_btn.click();
+ setTimeout(function(){
+ if(!params.div_form.is(':hidden')){
+ params.textarea.show();
+ params.textarea.focus();
+ params.textarea.hide();
+ }
+ },300);
+
+ });
+
+ $("div[nhname='new_message']").each(function(){
+ var params = {};
+ params.kindutil = K;
+ params.div_form = $(this);
+ params.form = $("form",params.div_form);
+ if(params.form==undefined || params.form.length==0){
+ return;
+ }
+ params.textarea = $("textarea[nhname='new_message_textarea']",params.div_form);
+ params.contentmsg = $("p[nhname='contentmsg']",params.div_form);
+ params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form);
+ params.cancel_btn = $("#new_message_cancel_btn");
+ params.submit_btn = $("#new_message_submit_btn");
+
+ if(params.textarea.data('init') == undefined){
+ params.editor = init_editor(params);
+ init_form(params);
+ params.cancel_btn.click(function(){
+ nh_reset_form(params);
+ });
+ params.submit_btn.click(function(){
+ params.form.submit();
+ });
+ params.textarea.data('init',1);
+ $(this).show();
+ }
+ });
+ });
+});
+function init_list_more_div(params){
+ var p=params;
+ p.exbtn.click(function(){
+ var isclose = p.container.data('isclose');
+ var hasmore = p.container.data('hasmore');
+ if(isclose == '1'){
+ $("div[nhname='rec']",p.container).show();
+ p.container.data('isclose','0');
+ change_status_4_list_more_div(params);
+ return;
+ }
+ if(hasmore == '0'){
+ change_status_4_list_more_div(params,'get');
+ return;
+ }
+ var url = p.container.data('url');
+ if($("div[nhname='rec']",p.container).length > 0){
+ var lastid = $("div[nhname='rec']",p.container).filter(':last').data('id');
+ url += "?lastid="+lastid;
+ var lasttime = $("div[nhname='rec']",p.container).filter(':last').data('time');
+ if(lasttime != undefined){
+ url += "&lasttime="+lasttime;
+ }
+ }
+ $.ajax( {url:url,dataType:'text',success:function(data){
+ var html = $("
"+data+"
");
+ var lens = $("div[nhname='rec']",html).length;
+ if(lens < p.size){
+ p.container.data('hasmore','0');
+ }
+ if(lens>0){
+ var currpage = parseInt(p.container.data('currpage'))+1;
+ p.container.data('currpage',currpage);
+ p.container.append(html.html())
+ }
+ change_status_4_list_more_div(params,'get');
+ p.div.show();
+ }} );
+ });
+ p.clbtn.click(function(){
+ var i=0;
+ $("div[nhname='rec']",p.container).each(function(){
+ i++;
+ if(i> p.size){
+ $(this).hide();
+ }
+ });
+ p.container.data('isclose','1');
+ change_status_4_list_more_div(params);
+ });
+ p.exbtn.click();
+}
+function change_status_4_list_more_div(params,opt){
+ var p=params;
+ if($("div[nhname='rec']",p.container).length == 0 && opt != 'get'){
+ p.exbtn.click();
+ return;
+ }
+ var show_lens = $("div[nhname='rec']",p.container).length - $("div[nhname='rec']",p.container).filter(':hidden').length;
+ if( show_lens > p.size ){
+ p.clbtn.show();
+ }else{
+ p.clbtn.hide();
+ }
+ if($("div[nhname='rec']",p.container).length == 0){
+ p.exbtn.html(p.nodatamsg);
+ }else if( p.container.data('hasmore') == '1' || p.container.data('isclose')=='1' ){
+ p.exbtn.html('点击展开更多');
+ }else{
+ p.exbtn.html('没有更多了');
+ }
+}
+function init_list_more_div_params(div){
+ var params = {};
+ params.div = div;
+ params.container = $("div[nhname='container']",div);
+ params.exbtn = $("a[nhname='expand']",div);
+ params.clbtn = $("a[nhname='close']",div);
+ params.size = params.container.data('pagesize');
+ params.nodatamsg = params.container.data('nodatamsg');
+ if( params.size == undefined ){
+ params.size = 13;
+ }
+ return params;
+}
+$(function(){
+ $("div[nhname='list_more_div']").each(function(){
+ var params = init_list_more_div_params($(this));
+ init_list_more_div(params)
+ });
+});
+//个人动态 end
\ No newline at end of file
diff --git a/public/stylesheets/users.css b/public/stylesheets/users.css
index 30e6594f5..7c3dad383 100644
--- a/public/stylesheets/users.css
+++ b/public/stylesheets/users.css
@@ -8,7 +8,7 @@
.icon_female{ background:url(../images/pic_uersall.png) 0 -24px no-repeat; width:15px; height:15px;}
.pf_intro{ width:222px; margin-top:5px; color:#696969;word-break: break-all; }
.leftbox{ width:230px; padding:10px; padding-right:0px; padding-bottom:5px;background:#fff; margin-bottom:10px; margin-right:10px;}
-.pic_members{ background:url(../images/pic_users.jpg) 0 0 no-repeat; display:block; width:38px; height:38px; border:1px solid #e9edf0; margin-right:5px; margin-bottom:5px;float:left;}
+.pic_members{ display:block; width:38px; height:38px; border:1px solid #e9edf0; margin-right:5px; margin-bottom:5px;float:left;}
.pic_members:hover{border:1px solid #c9c9c9;}
/*新建*/
.top_new{ height:26px; border-bottom:10px solid #eaebed; padding:10px; background:#fff; float:left; margin-left:10px; width:730px; }
@@ -89,7 +89,7 @@ a.select_btn_select{ background:#64bddb; color:#fff;}
.users_ctt input,.users_ctt select,.users_ctt textarea{ border:1px solid #CCC;}
.users_ctt input,.users_ctt select,.users_ctt option{ height:26px;}
.users_ctt input,.users_ctt textarea{ margin-left:2px;}
-.users_ctt textarea{ margin-bottom:none;}
+/*.users_ctt textarea{ margin-bottom:nor;}*/
.w450{ width:450px;}
.w210{ width:200px;}
.w70{ width:70px;}
@@ -124,4 +124,12 @@ a:hover.c_lgrey{ color:#3ca5c6;}
.newhwork_div textarea{border:1px solid #CCC;}
.w460{ width:460px;}
-a.hidepic>img{display:none;}
\ No newline at end of file
+a.hidepic>img{display:none;}
+
+div.ke-toolbar{display:none;width:400px;border:none;background:none;padding:0px 0px;}
+span.ke-toolbar-icon{line-height:26px;font-size:14px;padding-left:26px;}
+span.ke-toolbar-icon-url{background-image:url( ../images/public_icon.png )}
+div.ke-toolbar .ke-outline{padding:0px 0px;line-height:26px;font-size:14px;}
+span.ke-icon-emoticons{background-position:0px -671px;width:50px;height:26px;}
+span.ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;}
+div.ke-toolbar .ke-outline{border:none;}
\ No newline at end of file
From a0a5f3410847752d2c28c535a801976558046546 Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Wed, 29 Jul 2015 10:07:00 +0800
Subject: [PATCH 17/39] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E4=BB=A5=E5=89=8D?=
=?UTF-8?q?=E7=9A=84=E9=97=AE=E5=8D=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/poll_controller.rb | 31 +++++++++++++++++++++
app/views/poll/_poll_form.html.erb | 43 +++++++++++++++++++++++++++++-
app/views/poll/_show_head.html.erb | 3 +++
3 files changed, 76 insertions(+), 1 deletion(-)
diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb
index 8f81bc2c6..dda5b81b2 100644
--- a/app/controllers/poll_controller.rb
+++ b/app/controllers/poll_controller.rb
@@ -336,6 +336,37 @@ class PollController < ApplicationController
end
end
+
+ def import_poll
+ @poll = Poll.find(params[:to_id])
+ question_num = @poll.poll_questions.select("max(question_number) question_number").first.question_number
+ import_poll = Poll.find(params[:import_id])
+ import_poll.poll_questions.each_with_index do |question,index|
+ option = {
+ :is_necessary => question.is_necessary,
+ :question_title => question.question_title,
+ :question_type => question.question_type,
+ :question_number => question_num + index+1
+ }
+ poll_questions = @poll.poll_questions.new option
+ for i in 1..question.poll_answers.count
+ answer = question.poll_answers[i-1][:answer_text]
+ question_option = {
+ :answer_position => i,
+ :answer_text => answer
+ }
+ poll_questions.poll_answers.new question_option
+ end
+ @poll.poll_questions << poll_questions
+ end
+ if @poll.save
+ @poll = Poll.find(params[:to_id])
+ respond_to do |format|
+ format.js
+ end
+ end
+ end
+
#重新发布问卷
def republish_poll
@poll.poll_questions.each do |poll_question|
diff --git a/app/views/poll/_poll_form.html.erb b/app/views/poll/_poll_form.html.erb
index d784edab3..c5c016583 100644
--- a/app/views/poll/_poll_form.html.erb
+++ b/app/views/poll/_poll_form.html.erb
@@ -3,6 +3,7 @@
+