diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index e89f621c8..518cc01c4 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -836,7 +836,7 @@ class CoursesController < ApplicationController sql_select = "" if groupid == 0 sql_select = "SELECT members.*,( - SELECT SUM(student_works.final_score) + SELECT AVG(student_works.final_score) FROM student_works,homework_commons WHERE student_works.homework_common_id = homework_commons.id AND homework_commons.course_id = #{@course.id} @@ -848,7 +848,7 @@ class CoursesController < ApplicationController WHERE members.course_id = #{@course.id} ORDER BY score #{score_sort_by}" else sql_select = "SELECT members.*,( - SELECT SUM(student_works.final_score) + SELECT AVG(student_works.final_score) FROM student_works,homework_commons WHERE student_works.homework_common_id = homework_commons.id AND homework_commons.course_id = #{@course.id} 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/models/member.rb b/app/models/member.rb index 2936392ab..5b1e277d7 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -116,21 +116,23 @@ class Member < ActiveRecord::Base # 查找每个学生每个作业的评分 def student_homework_score - score_count = 0 homework_score = StudentWork.find_by_sql("SELECT homework_commons.name,student_works.final_score as score FROM student_works,homework_commons WHERE student_works.homework_common_id = homework_commons.id AND homework_commons.course_id = #{self.course_id} AND student_works.user_id = #{self.user_id}") - homework_score.each do |homework| - mem_score = 0 - if homework[:score] - mem_score = homework[:score] - end - score_count = score_count + mem_score - end + score_count = StudentWork.joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}").average(:final_score).try(:round, 2).to_f [homework_score, format("%0.2f", score_count)] end + + def student_work_score + StudentWork.select("homework_commons.name, student_works.final_score").joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}") + end + + def student_work_score_avg + StudentWork.joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}").average(:final_score).try(:round, 2).to_f + end + protected def validate_role diff --git a/app/views/attachments/_course_file_links.html.erb b/app/views/attachments/_course_file_links.html.erb index d32025787..e651c0a93 100644 --- a/app/views/attachments/_course_file_links.html.erb +++ b/app/views/attachments/_course_file_links.html.erb @@ -53,7 +53,7 @@ <% end %> <% if options[:author] %> - <%= link_to h(truncate(attachment.author.name, length: 10, omission: '...')),user_path(attachment.author) %>, + <%= link_to h(truncate(attachment.author.name, length: 10, omission: '...')),user_path(attachment.author),:class => "author_name" %>, <%= format_time(attachment.created_on) %> <% end %> diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb index 2a280fe03..d7a02e326 100644 --- a/app/views/boards/show.html.erb +++ b/app/views/boards/show.html.erb @@ -104,8 +104,8 @@ function nh_check_field(params){ result=false; } if(params.content.html()!=params.textarea.html() || params.issubmit==true){ -// params.textarea.html(params.content.html()); //用这个ie11提交到服务器居然木有值 真特么旧梦已尘风 - params.content.sync(); //但是这个貌似编辑器没内容时不会同步到textarea中 新愁不言中... + params.textarea.html(params.content.html()); + params.content.sync(); //用上面那句ie11提交到服务器居然木有值 if(params.content.isEmpty()){ params.contentmsg.html('内容不能为空'); params.contentmsg.css({color:'#ff0000'}); diff --git a/app/views/courses/_courses_jours.html.erb b/app/views/courses/_courses_jours.html.erb index adbbf4780..07d065901 100644 --- a/app/views/courses/_courses_jours.html.erb +++ b/app/views/courses/_courses_jours.html.erb @@ -1,25 +1,41 @@ + <%= javascript_include_tag "/assets/kindeditor/kindeditor" %> -
+
<%# reply_allow = JournalsForMessage.create_by_user? User.current %>

<%= l(:label_leave_message) %>

<% if !User.current.logged?%> -
- <%= l(:label_user_login_tips) %> - <%= link_to l(:label_user_login_new), signin_path %> -
-
+
+ <%= l(:label_user_login_tips) %> + <%= link_to l(:label_user_login_new), signin_path %> +
+
<% else %> - <%= form_for('new_form', :method => :post, - :url => {:controller => 'words', :action => 'leave_course_message'},:html => {:id=>'leave_message_form'}) do |f|%> - <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> - <%= f.kindeditor 'course_message',:height => '140px;',:editor_id => 'leave_message_editor',:input_html=>{:id => "leave_meassge",:style => "resize: none;", + <%= form_for('new_form', :method => :post, + :url => {:controller => 'words', :action => 'leave_course_message'},:html => {:id=>'leave_message_form'}) do |f|%> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + <%#= f.kindeditor 'course_message',:height => '140px;',:editor_id => 'leave_message_editor',:input_html=>{:id => "leave_meassge",:style => "resize: none;", :placeholder => "#{l(:label_welcome_my_respond)}",:maxlength => 250}%> - 取  消 - - <%= l(:button_leave_meassge)%> - - <% end %> + +

+
+ 取  消 + + <%= l(:button_leave_meassge)%> + + <% end %> <% end %>
@@ -28,4 +44,157 @@
\ No newline at end of file + +
+ + \ 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/courses/_set_course_time.html.erb b/app/views/courses/_set_course_time.html.erb index 0c28b90a7..27c6c0c99 100644 --- a/app/views/courses/_set_course_time.html.erb +++ b/app/views/courses/_set_course_time.html.erb @@ -1,6 +1,6 @@ <% id = "finish_course_#{course.id}" - display = (course.teacher.id == User.current.id || User.current.admin?) + display = (User.current.allowed_to?(:as_teacher,course) || User.current.admin?) %> <% if display #如果课程已结束%> diff --git a/app/views/courses/_show_member_score.html.erb b/app/views/courses/_show_member_score.html.erb index 0d250cf14..0fd1248c6 100644 --- a/app/views/courses/_show_member_score.html.erb +++ b/app/views/courses/_show_member_score.html.erb @@ -17,17 +17,17 @@

<%= @member_score.user.name %> 历次作业积分

diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb index 1e8189ddb..3208bb969 100644 --- a/app/views/homework_common/index.html.erb +++ b/app/views/homework_common/index.html.erb @@ -41,9 +41,9 @@ <%= homework.description.html_safe %> - -
diff --git a/app/views/poll/_poll.html.erb b/app/views/poll/_poll.html.erb index 3c4426696..180fed0f0 100644 --- a/app/views/poll/_poll.html.erb +++ b/app/views/poll/_poll.html.erb @@ -37,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/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("" + ""); 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 diff --git a/config/locales/commons/zh.yml b/config/locales/commons/zh.yml index a023bc8cb..f83d3810c 100644 --- a/config/locales/commons/zh.yml +++ b/config/locales/commons/zh.yml @@ -219,7 +219,7 @@ zh: label_submit: 提交 button_project_tags_add: 增加 button_download: 下载 - button_more: "更多»" + button_more: "更多" button_delete: 删除 button_unfollow: 取消关注 button_follow: 关注 diff --git a/config/locales/zh.yml b/config/locales/zh.yml index fc0a0e6c6..b327b1d5f 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1939,6 +1939,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' 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; diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 4c0cae670..8f87767ed 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -353,10 +353,26 @@ function show_more_msg() function news_show_more_des(id) { $('#news_description_' + id).toggleClass("news_description_none"); + if($("#news_description_" + id).hasClass("news_description_none")) + { + $("#news_foot_" + id).html("[收起]"); + } + else + { + $("#news_foot_" + id).html("[展开]"); + } } function bid_show_more_des(id) { $("#bid_description_" + id).toggleClass("news_description_none"); + if($("#bid_description_" + id).hasClass("news_description_none")) + { + $("#bid_show_more_des_button" + id).html("[收起]"); + } + else + { + $("#bid_show_more_des_button" + id).html("[展开]"); + } } //课程作业结束时间倒计时 diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index edb70075b..e577bde66 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -30,10 +30,6 @@ a:hover.news_foot{ color:#787b7e; border:1px solid #d4d4d4;} .box_h3{ color:#15bccf; text-align:center; font-size:16px;} .box_p{ color:#404040; margin-bottom:5px;} .fb_item{ color:#919191; border:1px solid #919191; height:28px; margin-bottom:10px; padding-left:5px; width:290px;} -/*.icon_addm{ background:url(../images/img_floatbox.png) 0 -33px no-repeat; width:16px; height:16px; display:block; margin:5px 0 0 5px;}*/ -/*.icon_addm:hover{background:url(../images/img_floatbox.png) 0 -61px no-repeat; }*/ -/*.icon_removem{ background:url(../images/img_floatbox.png) -22px -33px no-repeat;width:16px; height:16px; display:block; margin:5px 0 0 5px}*/ -/*.icon_removem:hover{background:url(../images/img_floatbox.png) -22px -61px no-repeat;}*/ a.btn_free{ background:#ff5722; display:block; width:80px; text-align:center; color:#fff; height:26px; padding-top:3px; margin-bottom:10px;} a:hover.btn_free{ background:#d63502;} /*成员邀请*/ 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;} diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 59431b3ad..4bfc1ef99 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -439,3 +439,4 @@ a.box_close{background:url(../images/img_floatbox.png) -22px 0 no-repeat;} img{max-width: 100%;} .attachments {clear: both;} .is_public_checkbox{margin-left: 15px;margin-right: 10px;} +.author_name{color: #3ca5c6 !important;}