From 43a3ad1ce8612d75eb43688de5ac34d6186ff2ba Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sun, 18 Sep 2016 09:38:02 +0800 Subject: [PATCH 01/48] =?UTF-8?q?=E9=97=AE=E9=A2=98=E8=B7=9F=E8=B8=AA?= =?UTF-8?q?=E4=BD=9C=E8=80=85=E4=B8=8B=E6=8B=89=E5=88=97=E8=A1=A8=E7=94=B1?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=90=8D=E6=94=B9=E4=B8=BA=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=A7=93=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/issues/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index e4557b787..45891ae72 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -85,7 +85,7 @@ {:onchange=>"remote_function();",:id=>"status_id",:name=>"status_id",:class=>"w90 mr18"} ) %> - <%= select( :issue,:user_id, @project.members.order("lower(users.login)").map{|c| [c.name, c.user_id]}.unshift(["作者",0]), + <%= select( :issue,:user_id, @project.members.order("lower(users.login)").map{|c| [User.find(c.user_id).show_name, c.user_id]}.unshift(["作者",0]), { :include_blank => false,:selected=>@author_id ? @author_id : 0 }, {:onchange=>"remote_function();",:id=>"author_id",:name=>"author_id",:class=>"w90 mr18"} From 4504308403bfc9820c93492515841c6fa884b37f Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sun, 18 Sep 2016 15:16:31 +0800 Subject: [PATCH 02/48] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E7=95=8C=E9=9D=A2=EF=BC=8C=E9=A1=B9=E7=9B=AE=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E7=9A=84=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 7 ++++++- app/views/admin/projects.html.erb | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 3f49abb23..01f16bc46 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -31,6 +31,7 @@ class AdminController < ApplicationController @no_configuration_data = Redmine::DefaultData::Loader::no_data? end + # 管理员界面 项目列表 def projects =begin @status = params[:status] || 1 @@ -39,7 +40,11 @@ class AdminController < ApplicationController scope = scope.like(params[:name]) if params[:name].present? @projects = scope.where(project_type: Project::ProjectType_project).reorder("created_on desc").all =end - @projects = Project.like(@name).order('created_on desc') + # 搜索功能 + @name = params[:name] || "" + condition = "#{@name.strip}".gsub(" ","") + @projects = Project.like(condition).order('created_on desc') + # 分页 @projects = paginateHelper @projects,30 @page = (params['page'] || 1).to_i - 1 render :action => "projects", :layout => false if request.xhr? diff --git a/app/views/admin/projects.html.erb b/app/views/admin/projects.html.erb index 80cc40fb0..4457eef59 100644 --- a/app/views/admin/projects.html.erb +++ b/app/views/admin/projects.html.erb @@ -18,7 +18,7 @@ - <%= text_field_tag 'name', params[:name], :size => 30 %> + <%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '输入项目名称进行搜索' %> <%= submit_tag l(:button_apply), :class => "small", :name => nil %> <%= link_to l(:button_clear), {:controller => 'admin', :action => 'projects'}, :class => 'icon icon-reload' %> From 984b540a63f61ed38e2466574c50ffceb14fc894 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 19 Sep 2016 10:01:22 +0800 Subject: [PATCH 03/48] =?UTF-8?q?=E6=B8=B8=E5=AE=A2=E8=BA=AB=E4=BB=BD?= =?UTF-8?q?=EF=BC=8C=E8=BF=9B=E5=85=A5=E5=85=B7=E4=BD=93=E7=9A=84=E7=8F=AD?= =?UTF-8?q?=E7=BA=A7=E5=92=8C=E9=A1=B9=E7=9B=AE=E5=90=84=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=85=A5=E5=8F=A3=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 4 +-- app/helpers/courses_helper.rb | 6 ++++- .../attachments/_project_file_links.html.erb | 14 +++++++--- app/views/files/_project_list.html.erb | 6 ++--- app/views/layouts/base_courses.html.erb | 6 ++--- app/views/users/_course_boardlist.html.erb | 26 +++++++++---------- app/views/users/_course_newslist.html.erb | 4 +-- app/views/users/_project_boardlist.html.erb | 4 +-- 8 files changed, 41 insertions(+), 29 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b5b6c5bd0..4352de732 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1360,7 +1360,7 @@ module ApplicationHelper :id => wiki_page_id, :version => nil, :anchor => anchor, :parent => parent) end end - link_to(title.present? ? title.html_safe : h(page), url, :class => ('wiki-page' + (wiki_page ? '' : ' new'))) + link_to(title.present? ? title.html_safe : h(page), User.current.logged? ? url : signin_url_without_domain, :class => ('wiki-page' + (wiki_page ? '' : ' new'))) else # project or wiki doesn't exist all @@ -2881,7 +2881,7 @@ module ApplicationHelper def file_preview_eye(file, html_options={}) if %w(pdf pptx doc docx xls xlsx).any?{|x| file.filename.downcase.end_with?(x)} - link_to '', download_named_attachment_path(file.id, file.filename, preview: true),html_options + link_to '', User.current.logged? ? download_named_attachment_path(file.id, file.filename, preview: true) : signin_url_without_domain, html_options end end diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 8f0d10634..4308fd816 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -803,7 +803,11 @@ module CoursesHelper link = link_to(text, url, :remote => true, :method => method, :id => "#{course.id}", :class => "sy_btn_grey fl") end else - link = "#{l(:label_course_join_student)}" + if User.current.logged? + link = "#{l(:label_course_join_student)}" + else + link = link_to(l(:label_course_join_student), signin_url_without_domain, :class => "sy_btn_grey fl ml10") + end end link.html_safe end diff --git a/app/views/attachments/_project_file_links.html.erb b/app/views/attachments/_project_file_links.html.erb index 4d261c5d1..82544544a 100644 --- a/app/views/attachments/_project_file_links.html.erb +++ b/app/views/attachments/_project_file_links.html.erb @@ -35,9 +35,17 @@ <% end%> <% if options[:length] %> - <%= link_to_short_attachment attachment, :class => ' link_file_board', :download => true,:length => options[:length] -%> + <% if User.current.logged? %> + <%= link_to_short_attachment attachment, :class => ' link_file_board', :download => true,:length => options[:length] -%> + <% else %> + <%= link_to(attachment.filename, signin_url_without_domain, :class => "link_file_board", :length => options[:length]) %> + <% end %> <% else %> - <%= link_to_short_attachment attachment, :length=> 58,:class => 'hidden link_file_a fl newsBlue mw400', :download => true -%> + <% if User.current.logged? %> + <%= link_to_short_attachment attachment, :length=> 58,:class => 'hidden link_file_a fl newsBlue mw400', :download => true -%> + <% else %> + <%= link_to(attachment.filename, signin_url_without_domain,:length=> 58, :class => "hidden link_file_a fl newsBlue mw400") %> + <% end %> <% end %> <%if is_float%> @@ -92,7 +100,7 @@ <% end %> <% if options[:author] %> - <%= link_to h(truncate(attachment.author.show_name, length: 10, omission: '...')),user_path(attachment.author),:class => "link-blue" %>, + <%= link_to h(truncate(attachment.author.show_name, length: 10, omission: '...')), User.current.logged? ? user_path(attachment.author) : signin_url_without_domain, :class => "link-blue" %>, <%= format_time(attachment.created_on) %> <% end %> diff --git a/app/views/files/_project_list.html.erb b/app/views/files/_project_list.html.erb index faf254015..f03114d69 100644 --- a/app/views/files/_project_list.html.erb +++ b/app/views/files/_project_list.html.erb @@ -11,15 +11,15 @@ <%# 如果有历史版本则提供历史版本下载 %> <% if file.attachment_histories.count == 0 %> <%= link_to truncate(file.filename,length: 35, omission: '...'), - download_named_attachment_path(file.id, file.filename), + User.current.logged? ? download_named_attachment_path(file.id, file.filename) : signin_url_without_domain, :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %> <% else %> - <%= link_to truncate(file.filename,length: 35, omission: '...'), attachment_history_download_path(file.id), + <%= link_to truncate(file.filename,length: 35, omission: '...'), User.current.logged? ? attachment_history_download_path(file.id) : signin_url_without_domain, :title => file.filename+"\n"+file.description.to_s, :class => "linkGrey3 f_14", :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;", :remote=>true %> <% end %> - <%= file_preview_eye(file, class: 'preview') %> + <%= file_preview_eye(file, class: 'preview') %> <% if file.is_public? == false%> 私有 diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 84aa054e0..49788bc9f 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -68,7 +68,7 @@
  • <% count = @course.boards.first ? (@course.boards.first.topics.count + Message.where("board_id =? and parent_id is not ?", @course.boards.first.id, nil).count) : 0 %> 讨论区<%=count %> - <%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'sy_class_add', :title =>"#{l(:label_message_new)}") %> + <%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'sy_class_add', :title =>"#{l(:label_message_new)}") if is_teacher %>
  • <% end %> <% unless show_nav?(@course.homework_commons.count) %> @@ -94,7 +94,7 @@ <% unless show_nav?(course_feedback_count) %>
  • 留言<%=course_feedback_count %> - <%= link_to "", course_feedback_path(@course), :class => 'sy_class_add', :title =>"#{l(:label_course_feedback)}"%> + <%= link_to( "", course_feedback_path(@course), :class => 'sy_class_add', :title =>"#{l(:label_course_feedback)}") if is_teacher %>
  • <% end %> <% unless show_nav?(course_poll_count) %> @@ -106,7 +106,7 @@ <% count = User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status <> 1").count %> <% unless show_nav?(count) %>
  • - 在线测验<%=count %> + 在线测验<%=count %> <%= link_to( "", new_exercise_path(:course_id => @course.id), :class => 'sy_class_add', :title =>"新建试卷") if is_teacher %>
  • <% end %> diff --git a/app/views/users/_course_boardlist.html.erb b/app/views/users/_course_boardlist.html.erb index 86b308778..b8a6be169 100644 --- a/app/views/users/_course_boardlist.html.erb +++ b/app/views/users/_course_boardlist.html.erb @@ -19,19 +19,19 @@ <% topics.each do |activity| %>
    - <% if activity.parent_id.nil? %> - <%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "list-title fl" %> - <% else %> - <%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "list-title f1" %> - <% end %> - <% if activity.sticky == 1 %> - - <% end%> - <% if activity.locked %> - - <% end %> - <% u = User.where("id=?",activity.author_id).first%> -
    + <% if activity.parent_id.nil? %> + <%= link_to activity.subject.to_s.html_safe, User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :class => "list-title fl" %> + <% else %> + <%= link_to activity.parent.subject.to_s.html_safe, User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :class => "list-title f1" %> + <% end %> + <% if activity.sticky == 1 %> + + <% end%> + <% if activity.locked %> + + <% end %> + <% u = User.where("id=?",activity.author_id).first%> +
    <% if activity.parent_id.nil? %> diff --git a/app/views/users/_course_newslist.html.erb b/app/views/users/_course_newslist.html.erb index 87dbe6b95..4eb013075 100644 --- a/app/views/users/_course_newslist.html.erb +++ b/app/views/users/_course_newslist.html.erb @@ -19,11 +19,11 @@ <% topics.each do |activity| %>
    - <%= link_to activity.title.to_s, news_path(activity), :class => "list-title fl" %> + <%= link_to activity.title.to_s, User.current.logged? ? news_path(activity) : signin_url_without_domain, :class => "list-title fl" %> <% if activity.sticky == 1 %> <% end%> - <% u = User.where("id=?",activity.author_id).first%> + <% u = User.where("id=?", activity.author_id).first %>
    diff --git a/app/views/users/_project_boardlist.html.erb b/app/views/users/_project_boardlist.html.erb index 3ba0244d9..fdffc052d 100644 --- a/app/views/users/_project_boardlist.html.erb +++ b/app/views/users/_project_boardlist.html.erb @@ -20,9 +20,9 @@
    <% if activity.parent_id.nil? %> - <%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "list-title fl" %> + <%= link_to activity.subject.to_s.html_safe, User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :class=> "list-title fl" %> <% else %> - <%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "list-title f1" %> + <%= link_to activity.parent.subject.to_s.html_safe, User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :class=> "list-title f1" %> <% end %> <% if activity.sticky == 1 %> From 673b68f2a28148480139d3ae8af139a6d5ec0162 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 19 Sep 2016 13:37:18 +0800 Subject: [PATCH 04/48] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E5=9C=A8?= =?UTF-8?q?=E5=85=AC=E5=85=B1=E8=B4=B4=E5=90=A7=EF=BC=8C=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E8=B4=B4=E5=90=A7=E6=80=BB=E6=8F=90=E7=A4=BA=E2=80=9C=E6=8F=90?= =?UTF-8?q?=E6=8B=94=E5=90=8D=E7=A7=B0=E5=B7=B2=E5=AD=98=E5=9C=A8=E2=80=9D?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/forums_controller.rb | 10 +++++----- app/views/forums/index.html.erb | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 3332f1207..6ebe6b9eb 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -296,12 +296,12 @@ class ForumsController < ApplicationController #检查forum的名字 def check_forum_name - forum_name_exist = true - if params[:forum_id] - forum_name_exist = Forum.where("name = '#{params[:forum_name]}' and id != #{params[:forum_id]}").count >= 1 ? true : false - else + forum_name_exist = false + # if params[:forum_id] + # forum_name_exist = Forum.where("name = '#{params[:forum_name]}' and id != #{params[:forum_id]}").count >= 1 ? true : false + # else forum_name_exist = Forum.where("name = '#{params[:forum_name]}' ").count >= 1 ? true : false - end + # end render :text => forum_name_exist end diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index 376ca420a..9b18070a8 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -74,6 +74,7 @@ }); function check_and_submit(doc){ $("#error").html('').hide(); + check_forum_name(); if( $("textarea[name='forum[name]']").val().trim() == "" && $("textarea[name='forum[description]']").val().trim() != "" ){ $("#error").html("名称不能为空").show(); return; From 436fb3e96e19bdf74a4049e2299f310bddfaa799 Mon Sep 17 00:00:00 2001 From: cxt Date: Sat, 8 Oct 2016 15:26:47 +0800 Subject: [PATCH 05/48] =?UTF-8?q?=E7=8F=AD=E7=BA=A7=E7=9A=84=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E5=88=97=E8=A1=A8=E5=88=86=E9=A1=B5=E6=8D=A2=E6=88=90?= =?UTF-8?q?=E6=96=B0=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../homework_common/_homework_index_list.html.erb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/views/homework_common/_homework_index_list.html.erb b/app/views/homework_common/_homework_index_list.html.erb index 063621399..6c8145e58 100644 --- a/app/views/homework_common/_homework_index_list.html.erb +++ b/app/views/homework_common/_homework_index_list.html.erb @@ -1,8 +1,10 @@ <%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => homework_commons,:page => 0,:course_id => course_id} %> -
    -
      - <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> -
    -
    +
    +
    +
      + <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true, :is_new => true%> +
    +
    +
    \ No newline at end of file From f332f2a46930f00a59521632a879c4c4b3e6538c Mon Sep 17 00:00:00 2001 From: cxt Date: Sat, 8 Oct 2016 17:50:06 +0800 Subject: [PATCH 06/48] =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E7=9A=84=E5=9B=9E=E5=A4=8D=E4=BD=9C=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org_document_comments_controller.rb | 7 ++ .../_document_show_replies.html.erb | 64 ++++++++++++++++++ app/views/org_document_comments/show.html.erb | 67 ++----------------- app/views/org_document_comments/show.js.erb | 1 + 4 files changed, 79 insertions(+), 60 deletions(-) create mode 100644 app/views/org_document_comments/_document_show_replies.html.erb create mode 100644 app/views/org_document_comments/show.js.erb diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index a8a294d4d..19e06fb70 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -40,7 +40,14 @@ class OrgDocumentCommentsController < ApplicationController @document = OrgDocumentComment.find(params[:id]) @org_subfield = OrgSubfield.where(:id => @document.org_subfield_id).first @subfield_content = @organization.org_subfields.order("priority") + all_comments = [] + @replies = get_all_children(all_comments, @document) + @reply_count = @replies.count + @page = params[:page] ? params[:page].to_i + 1 : 0 + @limit = 10 + @replies = @replies[@page * @limit..@page * @limit + 9] respond_to do |format| + format.js format.html {render :layout => (@organization.switch_type && @document && !@document.org_subfield_id.blank?) ? 'base_org_custom' : 'base_org'} end end diff --git a/app/views/org_document_comments/_document_show_replies.html.erb b/app/views/org_document_comments/_document_show_replies.html.erb new file mode 100644 index 000000000..9032edce6 --- /dev/null +++ b/app/views/org_document_comments/_document_show_replies.html.erb @@ -0,0 +1,64 @@ +
    + <% @replies.each do |comment| %> + +
  • +
    + <%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_user.id) %> +
    +
    + <%= render :partial => 'users/message_contents', :locals => {:comment => comment}%> + + <% if !comment.content_detail.blank? %> +
    + <%= comment.content_detail.html_safe %> +
    +
    +
    + + + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + + + <%= link_to( + l(:button_reply), + {:controller => 'org_document_comments',:action => 'quote',:user_id=>comment.creator_id, :id => comment.id}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) %> + + + <% if comment.creator_user == User.current %> + <%= link_to( + l(:button_delete), + {:controller => 'org_document_comments',:action => 'delete_reply', :id => comment.id}, + :method => :delete, + :id => "delete_reply_#{comment.id}", + :class => 'fr mr20 undis', + :data => {:confirm => l(:text_are_you_sure)}, + :title => l(:button_delete)) %> + <% end %> + +
    +
    +
    +

    + <% end %> +
    +
    +
  • + <% end %> +
    +<% if @reply_count > @page * @limit + 10 %> +
    +
    + + + <%= link_to '点击展开更多回复', org_document_comment_path(@document, :organization_id =>@organization.id, :page => @page),:remote=>true %> +
    +
    +<% end %> \ No newline at end of file diff --git a/app/views/org_document_comments/show.html.erb b/app/views/org_document_comments/show.html.erb index 0fe72ad36..c12711c54 100644 --- a/app/views/org_document_comments/show.html.erb +++ b/app/views/org_document_comments/show.html.erb @@ -74,77 +74,24 @@ <% end %>
    - <% all_comments = []%> - <% all_replies = get_all_children(all_comments, @document) %> - <% count = all_replies.count %> + <%# all_comments = []%> + <%# all_replies = get_all_children(all_comments, @document) %> + <%# count = all_replies.count %>
    <%# if count > 0 %>
    回复 - <%= count>0 ? "(#{count})" : "" %> + <%= @reply_count>0 ? "(#{@reply_count})" : "" %> <%=render :partial=> "praise_tread/praise", :locals => {:activity=>@document, :user_activity_id=>@document.id,:type=>"activity"}%>
    - <% comments = all_replies %> -
    - <% comments.each do |comment| %> - -
  • -
    - <%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_user.id) %> -
    -
    - <%= render :partial => 'users/message_contents', :locals => {:comment => comment}%> - - <% if !comment.content_detail.blank? %> -
    - <%= comment.content_detail.html_safe %> -
    -
    -
    - - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> - - - <%= link_to( - l(:button_reply), - {:controller => 'org_document_comments',:action => 'quote',:user_id=>comment.creator_id, :id => comment.id}, - :remote => true, - :method => 'get', - :title => l(:button_reply)) %> - - - <% if comment.creator_user == User.current %> - <%= link_to( - l(:button_delete), - {:controller => 'org_document_comments',:action => 'delete_reply', :id => comment.id}, - :method => :delete, - :id => "delete_reply_#{comment.id}", - :class => 'fr mr20 undis', - :data => {:confirm => l(:text_are_you_sure)}, - :title => l(:button_delete)) %> - <% end %> - -
    -
    -
    -

    - <% end %> -
    -
    -
  • - <% end %> - + <%# comments = all_replies %> +
    + <%= render :partial => "document_show_replies" %>
    <%# end %> diff --git a/app/views/org_document_comments/show.js.erb b/app/views/org_document_comments/show.js.erb new file mode 100644 index 000000000..f164d10ec --- /dev/null +++ b/app/views/org_document_comments/show.js.erb @@ -0,0 +1 @@ +$("#more_document_replies").replaceWith("<%= escape_javascript(render :partial => 'org_document_comments/document_show_replies')%>"); \ No newline at end of file From d407b5ab10956191c1329954b1a72630a4c42cb6 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 9 Oct 2016 10:35:43 +0800 Subject: [PATCH 07/48] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E4=B8=AD=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/welcome_controller.rb | 15 ++++--- app/models/syllabus.rb | 28 +++++++++++++ app/views/layouts/_logined_header.html.erb | 2 +- .../welcome/_search_syllabus_results.html.erb | 11 +++++ app/views/welcome/search.html.erb | 42 +++++++++++-------- 5 files changed, 75 insertions(+), 23 deletions(-) create mode 100644 app/views/welcome/_search_syllabus_results.html.erb diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 1508fc871..1d8f95779 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -161,7 +161,7 @@ class WelcomeController < ApplicationController query: @name, type:"most_fields", operator: "or", - fields: ['login', 'firstname','lastname','name','description^0.5','filename','subject','content^0.5'] + fields: ['login', 'firstname','lastname','title','name','description^0.5','filename','subject','content^0.5'] } }, highlight: { @@ -171,6 +171,7 @@ class WelcomeController < ApplicationController login: {}, firstname: {}, lastname: {}, + title:{}, name:{}, description:{}, filename:{}, @@ -181,6 +182,8 @@ class WelcomeController < ApplicationController },[User,Course,Attachment,Project,Memo] ).page(params[:page] || 1).per(20).results when 'user' @users = User.search(@name).page(params[:page] || 1).per(20) + when 'syllabus' + @syllabuses = Syllabus.search(@name).page(params[:page] || 1).per(20) when 'project' @projects = Project.search(@name).page(params[:page] || 1).per(20).results when 'course' @@ -196,7 +199,7 @@ class WelcomeController < ApplicationController query: @name, type:"most_fields", operator: "or", - fields: ['login', 'firstname','lastname','name','description^0.5','filename','subject','content^0.5'] + fields: ['login', 'firstname','lastname','title','name','description^0.5','filename','subject','content^0.5'] } }, highlight: { @@ -206,6 +209,7 @@ class WelcomeController < ApplicationController login: {}, firstname: {}, lastname: {}, + title:{}, name:{}, description:{}, filename:{}, @@ -213,12 +217,12 @@ class WelcomeController < ApplicationController content:{} } } - },[User,Course,Attachment,Project,Memo] ).page(params[:page] || 1).per(20).results + },[User,Syllabus,Course,Attachment,Project,Memo] ).page(params[:page] || 1).per(20).results end @users_count = User.search(@name).results.total - + @syllabus_count = Syllabus.search(@name).results.total @course_count = Course.search(@name).results.total @attach_count = Attachment.search(@name).results.total @project_count = Project.search(@name).results.total @@ -229,7 +233,7 @@ class WelcomeController < ApplicationController query: @name, type:"most_fields", operator: "or", - fields: ['login', 'firstname','lastname','name','description^0.5','filename','subject','content^0.5'] + fields: ['login', 'firstname','lastname','title','name','description^0.5','filename','subject','content^0.5'] } }, highlight: { @@ -239,6 +243,7 @@ class WelcomeController < ApplicationController login: {}, firstname: {}, lastname: {}, + title:{}, name:{}, description:{}, filename:{}, diff --git a/app/models/syllabus.rb b/app/models/syllabus.rb index f72463503..2f69ce5c4 100644 --- a/app/models/syllabus.rb +++ b/app/models/syllabus.rb @@ -57,4 +57,32 @@ class Syllabus < ActiveRecord::Base jfm.save jfm end + + def self.search(query) + __elasticsearch__.search( + { + query: { + multi_match: { + query: query, + type:"most_fields", + operator: "or", + fields: ['title', 'description^0.5'] + } + }, + sort: { + _score:{order: "desc" }, + updated_at:{order:"desc"} + + }, + highlight: { + pre_tags: [''], + post_tags: [''], + fields: { + title: {}, + description: {} + } + } + } + ) + end end diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index cda8e8be5..5f350dd65 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -47,7 +47,7 @@ <% name = name%> <%= form_tag({controller: :welcome, action: :search },:class=>'navHomepageSearchBox', method: :get) do %> - " id="navHomepageSearchInput" class="navHomepageSearchInput" placeholder="请输入关键词搜索公开的班级、项目、用户、资源以及帖子"/> + " id="navHomepageSearchInput" class="navHomepageSearchInput" placeholder="请输入关键词搜索公开的课程、班级、项目、用户、资源以及帖子"/> diff --git a/app/views/welcome/_search_syllabus_results.html.erb b/app/views/welcome/_search_syllabus_results.html.erb new file mode 100644 index 000000000..6dd9b382a --- /dev/null +++ b/app/views/welcome/_search_syllabus_results.html.erb @@ -0,0 +1,11 @@ +<% unless syllabuses.nil? || syllabuses.empty?%> + <% syllabuses.each do |syllabus|%> +
      +
    • <%= syllabus.title %>课程
      课程
    • +
    • 创建者:<%=syllabus.user.login+"("+syllabus.user.show_name+")"%>教师团队:<%=syllabus.syllabus_member.count%>班级:<%=syllabus.courses.count%>更新时间:<%=format(syllabus.updated_at)%>单位:<%=syllabus.user.user_extensions.occupation.present? ? syllabus.user.user_extensions.occupation:'' %>
    • +
    + <% end %> +
    + <%= paginate courses,:params => {:controller => 'welcome', :action => 'search',:search_type=>'course'}%> +
    +<% end %> \ No newline at end of file diff --git a/app/views/welcome/search.html.erb b/app/views/welcome/search.html.erb index 15491c1c0..d167920e9 100644 --- a/app/views/welcome/search.html.erb +++ b/app/views/welcome/search.html.erb @@ -3,7 +3,7 @@ function g(o){return document.getElementById(o);} function HoverLi(n){ //如果有N个标签,就将i<=N; - for(var i=1;i<=6;i++){ + for(var i=1;i<=7;i++){ g('searchBaner_'+i).className='searchBannerNormal'; g('searchContent_'+i).className='undis';g('searchNum_'+i).className="numRed"; g('searchType_'+i).className="fontGrey2 f14"; @@ -23,12 +23,14 @@ //$("#searchContent_2").html('<%#= escape_javascript(render :partial => 'search_user_results',:locals => {:users=>@users})%>'); search('user') }else if(n == 3){ - search('course') + search('syllabus') }else if(n == 4){ - search('attachment') + search('course') }else if(n == 5){ - search('project') + search('attachment') }else if(n == 6){ + search('project') + }else if(n == 7){ search('memo') } } @@ -49,19 +51,22 @@ }else if('<%= @search_type%>' == 'user'){ HoverLi(2) $("#searchContent_2").html('<%= escape_javascript(render :partial => 'search_user_results',:locals => {:users=>@users})%>'); - }else if('<%= @search_type%>' == 'course'){ + }else if('<%= @search_type%>' == 'syllabus'){ HoverLi(3) - $("#searchContent_3").html('<%= escape_javascript(render :partial => 'search_course_results',:locals => {:courses=>@courses})%>'); - }else if('<%= @search_type%>' == 'attachment'){ + $("#searchContent_3").html('<%= escape_javascript(render :partial => 'search_syllabus_results',:locals => {:syllabuses=>@syllabuses})%>'); + }else if('<%= @search_type%>' == 'course'){ HoverLi(4) - $("#searchContent_4").html('<%= escape_javascript(render :partial => 'search_attachment_results',:locals => {:attachments=>@attachments})%>'); - }else if('<%= @search_type%>' == 'project'){ + $("#searchContent_4").html('<%= escape_javascript(render :partial => 'search_course_results',:locals => {:courses=>@courses})%>'); + }else if('<%= @search_type%>' == 'attachment'){ HoverLi(5) - $("#searchContent_5").html('<%= escape_javascript(render :partial => 'search_project_results',:locals => {:projects=>@projects})%>'); + $("#searchContent_5").html('<%= escape_javascript(render :partial => 'search_attachment_results',:locals => {:attachments=>@attachments})%>'); + }else if('<%= @search_type%>' == 'project'){ + HoverLi(6) + $("#searchContent_6").html('<%= escape_javascript(render :partial => 'search_project_results',:locals => {:projects=>@projects})%>'); }else if('<%= @search_type%>' == 'memo') { - HoverLi(6) - $("#searchContent_6").html('<%= escape_javascript(render :partial => 'search_memo_results',:locals => {:memos=>@memos})%>'); + HoverLi(7) + $("#searchContent_7").html('<%= escape_javascript(render :partial => 'search_memo_results',:locals => {:memos=>@memos})%>'); } }) //如果要做成点击后再转到请将
  • 中的onmouseover 改成 onclick; @@ -79,10 +84,11 @@
  • From cd34388909b0b527efe095c69c931949b9a372ef Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 9 Oct 2016 11:01:52 +0800 Subject: [PATCH 08/48] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/_search_syllabus_results.html.erb | 4 ++-- app/views/welcome/search.js.erb | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/views/welcome/_search_syllabus_results.html.erb b/app/views/welcome/_search_syllabus_results.html.erb index 6dd9b382a..8c95a1e84 100644 --- a/app/views/welcome/_search_syllabus_results.html.erb +++ b/app/views/welcome/_search_syllabus_results.html.erb @@ -2,10 +2,10 @@ <% syllabuses.each do |syllabus|%>
    • <%= syllabus.title %>课程
      课程
    • -
    • 创建者:<%=syllabus.user.login+"("+syllabus.user.show_name+")"%>教师团队:<%=syllabus.syllabus_member.count%>班级:<%=syllabus.courses.count%>更新时间:<%=format(syllabus.updated_at)%>单位:<%=syllabus.user.user_extensions.occupation.present? ? syllabus.user.user_extensions.occupation:'' %>
    • +
    • 创建者:<%=syllabus.user.login+"("+syllabus.user.show_name+")"%>教师团队:<%=syllabus.syllabus_members.count%>班级:<%=syllabus.courses.count%>更新时间:<%=format_date(syllabus.updated_at)%>单位:<%=syllabus.user.user_extensions.occupation.present? ? syllabus.user.user_extensions.occupation:'' %>
    <% end %>
    - <%= paginate courses,:params => {:controller => 'welcome', :action => 'search',:search_type=>'course'}%> + <%= paginate syllabuses,:params => {:controller => 'welcome', :action => 'search',:search_type=>'syllabus'}%>
    <% end %> \ No newline at end of file diff --git a/app/views/welcome/search.js.erb b/app/views/welcome/search.js.erb index 5cb446896..f6081c86b 100644 --- a/app/views/welcome/search.js.erb +++ b/app/views/welcome/search.js.erb @@ -3,13 +3,15 @@ $("#searchContent_1").html('<%= escape_javascript(render :partial => 'search_all_results',:locals => {:all_results=> @alls})%>'); <% when 'user'%> $("#searchContent_2").html('<%= escape_javascript(render :partial => 'search_user_results',:locals => {:users=>@users})%>'); +<% when 'syllabus'%> +$("#searchContent_3").html('<%= escape_javascript(render :partial => 'search_syllabus_results',:locals => {:syllabuses=>@syllabuses})%>'); <% when 'course'%> -$("#searchContent_3").html('<%= escape_javascript(render :partial => 'search_course_results',:locals => {:courses=>@courses})%>'); +$("#searchContent_4").html('<%= escape_javascript(render :partial => 'search_course_results',:locals => {:courses=>@courses})%>'); <% when 'project'%> -$("#searchContent_5").html('<%= escape_javascript(render :partial => 'search_project_results',:locals => {:projects=>@projects})%>'); +$("#searchContent_6").html('<%= escape_javascript(render :partial => 'search_project_results',:locals => {:projects=>@projects})%>'); <% when 'attachment'%> -$("#searchContent_4").html('<%= escape_javascript(render :partial => 'search_attachment_results',:locals => {:attachments=>@attachments})%>'); +$("#searchContent_5").html('<%= escape_javascript(render :partial => 'search_attachment_results',:locals => {:attachments=>@attachments})%>'); <% when 'memo'%> -$("#searchContent_6").html('<%= escape_javascript(render :partial => 'search_memo_results',:locals => {:memos=>@memos})%>'); +$("#searchContent_7").html('<%= escape_javascript(render :partial => 'search_memo_results',:locals => {:memos=>@memos})%>'); <%else%> <%end %> \ No newline at end of file From 3b44f05b2ba657d95e107096f995aa5fb58a0ed5 Mon Sep 17 00:00:00 2001 From: cxt Date: Sun, 9 Oct 2016 11:12:44 +0800 Subject: [PATCH 09/48] =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E7=9A=84=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E5=9B=9E=E5=A4=8D=E5=88=86=E9=A1=B5=E3=80=81?= =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E5=88=97=E8=A1=A8=E7=9A=84=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E6=95=B0=E6=9C=AA=E7=BB=9F=E8=AE=A1=E4=BA=8C=E7=BA=A7=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/blog_comments_controller.rb | 7 ++ .../_blog_comment_show_replies.html.erb | 63 ++++++++++++++++++ app/views/blog_comments/show.html.erb | 66 ++----------------- app/views/blog_comments/show.js.erb | 1 + app/views/blogs/_article.html.erb | 13 ++-- app/views/blogs/_article_list.html.erb | 2 +- 6 files changed, 86 insertions(+), 66 deletions(-) create mode 100644 app/views/blog_comments/_blog_comment_show_replies.html.erb create mode 100644 app/views/blog_comments/show.js.erb diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb index dcd549d76..46c8f5c0c 100644 --- a/app/controllers/blog_comments_controller.rb +++ b/app/controllers/blog_comments_controller.rb @@ -40,7 +40,14 @@ class BlogCommentsController < ApplicationController end def show @article = BlogComment.find(params[:id]) + all_comments = [] + @replies = get_all_children(all_comments, @article) + @reply_count = @replies.count + @page = params[:page] ? params[:page].to_i + 1 : 0 + @limit = 10 + @replies = @replies[@page * @limit..@page * @limit + 9] respond_to do |format| + format.js format.html {render :layout=>'new_base_user'} end end diff --git a/app/views/blog_comments/_blog_comment_show_replies.html.erb b/app/views/blog_comments/_blog_comment_show_replies.html.erb new file mode 100644 index 000000000..ba33aaf5a --- /dev/null +++ b/app/views/blog_comments/_blog_comment_show_replies.html.erb @@ -0,0 +1,63 @@ +<% @replies.each do |comment| %> + +
  • +
    + <%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_user.id) %> +
    +
    + <%= render :partial => 'users/message_contents', :locals => {:comment => comment}%> + + <% if !comment.content_detail.blank? %> +
    + <%= comment.content_detail.html_safe %> +
    +
    +
    + + + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + + + <%= link_to( + l(:button_reply), + {:controller => 'blog_comments', :action => 'quote', :user_id => comment.author_id, :blog_id => comment.blog_id, :id => comment.id}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) if !@article.locked? %> + + + <% if comment.author == User.current %> + <%= link_to( + l(:button_delete), + {:controller => 'blog_comments', :action => 'destroy', :id => comment.id}, + :method => :delete, + :id => "delete_reply_#{comment.id}", + :class => 'fr mr20 undis', + :data => {:confirm => l(:text_are_you_sure)}, + :title => l(:button_delete) + ) %> + <% end %> + +
    +
    +
    +

    + <% end %> +
    +
    +
  • +<% end %> +<% if @reply_count > @page * @limit + 10 %> +
    +
    + + + <%= link_to '点击展开更多回复', blog_comment_path(@article, :page => @page),:remote=>true %> +
    +
    +<% end %> diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb index 7143e980b..41bcdf4c4 100644 --- a/app/views/blog_comments/show.html.erb +++ b/app/views/blog_comments/show.html.erb @@ -105,13 +105,13 @@
    - <% all_comments = []%> - <% all_replies = get_all_children(all_comments, @article) %> - <% count= all_replies.count %> + <%# all_comments = []%> + <%# all_replies = get_all_children(all_comments, @article) %> + <%# count= all_replies.count %>
    回复 - <%= count>0 ? "(#{count})" : "" %> + <%= @reply_count > 0 ? "(#{@reply_count})" : "" %> <%= render :partial => "praise_tread/praise", :locals => {:activity => @article, :user_activity_id => @article.id, :type => "activity"} %> @@ -120,62 +120,10 @@
    - <% comments = all_replies %> - <% if count > 0 %> + <%# comments = all_replies %> + <% if @reply_count > 0 %>
    - <% comments.each do |comment| %> - -
  • -
    - <%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_user.id) %> -
    -
    - <%= render :partial => 'users/message_contents', :locals => {:comment => comment}%> - - <% if !comment.content_detail.blank? %> -
    - <%= comment.content_detail.html_safe %> -
    -
    -
    - - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> - - - <%= link_to( - l(:button_reply), - {:controller => 'blog_comments', :action => 'quote', :user_id => comment.author_id, :blog_id => comment.blog_id, :id => comment.id}, - :remote => true, - :method => 'get', - :title => l(:button_reply)) if !@article.locked? %> - - - <% if comment.author == User.current %> - <%= link_to( - l(:button_delete), - {:controller => 'blog_comments', :action => 'destroy', :id => comment.id}, - :method => :delete, - :id => "delete_reply_#{comment.id}", - :class => 'fr mr20 undis', - :data => {:confirm => l(:text_are_you_sure)}, - :title => l(:button_delete) - ) %> - <% end %> - -
    -
    -
    -

    - <% end %> -
    -
    -
  • <% end %> + <%= render :partial => 'blog_comment_show_replies' %>
    <% end %> diff --git a/app/views/blog_comments/show.js.erb b/app/views/blog_comments/show.js.erb new file mode 100644 index 000000000..be5362685 --- /dev/null +++ b/app/views/blog_comments/show.js.erb @@ -0,0 +1 @@ +$("#more_blog_replies").replaceWith("<%= escape_javascript(render :partial => 'blog_comment_show_replies')%>"); \ No newline at end of file diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb index dd818fe72..620d68bec 100644 --- a/app/views/blogs/_article.html.erb +++ b/app/views/blogs/_article.html.erb @@ -36,12 +36,13 @@ <% end %>
    - <% count=0 %> - <% if activity.parent %> - <% count=activity.parent.children.count%> - <% else %> - <% count=activity.children.count%> - <% end %> + <% all_comments = [] %> + <% count = (get_all_children all_comments, activity).count %> + <%# if activity.parent %> + <%# count=activity.parent.children.count%> + <%# else %> + <%# count=activity.children.count%> + <%# end %>
  • 发布:<%= format_time(activity.created_on) %> 更新:<%= format_time(activity.updated_on) %> diff --git a/app/views/blogs/_article_list.html.erb b/app/views/blogs/_article_list.html.erb index c52fa017e..da5e78c73 100644 --- a/app/views/blogs/_article_list.html.erb +++ b/app/views/blogs/_article_list.html.erb @@ -39,7 +39,7 @@
    - <%= @user.name%>的博客 + <%= @user.show_name%>的博客
    From f380c64653707cbde25d6579c84907a9779c6215 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 9 Oct 2016 11:27:35 +0800 Subject: [PATCH 10/48] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/syllabus.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/app/models/syllabus.rb b/app/models/syllabus.rb index 2f69ce5c4..b046ce2cd 100644 --- a/app/models/syllabus.rb +++ b/app/models/syllabus.rb @@ -17,6 +17,10 @@ class Syllabus < ActiveRecord::Base validates :title, :user_id, presence: true + after_update :update_syllabus_ealasticsearch_index + after_create :create_syllabus_ealasticsearch_index + before_destroy :delete_syllabus_ealasticsearch_index + scope :like, lambda {|arg| if arg.blank? where(nil) @@ -58,6 +62,29 @@ class Syllabus < ActiveRecord::Base jfm end + def create_syllabus_ealasticsearch_index + return if Rails.env.development? + self.__elasticsearch__.index_document + end + + def update_syllabus_ealasticsearch_index + return if Rails.env.development? + begin + self.__elasticsearch__.update_document + rescue => e + self.__elasticsearch__.index_document + end + end + + def delete_syllabus_ealasticsearch_index + return if Rails.env.development? + begin + self.__elasticsearch__.delete_document + rescue => e + + end + end + def self.search(query) __elasticsearch__.search( { From 1fe2f8946bfa40a1cba9bf8da73fa8e307a096f1 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 9 Oct 2016 12:10:34 +0800 Subject: [PATCH 11/48] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E8=AF=BE=E7=A8=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/syllabus.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/syllabus.rb b/app/models/syllabus.rb index b046ce2cd..6bd770d5d 100644 --- a/app/models/syllabus.rb +++ b/app/models/syllabus.rb @@ -2,6 +2,7 @@ class Syllabus < ActiveRecord::Base include Redmine::SafeAttributes include ApplicationHelper + include Elasticsearch::Model acts_as_taggable acts_as_attachable has_many_kindeditor_assets :assets, :dependent => :destroy From 9dd6a6531698a786964db24cd0cced693e2dce90 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 9 Oct 2016 13:16:03 +0800 Subject: [PATCH 12/48] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/syllabus.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/models/syllabus.rb b/app/models/syllabus.rb index 6bd770d5d..fff88c83f 100644 --- a/app/models/syllabus.rb +++ b/app/models/syllabus.rb @@ -2,7 +2,18 @@ class Syllabus < ActiveRecord::Base include Redmine::SafeAttributes include ApplicationHelper + #elasticsearch include Elasticsearch::Model + #elasticsearch kaminari init + Kaminari::Hooks.init + Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari + settings index: { number_of_shards: 5 } do + mappings dynamic: 'false' do + indexes :name, analyzer: 'smartcn',index_options: 'offsets' + indexes :description, analyzer: 'smartcn',index_options: 'offsets' + indexes :updated_on, index:"not_analyzed", type:'date' + end + end acts_as_taggable acts_as_attachable has_many_kindeditor_assets :assets, :dependent => :destroy From 28d6bca3df09751f998a8c137eef0eb5d2d95002 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 9 Oct 2016 13:29:13 +0800 Subject: [PATCH 13/48] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/syllabus.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/syllabus.rb b/app/models/syllabus.rb index fff88c83f..5314f8dbd 100644 --- a/app/models/syllabus.rb +++ b/app/models/syllabus.rb @@ -9,9 +9,9 @@ class Syllabus < ActiveRecord::Base Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari settings index: { number_of_shards: 5 } do mappings dynamic: 'false' do - indexes :name, analyzer: 'smartcn',index_options: 'offsets' + indexes :title, analyzer: 'smartcn',index_options: 'offsets' indexes :description, analyzer: 'smartcn',index_options: 'offsets' - indexes :updated_on, index:"not_analyzed", type:'date' + indexes :updated_at, index:"not_analyzed", type:'date' end end acts_as_taggable From c90d8d6bea38c52da656a96e8005dab1e12094ef Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 9 Oct 2016 13:32:31 +0800 Subject: [PATCH 14/48] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/_search_syllabus_results.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/welcome/_search_syllabus_results.html.erb b/app/views/welcome/_search_syllabus_results.html.erb index 8c95a1e84..842cceb2b 100644 --- a/app/views/welcome/_search_syllabus_results.html.erb +++ b/app/views/welcome/_search_syllabus_results.html.erb @@ -1,7 +1,7 @@ <% unless syllabuses.nil? || syllabuses.empty?%> <% syllabuses.each do |syllabus|%>
      -
    • <%= syllabus.title %>课程
      课程
    • +
    • <%= syllabus.title %>课程
      课程
    • 创建者:<%=syllabus.user.login+"("+syllabus.user.show_name+")"%>教师团队:<%=syllabus.syllabus_members.count%>班级:<%=syllabus.courses.count%>更新时间:<%=format_date(syllabus.updated_at)%>单位:<%=syllabus.user.user_extensions.occupation.present? ? syllabus.user.user_extensions.occupation:'' %>
    <% end %> From 11edc93c0f9f154461ebbef53698f081ea25b320 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 9 Oct 2016 13:48:38 +0800 Subject: [PATCH 15/48] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/_search_syllabus_results.html.erb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/views/welcome/_search_syllabus_results.html.erb b/app/views/welcome/_search_syllabus_results.html.erb index 842cceb2b..f59b83d9a 100644 --- a/app/views/welcome/_search_syllabus_results.html.erb +++ b/app/views/welcome/_search_syllabus_results.html.erb @@ -1,8 +1,17 @@ <% unless syllabuses.nil? || syllabuses.empty?%> <% syllabuses.each do |syllabus|%>
      -
    • <%= syllabus.title %>课程
      课程
    • -
    • 创建者:<%=syllabus.user.login+"("+syllabus.user.show_name+")"%>教师团队:<%=syllabus.syllabus_members.count%>班级:<%=syllabus.courses.count%>更新时间:<%=format_date(syllabus.updated_at)%>单位:<%=syllabus.user.user_extensions.occupation.present? ? syllabus.user.user_extensions.occupation:'' %>
    • +
    • + <%= syllabus.title %>课程 + <%= syllabus.try(:highlight).try(:title) ? syllabus.highlight.title[0].html_safe : syllabus.title %>课程 +
      课程
    • +
    • + 创建者:<%=syllabus.user.login+"("+syllabus.user.show_name+")"%> + 教师团队:<%=syllabus.syllabus_members.count%> + 班级:<%=syllabus.courses.count%> + 更新时间:<%=format_date(syllabus.updated_at)%> + 单位:<%=syllabus.user.user_extensions.occupation.present? ? syllabus.user.user_extensions.occupation : '' %> +
    <% end %>
    From fdcb13a3deed66e794d7f4747840657fd1b04162 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 9 Oct 2016 13:57:27 +0800 Subject: [PATCH 16/48] =?UTF-8?q?=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/_search_all_results.html.erb | 13 +++++++++++++ app/views/welcome/_search_syllabus_results.html.erb | 2 +- app/views/welcome/search.html.erb | 6 +++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/views/welcome/_search_all_results.html.erb b/app/views/welcome/_search_all_results.html.erb index 3316cbc8a..bacafb323 100644 --- a/app/views/welcome/_search_all_results.html.erb +++ b/app/views/welcome/_search_all_results.html.erb @@ -25,6 +25,19 @@
  • + <% when 'syllabus'%> + <% when 'course'%>
    • diff --git a/app/views/welcome/_search_syllabus_results.html.erb b/app/views/welcome/_search_syllabus_results.html.erb index f59b83d9a..779570a4e 100644 --- a/app/views/welcome/_search_syllabus_results.html.erb +++ b/app/views/welcome/_search_syllabus_results.html.erb @@ -2,7 +2,7 @@ <% syllabuses.each do |syllabus|%> <% when 'syllabus'%> + <% logger.info "input_item" %> + <% logger.info item %>
      • <%= item.try(:highlight).try(:title) ? item.highlight.title[0].html_safe : item.title %>课程 From 9ca685ea940d74c8befba2d6971cb3b02327b7b9 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 9 Oct 2016 16:10:33 +0800 Subject: [PATCH 21/48] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/welcome_controller.rb | 4 +--- app/views/welcome/_search_all_results.html.erb | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 23876adf3..51ede7d9f 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -183,9 +183,7 @@ class WelcomeController < ApplicationController when 'user' @users = User.search(@name).page(params[:page] || 1).per(20) when 'syllabus' - @syllabuses = Syllabus.search(@name).page(params[:page] || 1).per(20) - logger.info "input_syllabus" - logger.info @syllabuses[0] + @syllabuses = Syllabus.search(@name).page(params[:page] || 1).per(20).results when 'project' @projects = Project.search(@name).page(params[:page] || 1).per(20).results when 'course' diff --git a/app/views/welcome/_search_all_results.html.erb b/app/views/welcome/_search_all_results.html.erb index 10f5a14cf..69ee1756b 100644 --- a/app/views/welcome/_search_all_results.html.erb +++ b/app/views/welcome/_search_all_results.html.erb @@ -26,8 +26,6 @@
      <% when 'syllabus'%> - <% logger.info "input_item" %> - <% logger.info item %>
      • <%= item.try(:highlight).try(:title) ? item.highlight.title[0].html_safe : item.title %>课程 From 4de0105d994e1c2a1d2099df8daa15399f763d8f Mon Sep 17 00:00:00 2001 From: cxt Date: Sun, 9 Oct 2016 17:05:32 +0800 Subject: [PATCH 22/48] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E5=A4=B4=E9=83=A8?= =?UTF-8?q?=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/poll/_edit_head.html.erb | 57 ++++++++++++------------------ app/views/poll/_poll_form.html.erb | 7 ++-- app/views/poll/_show_head.html.erb | 8 ++--- 3 files changed, 29 insertions(+), 43 deletions(-) diff --git a/app/views/poll/_edit_head.html.erb b/app/views/poll/_edit_head.html.erb index 8eebae5a2..6182aedf5 100644 --- a/app/views/poll/_edit_head.html.erb +++ b/app/views/poll/_edit_head.html.erb @@ -1,42 +1,31 @@ <%= form_for @poll,:remote => true do |f|%> -
        -
        - -
        -
        -
        - <%= @poll.polls_description.nil? ? "" : @poll.polls_description.html_safe%> -
        - -
        -
      • -
      • <%= User.find(item.id).user_extensions && User.find(item.id).user_extensions.brief_introduction.present? ? User.find(item.id).user_extensions.brief_introduction : '这位童鞋很懒,什么也没有留下~'%>
      • + <% user = User.find(item.id)%> +
      • <%= user.user_extensions && user.user_extensions.brief_introduction.present? ? user.user_extensions.brief_introduction : '这位童鞋很懒,什么也没有留下~'%>
      • - 加入时间:<%= format_date( User.find(item.id).created_on)%> - 最后登录时间:<%= format_date( User.find(item.id).last_login_on)%> - <%= User.find(item.id).user_extensions.occupation.present? ? '单位:'+User.find(item.id).user_extensions.occupation : ''%>
      • + 加入时间:<%= format_date( user.created_on)%> + 最后登录时间:<%= format_date( user.last_login_on)%> + <%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %>
    • @@ -29,13 +30,15 @@
      • <%= item.try(:highlight).try(:title) ? item.highlight.title[0].html_safe : item.title %>课程 -
        课程
      • +
        <%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %>课程
      • - 创建者:<%=item.user.login+"("+item.user.show_name+")"%> - 教师团队:<%=item.syllabus_members.count%> - 班级:<%=item.courses.count%> + <% user = User.find(item.user_id)%> + <% syllabus = Syllabus.find(item.id) %> + 创建者:<%=user.login+"("+user.show_name+")"%> + 教师团队:<%=syllabus.syllabus_members.count%> + 班级:<%=syllabus.courses.count%> 更新时间:<%=format_date(item.updated_at)%> - 单位:<%=item.user.user_extensions.occupation.present? ? item.user.user_extensions.occupation : '' %> + <%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %>
      <% when 'course'%> @@ -51,10 +54,11 @@
    • <%= item.try(:highlight).try(:description) ? item.highlight.description[0].html_safe : item.description %>
    • - 教师:<%= User.find(item.tea_id).realname %> + <% user = User.find(item.tea_id)%> + 教师:<%= user.realname %> 授课时间:<%= item.time.to_s + item.term%> 更新时间:<%= format_date(item.updated_at)%> - <%= User.find(item.tea_id).user_extensions.occupation.present? ? '单位:'+User.find(item.tea_id).user_extensions.occupation : ''%>
    • + <%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %>
    @@ -69,7 +73,8 @@
    <%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %>资源
    -
  • 发布者:<%= User.find(item.author_id).login%>(<%= User.find(item.author_id).realname%>) + <% user = User.find(item.author_id)%> +
  • 发布者:<%= user.login%>(<%= user.realname%>) 发布时间:<%= format_date(item.created_on)%> 下载次数:<%= item.downloads%>次 diff --git a/app/views/welcome/_search_attachment_results.html.erb b/app/views/welcome/_search_attachment_results.html.erb index e51706085..fa0468385 100644 --- a/app/views/welcome/_search_attachment_results.html.erb +++ b/app/views/welcome/_search_attachment_results.html.erb @@ -10,7 +10,8 @@
    <%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %>资源
  • -
  • 发布者:<%= User.find(attachment.author_id).login%>(<%= User.find(attachment.author_id).realname%>) + <% user = User.find(attachment.author_id)%> +
  • 发布者:<%= user.login%>(<%= user.realname%>) 发布时间:<%= format_date(attachment.created_on)%> 下载次数:<%= attachment.downloads%>次 diff --git a/app/views/welcome/_search_course_results.html.erb b/app/views/welcome/_search_course_results.html.erb index 322a47de5..dd4c9f405 100644 --- a/app/views/welcome/_search_course_results.html.erb +++ b/app/views/welcome/_search_course_results.html.erb @@ -13,10 +13,11 @@
  • <%= course.try(:highlight).try(:description) ? course.highlight.description[0].html_safe : (course.description.present? ? course.description : '暂时没有该班级描述') %>
  • - 教师:<%= User.find(course.tea_id).realname %> + <% user = User.find(course.tea_id)%> + 教师:<%= user.realname %> 授课时间:<%= course.time.to_s + course.term%> 更新时间:<%= format_date(course.updated_at)%> - <%= User.find(course.tea_id).user_extensions.occupation.present? ? '单位:'+User.find(course.tea_id).user_extensions.occupation : ''%>
  • + <%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %>
    diff --git a/app/views/welcome/_search_syllabus_results.html.erb b/app/views/welcome/_search_syllabus_results.html.erb index 779570a4e..163392341 100644 --- a/app/views/welcome/_search_syllabus_results.html.erb +++ b/app/views/welcome/_search_syllabus_results.html.erb @@ -1,16 +1,18 @@ <% unless syllabuses.nil? || syllabuses.empty?%> - <% syllabuses.each do |syllabus|%> + <% syllabuses.each do |item|%> <% end %> diff --git a/app/views/welcome/_search_user_results.html.erb b/app/views/welcome/_search_user_results.html.erb index 06a40d021..3b9e18fba 100644 --- a/app/views/welcome/_search_user_results.html.erb +++ b/app/views/welcome/_search_user_results.html.erb @@ -1,20 +1,21 @@ <% unless users.nil? || users.empty?%> -<% users.each do |user|%> +<% users.each do |item|%>
    • - <%= link_to image_tag(url_to_avatar(User.find(user.id)), :width => "75", :height => "75",:class=>'searchCourseImage'), user_path(user.id), :alt => "用户头像" %> + <% user = User.find(item.id)%> + <%= link_to image_tag(url_to_avatar(user), :width => "75", :height => "75",:class=>'searchCourseImage'), user_path(user.id), :alt => "用户头像" %>
    • diff --git a/lib/tasks/elasticsearch_batch_op.rake b/lib/tasks/elasticsearch_batch_op.rake index 6693fcf69..0c041ba8c 100644 --- a/lib/tasks/elasticsearch_batch_op.rake +++ b/lib/tasks/elasticsearch_batch_op.rake @@ -7,21 +7,6 @@ namespace :importer do ENV['BATCH']='1000' Rake::Task["elasticsearch:import:model"].execute end - task :importproject => :environment do - - ENV['CLASS']='Project' - ENV['SCOPE']='indexable' - ENV['FORCE']='y' - ENV['BATCH']='1000' - Rake::Task["elasticsearch:import:model"].execute - end - task :importcourse => :environment do - ENV['CLASS']='Course' - ENV['SCOPE']='indexable' - ENV['FORCE']='y' - ENV['BATCH']='1000' - Rake::Task["elasticsearch:import:model"].execute - end task :importsyllabus => :environment do ENV['CLASS']='Syllabus' ENV['SCOPE']='indexable' @@ -29,6 +14,13 @@ namespace :importer do ENV['BATCH']='1000' Rake::Task["elasticsearch:import:model"].execute end + task :importcourse => :environment do + ENV['CLASS']='Course' + ENV['SCOPE']='indexable' + ENV['FORCE']='y' + ENV['BATCH']='1000' + Rake::Task["elasticsearch:import:model"].execute + end task :importattachment => :environment do ENV['CLASS']='Attachment' ENV['SCOPE']='indexable' @@ -36,6 +28,14 @@ namespace :importer do ENV['BATCH']='1000' Rake::Task["elasticsearch:import:model"].execute end + task :importproject => :environment do + + ENV['CLASS']='Project' + ENV['SCOPE']='indexable' + ENV['FORCE']='y' + ENV['BATCH']='1000' + Rake::Task["elasticsearch:import:model"].execute + end task :importmemo => :environment do ENV['CLASS']='Memo' ENV['SCOPE']='indexable' @@ -45,5 +45,5 @@ namespace :importer do end desc "Run all tasks" - task :all => [:importuser,:importproject,:importsyllabus,:importcourse,:importattachment,:importmemo] + task :all => [:importuser,:importsyllabus,:importcourse,:importattachment,:importproject,:importmemo] end \ No newline at end of file From 163abb70de00fd8bbe6435606a78f425e6d0230b Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Mon, 10 Oct 2016 14:00:10 +0800 Subject: [PATCH 24/48] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=8F=AA=E8=83=BD=E6=90=9C=E7=B4=A2title?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/syllabus.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/syllabus.rb b/app/models/syllabus.rb index b471c0684..959499bf0 100644 --- a/app/models/syllabus.rb +++ b/app/models/syllabus.rb @@ -107,7 +107,7 @@ class Syllabus < ActiveRecord::Base query: query, type:"most_fields", operator: "or", - fields: ['title', 'description^0.5'] + fields: ['title'] } }, sort: { From 3217f84df27f421ea99bd06bfe37eec57c61753b Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 10 Oct 2016 14:13:20 +0800 Subject: [PATCH 25/48] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E7=9A=84=E5=8D=95?= =?UTF-8?q?=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/poll_controller.rb | 7 +++++ app/views/poll/_new_MC.html.erb | 50 ++++++++++++++++++------------ app/views/poll/_poll_form.html.erb | 34 +++++++++++++++----- public/stylesheets/css/common.css | 5 ++- public/stylesheets/css/courses.css | 7 ++++- public/stylesheets/css/public.css | 3 ++ 6 files changed, 76 insertions(+), 30 deletions(-) diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 95724edf3..bc5e5dc9e 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -151,6 +151,13 @@ class PollController < ApplicationController @poll_questions.poll_answers.new question_option end end + if params[:question_other_answer] + question_option = { + :answer_position => params[:question_answer].count + 1, + :answer_text => '' + } + @poll_questions.poll_answers.new question_option + end # 如果是插入的话,那么从插入的这个id以后的question_num都将要+1 if params[:quest_id] @is_insert = true diff --git a/app/views/poll/_new_MC.html.erb b/app/views/poll/_new_MC.html.erb index 268ce18b1..0a9114158 100644 --- a/app/views/poll/_new_MC.html.erb +++ b/app/views/poll/_new_MC.html.erb @@ -1,37 +1,47 @@ <%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%> <% insert_begin = insert_begin %> -
      +
      - +
      +
        +
      • + + + + +
      • +
        +
      • + + + + +
      • +
        +
      • + + + + +
      • +
        +
        -
      • - - - - +
      • +
        新建选项
      • -
      • - - - - +
      • + 添加[其他]选项
      • -
        -
      • - - - - -
      • -
        +
      -
      -
        -
      • +
        + 题型 +
          +
        • <%= l(:label_MC) %> diff --git a/public/stylesheets/css/common.css b/public/stylesheets/css/common.css index defbdbed1..3420a994d 100644 --- a/public/stylesheets/css/common.css +++ b/public/stylesheets/css/common.css @@ -588,4 +588,7 @@ a:hover.sy_btn_blue{ background: #2788d0;} /*状态提示图标*/ .success-icon {background:url("/images/icons_ziliao.png") 0 -28px no-repeat; padding-left:25px;} -.error-icon {background:url("/images/icons_ziliao.png") 0 -56px no-repeat; padding-left:25px;} \ No newline at end of file +.error-icon {background:url("/images/icons_ziliao.png") 0 -56px no-repeat; padding-left:25px;} + +/*禁用*/ +.disabled {background-color:#f5f5f5;} \ No newline at end of file diff --git a/public/stylesheets/css/courses.css b/public/stylesheets/css/courses.css index a21633e44..fee11954f 100644 --- a/public/stylesheets/css/courses.css +++ b/public/stylesheets/css/courses.css @@ -545,4 +545,9 @@ a:hover.blueCir{ background:#3598db; color:#fff;} .homework-detail-tab li {float:left; width:100px; text-align:center; padding:3px 0; border-bottom:2px solid #ddd;} .homework-detail-tab li.selected {border-bottom:2px solid #f00;} .test-set-table, .test-set-table tr, .test-set-table th, .test-set-table td {border-collapse:collapse; text-align:left; border:1px solid #ddd; color:#484848;} -.test-set-table th, .test-set-table td {padding:2px 5px;} \ No newline at end of file +.test-set-table th, .test-set-table td {padding:2px 5px;} + +/*20160912问卷调查*/ +.new-question {width:324px; height:30px; color:#888; background-color:#fff; padding-left:5px; margin-left:46px; cursor:pointer;} +.new-subjective {width:550px; height:30px; color:#888; background-color:#fff; padding-left:5px; margin-left:96px; cursor:pointer;} +.questionnaire-input {height:30px; border:1px solid #cbcbcb; padding-left:5px;} \ No newline at end of file diff --git a/public/stylesheets/css/public.css b/public/stylesheets/css/public.css index 514139513..3117e1a07 100644 --- a/public/stylesheets/css/public.css +++ b/public/stylesheets/css/public.css @@ -1461,3 +1461,6 @@ a:hover.sy_btn_green{ background: #51a74f;} .flex-container {display:flex;} .flex-cell {flex:1;} .flex-cell:last-child {text-align:right;} + +/*20160912问卷调查*/ +.dash-block {border:1px dashed #ddd;} \ No newline at end of file From 405e2cfb9b1338d7c18d7bf0fc242a33ec65fe40 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 11 Oct 2016 08:51:00 +0800 Subject: [PATCH 26/48] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E5=8D=95=E9=80=89?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/poll_controller.rb | 15 ++++++ app/views/poll/_edit_MC.html.erb | 36 +++++++++---- app/views/poll/_poll_content.html.erb | 78 ++++++++++++++++++--------- app/views/poll/_show_MC.html.erb | 28 +++++----- public/stylesheets/css/common.css | 1 + 5 files changed, 113 insertions(+), 45 deletions(-) diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index bc5e5dc9e..d7b2cfa26 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -199,6 +199,21 @@ class PollController < ApplicationController @poll_question.poll_answers.new question_option end end + if params[:question_other_answer] + question = @poll_question.poll_answers.where("answer_text = ''").first + unless question + question_option = { + :answer_position => params[:question_answer].count + 1, + :answer_text => '' + } + @poll_question.poll_answers.new question_option + end + else + question = @poll_question.poll_answers.where("answer_text = ''").first + if question + question.destroy + end + end end @poll_question.save respond_to do |format| diff --git a/app/views/poll/_edit_MC.html.erb b/app/views/poll/_edit_MC.html.erb index 9209bf61d..08aeacc43 100644 --- a/app/views/poll/_edit_MC.html.erb +++ b/app/views/poll/_edit_MC.html.erb @@ -17,26 +17,44 @@ } -
          +
          - + />
            <% poll_question.poll_answers.reorder("answer_position").each do |poll_answer| %> -
          • - - - - -
          • -
            + <% if poll_answer.answer_text != '' %> +
          • + + + +
          • +
            + <% else %> +
          • + + + +
          • +
            + <% end %> <% end%>
          +