diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index b1cca68ed..c98df27d3 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -490,7 +490,7 @@ class BidsController < ApplicationController (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score, (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY s_score DESC,created_at ASC) AS table1 - WHERE table1.t_score IS NULL OR table1.t_score = 0") + WHERE table1.t_score IS NULL") @not_batch_homework = true @cur_type = 1 else diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 523e430fb..f6b044c63 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -51,7 +51,7 @@ class HomeworkAttachController < ApplicationController order_by = "created_at #{direction}" end all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM (SELECT homework_attaches.*, - (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL AND stars > 0 ORDER BY updated_at DESC limit 0,1) AS t_score, + (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score, (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY #{order_by}) AS table1 @@ -503,7 +503,7 @@ class HomeworkAttachController < ApplicationController get_not_batch_homework_list params[:cur_sort] || "s_socre",params[:cur_direction] || "desc",@homework.bid_id elsif @cur_type == "2" #老师已批列表 @result_homework = HomeworkAttach.find_by_sql("SELECT homework_attaches.*, - (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL AND stars > 0 ORDER BY updated_at DESC limit 0,1) AS t_score, + (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score, (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score FROM homework_attaches WHERE id = #{@homework.id}").first elsif @cur_type == "3" #全部作业列表 @@ -630,7 +630,7 @@ class HomeworkAttachController < ApplicationController (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score FROM homework_attaches WHERE bid_id = #{bid_id} ORDER BY #{order_by}) AS table1 - WHERE table1.t_score IS NULL OR table1.t_score = 0 ") + WHERE table1.t_score IS NULL ") @all_homework_list = search_homework_member(@all_homework_list,@search_name.to_s.downcase) if @search_name # @homework_list = paginateHelper @all_homework_list,10 @homework_list = @all_homework_list diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 436418430..bab5dfb4c 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -93,7 +93,15 @@ class MessagesController < ApplicationController end call_hook(:controller_messages_new_after_save, { :params => params, :message => @message}) render_attachment_warning_if_needed(@message) - redirect_to board_message_url(@board, @message) + if params[:is_board] + if @project + redirect_to project_boards_path(@project) + elsif @course + redirect_to course_boards_path(@course) + end + else + redirect_to board_message_url(@board, @message) + end else layout_file = @project ? 'base_projects' : 'base_courses' render :action => 'new', :layout => layout_file @@ -131,9 +139,16 @@ class MessagesController < ApplicationController render_attachment_warning_if_needed(@reply) else #render file: 'messages#show', layout: 'base_courses' + end + if params[:is_board] + if @project + redirect_to project_boards_path(@project) + elsif @course + redirect_to course_boards_path(@course) + end + else + redirect_to board_message_url(@board, @topic, :r => @reply) end - redirect_to board_message_url(@board, @topic, :r => @reply) - end # Edit a message @@ -172,16 +187,20 @@ class MessagesController < ApplicationController @message.destroy # modify by nwb if @project - if @message.parent - redirect_to board_message_url(@board, @message.parent, :r => r) - else + if params[:is_board] redirect_to project_boards_url(@project) + else + redirect_to board_message_url(@board, @topic, :r => @reply) end elsif @course - if @message.parent - redirect_to board_message_url(@board, @message.parent, :r => r) + if params[:is_board] + redirect_to course_boards_url(@course) else - redirect_to course_board_url(@course, @board) + if @message.parent + redirect_to board_message_url(@board, @message.parent, :r => r) + else + redirect_to course_board_url(@course, @board) + end end end end diff --git a/app/views/bids/_homework.html.erb b/app/views/bids/_homework.html.erb index 0cb1ff7cc..c3a6cc9d0 100644 --- a/app/views/bids/_homework.html.erb +++ b/app/views/bids/_homework.html.erb @@ -59,6 +59,55 @@ } ); } + +// $(window).scroll(function(){ +// //获取窗口的滚动条的垂直位置 +// var s = $(window).scrollTop(); +// //当窗口的滚动条的垂直位置大于页面的最小高度时,让返回顶部元素渐现,否则渐隐 +// if( s > 600){ +// $("#gotoTop").fadeIn(100); +// }else{ +// $("#gotoTop").fadeOut(200); +// }; +// }); + $(function(){goTopEx();}); + + var Sys = {}; + var ua = navigator.userAgent.toLowerCase(); + var s; + (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] : + (s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] : + (s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] : + (s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] : + (s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0; + + function goTopEx() { + var obj = document.getElementById("goTopBtn"); + var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0; + function getScrollTop() { + var xsun = document.documentElement.scrollTop; + if (Sys.chrome) { + xsun=document.body.scrollTop; + } + return xsun; + } + function setScrollTop(value) { + if (Sys.chrome) { + document.body.scrollTop = value; + } + else { + document.documentElement.scrollTop = value; + } + } + window.onscroll = function () { getScrollTop() > 0 ? obj.style.display = "" : obj.style.display = "none"; }; + obj.onclick = function () { + var goTop = setInterval(scrollMove, 10); + function scrollMove() { + setScrollTop(getScrollTop() / 1.1); + if (getScrollTop() < 1) clearInterval(goTop); + } + } + }
diff --git a/app/views/boards/_course_new.html.erb b/app/views/boards/_course_new.html.erb new file mode 100644 index 000000000..94ba51529 --- /dev/null +++ b/app/views/boards/_course_new.html.erb @@ -0,0 +1,9 @@ +<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message-form'} do |f| %> + + <%= render :partial => 'form_course', :locals => {:f => f} %> +
  • + <%= link_to l(:button_cancel), course_boards_path(@course), :class => 'grey_btn fr ml10' %> + <%= l(:button_submit)%> +
    +
  • +<% end %> diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index ed2c20448..8f2cddc48 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -1,28 +1,26 @@ - +
    -

    <%= l(:label_board_plural) %>

    -
    +

    + <% if User.current.language == "zh"%> + <%= h @board.name %> + <% else %> + <%= l(:project_module_boards) %> + <% end %> +

    + <%= l(:label_message_new) %> +
    +
    + +
    +
    +
    + +
    <% if !User.current.logged?%>
    @@ -31,38 +29,125 @@
    <% end %> -
    -

    - <%= l(:label_totle) %> - <%= @topic_count %> - <%= l(:label_course_momes_count) %> -

    - <%= link_to l(:label_message_new), - new_board_message_path(@board), - :class => 'problem_new_btn fl c_dorange' if User.current.logged? %> -
    -
    + <% if @topics.any? %> <% @topics.each do |topic| %> -
    - <%= link_to image_tag(url_to_avatar(topic.author), :width=>"32",:height=>"32"), user_path(topic.author),:class => 'problem_pic talk_pic fl' %> -
    - <%= link_to h(topic.subject.truncate(40,ommision:'...')), board_message_path(@board, topic),title: topic.subject.to_s,:class => "problem_tit fl fb c_dblue" %> - <% if topic.sticky? %> - 置顶 - <% end %> -
    -

    由<%= link_to topic.author,user_path(topic.author),:class => "problem_name" %>添加于<%= format_time(topic.created_on) %>

    -
    - <%=link_to (l(:label_reply) + topic.replies_count.to_s), board_message_path(@board, topic),:class => "talk_btn fr c_white" %> +
    + <%= link_to image_tag(url_to_avatar(topic.author), :width=>"42",:height=>"42"), user_path(topic.author),:class =>'talkmain_pic fl' %> +
    + <% author = topic.author.to_s + ":" %> + <%= link_to author, user_path(topic.author), :class =>"talkmain_name fl " %> +

      <%= h(topic.subject) %>

    + <% if topic.sticky? %> + <%= l(:label_board_sticky)%> + <% end %> -
    -
    + +
    +

    +

    + <%= topic.content %> +
    + + + + +

    + <%= l(:label_activity_time)%>:  <%= format_time topic.created_on %> +
    + <%= toggle_link l(:button_reply), "reply" + topic.id.to_s, :focus => 'message_content',:class => ' c_dblue fr' %> + +
    +
    +
    + <% reply = Message.new(:subject => "RE: #{@message.subject}")%> + <% if !topic.locked? && authorize_for('messages', 'reply') %> + +
    + + <% end %> + <% replies_all = topic.children. + includes(:author, :attachments, {:board => :project}). + reorder("#{Message.table_name}.created_on DESC").offset(2). + all %> + <% replies_show = topic.children. + includes(:author, :attachments, {:board => :project}). + reorder("#{Message.table_name}.created_on DESC").limit(2). + all %> + <% unless replies_show.empty? %> + <% reply_count = 0 %> +
    +
      + <% replies_show.each do |message| %> + +
    • + <%= link_to image_tag(url_to_avatar(message.author), :width => '34',:height => '34'), user_path(message.author), :class =>'Msg_pic' %> +
      + <%= link_to_user_header message.author,false,:class => 'fl c_orange ' %> +
      +

      <%= textAreailizable message,:content,:attachments => message.attachments %>

      + +
      + <%= format_time(message.created_on) %> + <%= link_to( + + l(:button_delete), + {:controller => 'messages', :action => 'destroy', :id => message.id, :board_id => message.board_id, :is_board => 'true'}, + :method => :post, + :data => {:confirm => l(:text_are_you_sure)}, + :title => l(:button_delete), + :class => ' c_dblue fr' + ) if message.course_destroyable_by?(User.current) %> +
      +
      + +
    • + <% end %> +
    +
    + + + + <% end %> +
    <% end %> <% else %> -

    - <%= l(:label_no_data) %> -

    +

    <%= l(:label_no_data) %>

    <% end %>