From 857d3d5f623eb918b3ab6b15078c1b1f7f08b7a4 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 9 Jun 2015 17:03:28 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E8=B0=83=E6=9F=A5?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E5=AF=BC=E5=87=BA=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 | 52 ++++++++++++++++++++++++++++-- app/views/poll/_poll.html.erb | 2 ++ config/locales/zh.yml | 1 + config/routes.rb | 1 + 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 32ec3dad2..73650a782 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -1,8 +1,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] + 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] before_filter :is_member_of_course, :only => [:index,:show,:poll_result] - before_filter :is_course_teacher, :only => [:new,:create,:edit,:update,:destroy,:publish_poll,:republish_poll,:close_poll] + before_filter :is_course_teacher, :only => [:new,:create,:edit,:update,:destroy,:publish_poll,:republish_poll,:close_poll,:export_poll] include PollHelper def index if @course @@ -360,6 +360,17 @@ class PollController < ApplicationController end end + #导出问卷 + def export_poll + poll_questions = @poll.poll_questions + respond_to do |format| + format.xls { + send_data(poll_to_xls(poll_questions), :type => "text/excel;charset=utf-8; header=present", + :filename => "#{@poll.polls_name}.xls") + } + end + end + private def find_poll_and_course @poll = Poll.find params[:id] @@ -438,4 +449,41 @@ class PollController < ApplicationController end pu end + + #将poll中题目转换为Excel + def poll_to_xls poll_questions + xls_report = StringIO.new + book = Spreadsheet::Workbook.new + sheet1 = book.create_worksheet :name => "poll" + blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 + count_row = 0 + poll_questions.each do |poll_question| + if poll_question.question_type == 1 || poll_question.question_type == 2 + sheet1.row(count_row).default_format = blue + sheet1[count_row,0]= l(:label_poll_question_num,:num => poll_question.question_number) + sheet1[count_row + 1,0] = l(:label_poll_subtotal) + sheet1[count_row + 2,0] = l(:label_poll_proportion) + poll_question.poll_answers.each_with_index do |poll_answer,i| + sheet1[count_row, i + 1] = poll_answer.answer_text + sheet1[count_row + 1, i + 1] = poll_answer.poll_votes.count + sheet1[count_row + 2, i + 1] = statistics_result_percentage(poll_answer.poll_votes.count, total_answer(poll_question.id)).to_s + "%" + end + sheet1[count_row + 3,0] = l(:label_poll_valid_commit) + sheet1[count_row + 3,1] = total_answer(poll_question.id) + count_row += 5 + else + sheet1.row(count_row).default_format = blue + sheet1[count_row,0] = l(:label_poll_question_num,:num => poll_question.question_number) + sheet1[count_row,1] = poll_question.question_title + count_row += 1 + poll_question.poll_votes.each do |poll_vote| + sheet1[count_row,0] = poll_vote.vote_text + count_row += 1 + end + count_row += 1 + end + end + book.write xls_report + xls_report.string + end end \ No newline at end of file diff --git a/app/views/poll/_poll.html.erb b/app/views/poll/_poll.html.erb index 3c4426696..14f351182 100644 --- a/app/views/poll/_poll.html.erb +++ b/app/views/poll/_poll.html.erb @@ -25,6 +25,8 @@ <%= link_to(l(:button_delete), poll,:method => :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml5 mr10") %> +
  • <%= link_to "导出", export_poll_poll_path(poll.id,:format => "xls"), :class => "polls_de fr ml5"%>
  • + <% if poll.polls_status == 1 %>
  • <%= link_to l(:button_edit), edit_poll_path(poll.id), :class => "polls_de fr ml5"%>
  • <% else%> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 7653a0c4e..8434843d6 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1936,6 +1936,7 @@ zh: label_poll_description: 问卷描述 label_poll_options: 选项 label_poll_subtotal: 小计 + label_poll_question_num: "第%{num}题" label_poll_proportion: 比例 label_poll_valid_commit: 本题有效填写人次 label_poll_result: 问卷调查_问卷统计 diff --git a/config/routes.rb b/config/routes.rb index d2c21f6ea..c92c732d2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -70,6 +70,7 @@ RedmineApp::Application.routes.draw do get 'republish_poll' get 'poll_result' get 'close_poll' + get 'export_poll' end collection do delete 'delete_poll_question' From 4c5d2d50559d05df48abac44e6bad426497c8482 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 9 Jun 2015 17:08:00 +0800 Subject: [PATCH 02/12] =?UTF-8?q?poll=E5=88=97=E8=A1=A8=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4=EF=BC=8C=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/poll/_poll.html.erb | 9 +++++++-- public/stylesheets/polls.css | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/views/poll/_poll.html.erb b/app/views/poll/_poll.html.erb index 14f351182..180fed0f0 100644 --- a/app/views/poll/_poll.html.erb +++ b/app/views/poll/_poll.html.erb @@ -25,8 +25,6 @@ <%= link_to(l(:button_delete), poll,:method => :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml5 mr10") %> -
  • <%= link_to "导出", export_poll_poll_path(poll.id,:format => "xls"), :class => "polls_de fr ml5"%>
  • - <% if poll.polls_status == 1 %>
  • <%= link_to l(:button_edit), edit_poll_path(poll.id), :class => "polls_de fr ml5"%>
  • <% else%> @@ -39,6 +37,13 @@
  • 关闭
  • <% end%> + <% if poll.polls_status == 1%> +
  • 导出
  • + <% elsif poll.polls_status == 2 || poll.polls_status == 3 %> +
  • <%= link_to "导出", export_poll_poll_path(poll.id,:format => "xls"), :class => "polls_de fr ml5"%>
  • + <% end%> + +
  • <%= format_date poll.created_at.to_date%>
  • <% else%> <% if poll.polls_status == 2%> diff --git a/public/stylesheets/polls.css b/public/stylesheets/polls.css index f1b5023bd..353ec3937 100644 --- a/public/stylesheets/polls.css +++ b/public/stylesheets/polls.css @@ -127,7 +127,7 @@ a:hover.btn_de{ background:#ff5d31;} a.btn_pu{ border:1px solid #3cb761; color:#3cb761; } a:hover.btn_pu{ background:#3cb761;} .pollsbtn_grey{ border:1px solid #b1b1b1; color:#b1b1b1; padding:0px 9px; height:19px; padding-top:3px; } -.polls_title_w { width:330px; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;} +.polls_title_w { width:300px; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;} .polls_title_st { max-width:530px; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;} .polls_de_grey{ color:#b1b1b1; margin-top:3px;} .ml5{ margin-left:5px;} From f3dd7c11b6bb44865ff3fee6fd37e2aced0d8bb0 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 9 Jun 2015 17:11:54 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E9=97=AE=E5=8D=B7?= =?UTF-8?q?=E7=AD=94=E6=A1=88=E6=97=B6=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/poll/commit_poll.js.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/poll/commit_poll.js.erb b/app/views/poll/commit_poll.js.erb index 8f68dae68..76e5e53df 100644 --- a/app/views/poll/commit_poll.js.erb +++ b/app/views/poll/commit_poll.js.erb @@ -1,6 +1,6 @@ $('#ajax-modal').html('<%= escape_javascript(render :partial => 'commit_alert',:locals => {:status => @status}) %>'); -showModal('ajax-modal', '250px'); -$('#ajax-modal').css('height','100px'); +showModal('ajax-modal', '270px'); +$('#ajax-modal').css('height','110px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before("" + ""); From 1c808464d58fb79e438649b0a5542f1cae08d8a5 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 10 Jun 2015 16:12:19 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E6=96=B0=E7=89=88=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E4=B8=8D=E5=8F=AF=E4=BB=A5=E6=8B=89=E5=AE=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vendor/assets/javascripts/kindeditor/kindeditor.js | 3 +-- public/assets/kindeditor/kindeditor.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/rails_kindeditor/vendor/assets/javascripts/kindeditor/kindeditor.js b/lib/rails_kindeditor/vendor/assets/javascripts/kindeditor/kindeditor.js index e58e4b2be..fe27e92c2 100644 --- a/lib/rails_kindeditor/vendor/assets/javascripts/kindeditor/kindeditor.js +++ b/lib/rails_kindeditor/vendor/assets/javascripts/kindeditor/kindeditor.js @@ -5054,8 +5054,7 @@ KEditor.prototype = { } }); statusbar.removeClass('statusbar').addClass('ke-statusbar') - .append('') - .append(''); + .append(''); if (self._fullscreenResizeHandler) { K(window).unbind('resize', self._fullscreenResizeHandler); self._fullscreenResizeHandler = null; diff --git a/public/assets/kindeditor/kindeditor.js b/public/assets/kindeditor/kindeditor.js index b019bccf1..74228d3ea 100644 --- a/public/assets/kindeditor/kindeditor.js +++ b/public/assets/kindeditor/kindeditor.js @@ -5102,8 +5102,7 @@ KEditor.prototype = { } }); statusbar.removeClass('statusbar').addClass('ke-statusbar') - .append('') - .append(''); + .append(''); if (self._fullscreenResizeHandler) { K(window).unbind('resize', self._fullscreenResizeHandler); self._fullscreenResizeHandler = null; From ff159075aa743a7beeafa899cfa81cab6ae79c28 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 10 Jun 2015 16:16:23 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E6=96=B0header=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=9C=A8=E9=A1=B9=E7=9B=AE=E4=B8=8A=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_new_header.html.erb | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/views/layouts/_new_header.html.erb b/app/views/layouts/_new_header.html.erb index 46a2eff63..f26317acd 100644 --- a/app/views/layouts/_new_header.html.erb +++ b/app/views/layouts/_new_header.html.erb @@ -20,19 +20,6 @@
  • <%= link_to "#{User.current.login}".html_safe, {:controller=> 'users', :action => 'show', id: User.current.id, host: Setting.host_user}, target:"_blank", :class => "uses_name"%> +
    + + \ No newline at end of file diff --git a/app/views/courses/_history.html.erb b/app/views/courses/_history.html.erb index e7c5a7c5e..3dc9aeba5 100644 --- a/app/views/courses/_history.html.erb +++ b/app/views/courses/_history.html.erb @@ -30,8 +30,7 @@ <% end %> <% if reply_allow %> <%= link_to l(:label_bid_respond_quote),'', - {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea')); $('##{ids} textarea') ;return false;"} %> - + {:focus => 'project_respond',:nhname=>"reply_btn", :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea')); $('##{ids} textarea') ;return false;"} %> <% end %>
    diff --git a/app/views/words/_journal_reply_items.html.erb b/app/views/words/_journal_reply_items.html.erb index d52f7cfe1..9d4eebd6f 100644 --- a/app/views/words/_journal_reply_items.html.erb +++ b/app/views/words/_journal_reply_items.html.erb @@ -34,7 +34,7 @@ <% end %> <% if reply_allow %> <%= link_to l(:button_reply),'', - {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{id}'), $('##{id} textarea'), ''); return false;"} %> + {:focus => 'project_respond',:nhname=>"reply_btn", :onclick => "toggleAndSettingWordsVal($('##{id}'), $('##{id} textarea'), ''); return false;"} %> <% end %>
    diff --git a/app/views/words/_new_respond_course.html.erb b/app/views/words/_new_respond_course.html.erb index e705b7fd3..5b27fd21f 100644 --- a/app/views/words/_new_respond_course.html.erb +++ b/app/views/words/_new_respond_course.html.erb @@ -4,12 +4,14 @@ :placeholder => l(:label_feedback_respond_content), :maxlength => 250 %> +

    <%= hidden_field_tag 'reference_id', params[:reference_id], :value => journal.id %> <%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => m_reply_id.user.id %> <%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => m_reply_id.id %> <%= hidden_field_tag 'show_name',params[:show_name],:value => show_name.nil? ? true : show_name %> +
    <%= submit_tag l(:button_feedback_respond), :name => nil , :class => "reply_btn"%> - + <% end %> \ No newline at end of file