From d43ded4f8bcdcb66abb52254e21559a56106ef6c Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 11 Aug 2015 11:30:17 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1.=E6=B2=A1=E6=9C=89=E5=8F=AF=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E7=9A=84=E9=97=AE=E5=8D=B7=E6=8F=90=E7=A4=BA=202.?= =?UTF-8?q?=E6=95=99=E8=BE=85=E4=B9=9F=E5=8F=AF=E4=BB=A5=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E8=80=81=E5=B8=88=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/files_controller.rb | 10 +++++----- app/controllers/poll_controller.rb | 9 ++++++--- app/helpers/poll_helper.rb | 2 +- app/views/poll/_other_poll.html.erb | 4 ++-- app/views/poll/other_poll.js.erb | 16 ++++++++++------ 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 19c1214e2..7b81d12db 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -177,11 +177,11 @@ class FilesController < ApplicationController def index @flag = params[:flag] || false #sort_init 'filename', 'asc' - sort_init 'created_on', 'desc' - sort_update 'created_on' => "#{Attachment.table_name}.created_on", - 'filename' => "#{Attachment.table_name}.filename", - 'size' => "#{Attachment.table_name}.filesize", - 'downloads' => "#{Attachment.table_name}.downloads" + # sort_init 'created_on', 'desc' + # sort_update 'created_on' => "#{Attachment.table_name}.created_on", + # 'filename' => "#{Attachment.table_name}.filename", + # 'size' => "#{Attachment.table_name}.filesize", + # 'downloads' => "#{Attachment.table_name}.downloads" sort = "" @sort = "" @order = "" diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index b376a9acd..edf8c2259 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -1,3 +1,4 @@ +#encoding utf-8 class PollController < ApplicationController before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result,:create_poll_question,:commit_poll,:commit_answer,:publish_poll,:republish_poll,:poll_result,:close_poll,:export_poll] before_filter :find_container, :only => [:new,:create, :index] @@ -412,8 +413,10 @@ class PollController < ApplicationController # 将其他地方的问卷导出来 def other_poll - # 查作者是我,且不在当前课程内的问卷 进行导入 - @polls = Poll.where("user_id = #{User.current.id} and polls_type = 'course' and polls_group_id != #{params[:polls_group_id]}") + # 查作者是我,或者作者是当前课程的老师,且不在当前课程内的问卷 进行导入 + tea_ids = '(' + tea_ids << Course.find(params[:polls_group_id]).tea_id.to_s << ','<< User.current.id.to_s << ')' + @polls = Poll.where("user_id in #{tea_ids} and polls_type = 'course' and polls_group_id != #{params[:polls_group_id]}") @polls_group_id = params[:polls_group_id] respond_to do |format| format.js @@ -427,7 +430,7 @@ class PollController < ApplicationController params[:polls].each_with_index do |p,i| poll = Poll.find(p) option = { - :polls_name => poll.polls_name, + :polls_name => poll.polls_name || l(:label_poll_new), :polls_type => 'Course', :polls_group_id => course_id, :polls_status => 1, diff --git a/app/helpers/poll_helper.rb b/app/helpers/poll_helper.rb index 0baad37ee..22ee21936 100644 --- a/app/helpers/poll_helper.rb +++ b/app/helpers/poll_helper.rb @@ -78,7 +78,7 @@ module PollHelper def poll_check_box_tags(name,polls,current_poll) s = '' polls.each do |poll| - s << "
" + s << "
" end s.html_safe end diff --git a/app/views/poll/_other_poll.html.erb b/app/views/poll/_other_poll.html.erb index c899f0d47..850d821fd 100644 --- a/app/views/poll/_other_poll.html.erb +++ b/app/views/poll/_other_poll.html.erb @@ -1,6 +1,6 @@
-

将以下问卷导入本课程

+

选择问卷导入本课程

<%= form_tag import_other_poll_poll_index_path, @@ -8,7 +8,7 @@ remote: true, id: "relation_file_form" do %> - <%= content_tag('div', poll_check_box_tags('polls[]', polls,polls_group_id), :id => 'courses')%> + <%= content_tag('div', poll_check_box_tags('polls[]', polls,polls_group_id), :id => 'courses',:style=> 'width: 300px;')%> 导  入 取  消 <% end -%> diff --git a/app/views/poll/other_poll.js.erb b/app/views/poll/other_poll.js.erb index 34f53b73e..eee4ed4a1 100644 --- a/app/views/poll/other_poll.js.erb +++ b/app/views/poll/other_poll.js.erb @@ -1,9 +1,13 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'other_poll',:locals => {:polls => @polls,:polls_group_id=>@polls_group_id}) %>'); +<% if @polls.empty? %> + alert('您目前还没有自己新建的问卷'); +<% else %> + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'other_poll',:locals => {:polls => @polls,:polls_group_id=>@polls_group_id}) %>'); -showModal('ajax-modal', '513px'); -$('#ajax-modal').siblings().remove(); -$('#ajax-modal').before(""); -$('#ajax-modal').parent().css("top","").css("left",""); -$('#ajax-modal').parent().addClass("popbox_polls"); \ No newline at end of file + showModal('ajax-modal', '513px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').before(""); + $('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().addClass("popbox_polls"); +<% end %> \ No newline at end of file From 477db5841bd1678bcab255857daec1a54bc1047e Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 11 Aug 2015 14:32:01 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B2=A1=E6=9C=89=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E9=97=AE=E5=8D=B7=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/poll/_other_poll.html.erb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/views/poll/_other_poll.html.erb b/app/views/poll/_other_poll.html.erb index 850d821fd..40ecbc569 100644 --- a/app/views/poll/_other_poll.html.erb +++ b/app/views/poll/_other_poll.html.erb @@ -19,9 +19,19 @@
\ No newline at end of file