From ea308736657c38b7a048a26eb22f369d2e37bad7 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 29 Nov 2016 17:02:36 +0800 Subject: [PATCH 01/28] =?UTF-8?q?=E5=88=9B=E5=BB=BA=EF=BC=8C=E6=88=96?= =?UTF-8?q?=E5=85=B3=E9=97=ADPullRequest=E6=97=B6=EF=BC=8C=E5=8F=91?= =?UTF-8?q?=E9=80=81=E6=B6=88=E6=81=AF=EF=BC=88=E6=9C=AA=E5=AE=8C=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 13 +++++----- app/views/users/_user_message_forge.html.erb | 25 +++++++++++++------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 0b6a73440..d3d60bf5a 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -98,15 +98,15 @@ class PullRequestsController < ApplicationController @fork_project_name = Project.find(params[:target_project_id]).try(:name) @fork_pr_message = true if @fork_project_name # 发送消息 - #send_message(User.current.id, target_project_id, title) + send_message(User.current.id, target_project_id, request.id) # 创建Trustie数据 - #PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => target_project_id) + PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => target_project_id) else request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch) # 发送消息 - #send_message(User.current.id, @project.id, title) + send_message(User.current.id, @project.id, request.id) # 创建Trustie数据 - #PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => @project.id) + PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => @project.id) respond_to do |format| format.js{redirect_to project_pull_request_path(request.id, :project_id => @project.id)} end @@ -295,8 +295,9 @@ class PullRequestsController < ApplicationController end private - def send_message user_id, project_id, title - self.forge_acts << ForgeMessage.new(:user_id => user_id, :project_id => project_id, :title => title) + def send_message user_id, project_id, pull_request_id + self.forge_acts << ForgeMessage.new(:user_id => user_id, :project_id => project_id, + :forge_message_id => pull_request_id, :forge_message_type => "PullRequest", :viewed => true) end def authorize_logged diff --git a/app/views/users/_user_message_forge.html.erb b/app/views/users/_user_message_forge.html.erb index 54eea89c0..95a079714 100644 --- a/app/views/users/_user_message_forge.html.erb +++ b/app/views/users/_user_message_forge.html.erb @@ -194,24 +194,31 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> - + <% end %> <% end %> \ No newline at end of file From 2cee4448ea30f129e09d632864b680f92cf78b93 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 29 Nov 2016 18:19:29 +0800 Subject: [PATCH 02/28] =?UTF-8?q?pullrequest=E6=B6=88=E6=81=AF=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=EF=BC=88=E6=9C=AA=E5=AE=8C=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/users_helper.rb | 14 ++++++++++++++ app/views/users/_user_message_forge.html.erb | 10 +++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 4dd3399a3..14064c11f 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -90,6 +90,20 @@ module UsersHelper end end + # 获取pullrequest消息状态 + def pull_request_message_status ma + case ma.status + when 1 + "创建了PullRequest:" + when 2 + "接受了您的PullRequest:" + when 3 + "重新打开了PullRequest:" + when 4 + "关闭了您的PullRequest:" + end + + end # 判断当前用户能否对消息进行操作 def allow_to_show applied_message (User.current.id == applied_message.user_id && applied_message.status == 1) ? true : false diff --git a/app/views/users/_user_message_forge.html.erb b/app/views/users/_user_message_forge.html.erb index 95a079714..c28c40065 100644 --- a/app/views/users/_user_message_forge.html.erb +++ b/app/views/users/_user_message_forge.html.erb @@ -206,16 +206,12 @@ <%=link_to User.find(ma.forge_message.author).show_name, user_path(ma.forge_message.author), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> "> - <% if ma.status == 1 %> - 创建了PullRequest: - <% elsif ma.status == 3 %> - 重新打开了PullRequest: - <% end %> + <%= pull_request_message_status(ma) %>
  • - <%= link_to "#{ma.forge_message.forge_message_id.title}", - {:controller => 'pull_requests', :action => 'show', :id => ma.forge_message.project_id },:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %> + <%= link_to "#{ma.forge_message.forge_message_id.title}", {:controller => 'pull_requests', :action => 'show', :id => ma.forge_message.project_id }, + :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
  • <%= time_tag(ma.created_at).html_safe %>
  • From 9fa4b5613a7053b1ae7b01949c6832e6946e39d2 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 30 Nov 2016 08:37:56 +0800 Subject: [PATCH 03/28] =?UTF-8?q?pullrequest=E5=8F=91=E9=80=81=E6=B6=88?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index d3d60bf5a..9cb2d2c02 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -296,7 +296,7 @@ class PullRequestsController < ApplicationController private def send_message user_id, project_id, pull_request_id - self.forge_acts << ForgeMessage.new(:user_id => user_id, :project_id => project_id, + ForgeMessage.create(:user_id => user_id, :project_id => project_id, :forge_message_id => pull_request_id, :forge_message_type => "PullRequest", :viewed => true) end From 2e5cd96bb9b85046aec8dc44cf993d6979c932dd Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 1 Dec 2016 11:31:48 +0800 Subject: [PATCH 04/28] =?UTF-8?q?pullrequest=E5=8F=91=E9=80=81=E6=B6=88?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 56 ++++++++++++++++--- app/helpers/users_helper.rb | 4 +- app/models/pull_request.rb | 2 +- app/views/repositories/show.html.erb | 20 +++---- app/views/users/_user_message_course.html.erb | 8 +-- app/views/users/_user_message_forge.html.erb | 16 +++--- ...61129032534_add_status_to_pull_requests.rb | 5 -- ...0161130031415_add_titil_to_pull_requsts.rb | 5 ++ 8 files changed, 80 insertions(+), 36 deletions(-) delete mode 100644 db/migrate/20161129032534_add_status_to_pull_requests.rb create mode 100644 db/migrate/20161130031415_add_titil_to_pull_requsts.rb diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 9cb2d2c02..7da5a0dc1 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -97,16 +97,31 @@ class PullRequestsController < ApplicationController request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch, :target_project_id => target_project_id) @fork_project_name = Project.find(params[:target_project_id]).try(:name) @fork_pr_message = true if @fork_project_name - # 发送消息 - send_message(User.current.id, target_project_id, request.id) + # fork项目的pullrequest发送消息 + # 向管理员发送消息 + @project_member = Member.where(:project_id => params[:target_project_id].to_i) + unless @project_member.nil? + @project_member.each do |mem| + if is_project_manager?(mem.user_id, params[:target_project_id].to_i) && mem.user_id != User.current.id + send_message(mem.user_id, params[:target_project_id].to_i, request.id, 1) + end + end + end # 创建Trustie数据 - PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => target_project_id) + PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => target_project_id, :title => title) else + @project_member = Member.where(:project_id => @project.id) request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch) # 发送消息 - send_message(User.current.id, @project.id, request.id) + unless @project_member.nil? + @project_member.each do |mem| + if is_project_manager?(mem.user_id, @project.id) && mem.user_id != User.current.id + send_message(mem.user_id, @project.id, request.id, 1) + end + end + end # 创建Trustie数据 - PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => @project.id) + PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => @project.id, :title => title) respond_to do |format| format.js{redirect_to project_pull_request_path(request.id, :project_id => @project.id)} end @@ -180,6 +195,14 @@ class PullRequestsController < ApplicationController begin status = @g.accept_merge_rquest(@project.gpid, params[:id], User.current.gid) PullRequest.create(:pull_request_id => status.id, :user_id => User.current.id, :gpid => status.project_id) + + # 接受后,给用户发消息 + request = @g.merge_request(@project.gpid, params[:id]) + if User.current.login != request.author.try(:username) + message_user = User.where( :login => request.author.try(:username) ).first + send_message(message_user.id, @project.id, request.id, 2) + end + respond_to do |format| format.js{redirect_to project_pull_request_path(status.id, :project_id => @project.id)} end @@ -205,6 +228,25 @@ class PullRequestsController < ApplicationController def update_pull_request begin @g.update_merge_request(@project.gpid, params[:id], User.current.gid, :state_event => params[:state]) + + # 自己关闭/重新打开 就给每个管理员发送消息,如果是管理员关闭/重新打开,就给用户发消息 + request = @g.merge_request(@project.gpid, params[:id]) + @project_member = Member.where(:project_id => @project.id) + # 发送消息 + if ( params[:state] == "close" || params[:state] == "reopen" ) && User.current.login == request.author.try(:username) + unless @project_member.nil? + @project_member.each do |mem| + if is_project_manager?(mem.user_id, @project.id) && mem.user_id != User.current.id + send_message(mem.user_id, @project.id, request.id, params[:state] == "close" ? 4 : 3) + end + end + end + end + if ( params[:state] == "close" || params[:state] == "reopen" ) && User.current.login != request.author.try(:username) + message_user = User.where( :login => request.author.try(:username) ).first + send_message(message_user.id, @project.id, request.id, params[:state] == "close" ? 4 : 3) + end + respond_to do |format| format.html{redirect_to project_pull_request_path(params[:id], :project_id => @project.id)} end @@ -295,9 +337,9 @@ class PullRequestsController < ApplicationController end private - def send_message user_id, project_id, pull_request_id + def send_message user_id, project_id, pull_request_id, status ForgeMessage.create(:user_id => user_id, :project_id => project_id, - :forge_message_id => pull_request_id, :forge_message_type => "PullRequest", :viewed => true) + :forge_message_id => pull_request_id, :forge_message_type => "PullRequest", :viewed => true, :status => status) end def authorize_logged diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 14064c11f..98024954d 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -96,11 +96,11 @@ module UsersHelper when 1 "创建了PullRequest:" when 2 - "接受了您的PullRequest:" + "接受了PullRequest:" when 3 "重新打开了PullRequest:" when 4 - "关闭了您的PullRequest:" + "关闭了PullRequest:" end end diff --git a/app/models/pull_request.rb b/app/models/pull_request.rb index ec13ff16b..92f9b56a6 100644 --- a/app/models/pull_request.rb +++ b/app/models/pull_request.rb @@ -1,6 +1,6 @@ class PullRequest < ActiveRecord::Base # status 1:创建 2:接受 3:重新打开 4:关闭 - attr_accessible :gpid, :pull_request_id, :user_id, :status + attr_accessible :gpid, :pull_request_id, :user_id, :project_id, :title validates_uniqueness_of :pull_request_id has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 282df48c3..05b8d40d0 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -27,17 +27,17 @@ <% unless @entries.nil? %> ZIP下载 - <% if User.current.member_of?(@project) && @project.is_public? %> - <% if quality_analysis(User.current.try(:login), @repository.id).nil? %> - <%= link_to "质量分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch, :type => "1"), :remote => true, :class => "btn_zipdown fr" %> - <% else %> - <%= link_to "重新分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch, :type => "2"), :remote => true, :class => "btn_zipdown fr" %> - <% end %> - <% end %> - <% end %> - <% unless QualityAnalysis.where(:project_id => @project.id).first.nil? %> - <%= link_to "代码分析结果", project_quality_analysis_path(:project_id => @project.id), :class => "btn_zipdown fr" %> + <%# if User.current.member_of?(@project) && @project.is_public? %> + <%# if quality_analysis(User.current.try(:login), @repository.id).nil? %> + <%#= link_to "质量分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch, :type => "1"), :remote => true, :class => "btn_zipdown fr" %> + <%# else %> + <%#= link_to "重新分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch, :type => "2"), :remote => true, :class => "btn_zipdown fr" %> + <%# end %> + <%# end %> <% end %> + <%# unless QualityAnalysis.where(:project_id => @project.id).first.nil? %> + <%#= link_to "代码分析结果", project_quality_analysis_path(:project_id => @project.id), :class => "btn_zipdown fr" %> + <%# end %>
    <%=link_to "代码统计", stats_repository_project_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :creator => @creator, :default_branch => @g_default_branch ), :class => "fl vl_zip" %> diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index b1936e19b..f43b87360 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -304,7 +304,7 @@
  • - <%=link_to User.find(ma.course_message.user).show_name, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> + <%=link_to ma.course_message.user.show_name, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> ">发布了问卷:
  • @@ -327,7 +327,7 @@
  • - <%=link_to User.find(ma.course_message.author).show_name, user_path(ma.course_message.author), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> + <%=link_to User.find(ma.course_message.author_id).show_name, user_path(ma.course_message.author), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> "> <%= ma.course_message.parent_id.nil? ? "发布了班级帖子:" : "评论了班级帖子:" %>
  • <% if ma.course_message.parent_id.nil? %> @@ -423,7 +423,7 @@
  • - <%= link_to User.find(ma.course_message.user).show_name, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> + <%= link_to ma.course_message.user.show_name, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> ">在班级中留言了:
  • @@ -447,7 +447,7 @@
  • - <%= link_to User.find(ma.course_message.user).show_name, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> + <%= link_to ma.course_message.user.show_name, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> "> <% if ma.course_message.m_parent_id.nil? %> 回复了您的作业: diff --git a/app/views/users/_user_message_forge.html.erb b/app/views/users/_user_message_forge.html.erb index c28c40065..b32e7bcb4 100644 --- a/app/views/users/_user_message_forge.html.erb +++ b/app/views/users/_user_message_forge.html.erb @@ -162,7 +162,7 @@ <% if ma.forge_message_type == "Message" %> <% end %> - <% if ma.forge_message_type == "PullRequest" && is_project_manager?( User.current.id, ma.forge_message.project_id) %> + <% if ma.forge_message_type == "PullRequest" %>
    • - <%=link_to image_tag(url_to_avatar(ma.forge_message.author), :width => "30", :height => "30"), user_path(ma.forge_message.author), :target => '_blank' %> + <% send_message_user = PullRequest.where(:pull_request_id => ma.forge_message_id) %> + <% author = User.find(send_message_user[0].user_id) %> + <%= link_to image_tag(url_to_avatar(author), :width => "30", :height => "30"), user_path(author), :target => '_blank' %>
    • - <%=link_to User.find(ma.forge_message.author).show_name, user_path(ma.forge_message.author), - :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> + <%= link_to User.find(send_message_user[0].user_id).show_name, user_path(send_message_user[0].user_id), + :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> "> <%= pull_request_message_status(ma) %>
    • - <%= link_to "#{ma.forge_message.forge_message_id.title}", {:controller => 'pull_requests', :action => 'show', :id => ma.forge_message.project_id }, + <%= link_to "#{send_message_user[0].title}", project_pull_requests_path(ma.project_id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
    • diff --git a/db/migrate/20161129032534_add_status_to_pull_requests.rb b/db/migrate/20161129032534_add_status_to_pull_requests.rb deleted file mode 100644 index a8ad71125..000000000 --- a/db/migrate/20161129032534_add_status_to_pull_requests.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddStatusToPullRequests < ActiveRecord::Migration - def change - add_column :pull_requests, :status, :integer, :default => false - end -end diff --git a/db/migrate/20161130031415_add_titil_to_pull_requsts.rb b/db/migrate/20161130031415_add_titil_to_pull_requsts.rb new file mode 100644 index 000000000..cc3ce3fef --- /dev/null +++ b/db/migrate/20161130031415_add_titil_to_pull_requsts.rb @@ -0,0 +1,5 @@ +class AddTitilToPullRequsts < ActiveRecord::Migration + def change + add_column :pull_requests, :title, :string + end +end From 233ce0428b33d9085139d9cb83e7b225bfa92062 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 1 Dec 2016 13:55:15 +0800 Subject: [PATCH 05/28] =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E7=94=A8=E6=88=B7=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_message_course.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index f43b87360..49e78521c 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -7,7 +7,7 @@
    • - <%=link_to ma.course_message.author, user_path(ma.course_message.author), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> + <%=link_to ma.course_message.author.show_name, user_path(ma.course_message.author), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> ">发布了通知:
    • From c33bf1b1637096d6a65f8aed3a694280c58f1573 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 1 Dec 2016 15:42:07 +0800 Subject: [PATCH 06/28] =?UTF-8?q?=E6=B5=8B=E9=AA=8C=E5=A4=B4=E9=83=A8?= =?UTF-8?q?=E5=92=8C=E6=96=B0=E5=BB=BA=E9=A2=98=E7=9B=AE=E7=9A=84=E6=94=B9?= =?UTF-8?q?=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 4 +- app/helpers/exercise_helper.rb | 39 +++++++++ app/views/exercise/_edit_head.html.erb | 14 ++-- app/views/exercise/_exercise_form.html.erb | 61 +++++++++++--- app/views/exercise/_new_MC.html.erb | 80 +++++++++---------- app/views/exercise/_new_MCQ.html.erb | 53 ++++++------ app/views/exercise/_new_question.html.erb | 6 +- app/views/exercise/_new_single.html.erb | 16 ++-- app/views/exercise/_show_head.html.erb | 9 ++- .../20161129084352_add_column_to_exercises.rb | 6 ++ db/schema.rb | 8 +- public/stylesheets/css/courses.css | 7 ++ 12 files changed, 201 insertions(+), 102 deletions(-) create mode 100644 db/migrate/20161129084352_add_column_to_exercises.rb diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 02a8400a7..02ee909b7 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -132,7 +132,9 @@ class ExerciseController < ApplicationController @exercise.time = params[:exercise][:time].blank? ? -1 : params[:exercise][:time] @exercise.end_time = Time.at(params[:exercise][:end_time].to_time.to_i + 16*60*60 -1) @exercise.publish_time = params[:exercise][:publish_time] - @exercise.show_result = params[:exercise][:show_result].blank? ? 1 : params[:exercise][:show_result] + @exercise.show_result = params[:show_result].blank? ? 1 : params[:show_result] + @exercise.question_random = params[:question_random] + @exercise.choice_random = params[:choice_random] if @exercise.save respond_to do |format| format.js diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index 6dadf92b5..47fccefff 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -175,4 +175,43 @@ module ExerciseHelper standard_answer end + # 问题随机的下拉列表 + def question_random_select + type = [] + option1 = [] + option1 << "题目不随机打乱" + option1 << 0 + type << option1 + option2 = [] + option2 << "题目随机打乱" + option2 << 1 + type << option2 + end + + # 选项随机的下拉列表 + def choice_random_select + type = [] + option1 = [] + option1 << "选项不随机打乱" + option1 << 0 + type << option1 + option2 = [] + option2 << "选项随机打乱" + option2 << 1 + type << option2 + end + + #允许学生查看结果的下拉列表 + def show_result_select + type = [] + option1 = [] + option1 << "允许学生查看测验结果" + option1 << 1 + type << option1 + option2 = [] + option2 << "不允许学生查看测验结果" + option2 << 0 + type << option2 + end + end \ No newline at end of file diff --git a/app/views/exercise/_edit_head.html.erb b/app/views/exercise/_edit_head.html.erb index a071904ce..e23f3134a 100644 --- a/app/views/exercise/_edit_head.html.erb +++ b/app/views/exercise/_edit_head.html.erb @@ -16,13 +16,13 @@
  • - diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index cb41cf26b..c2c01ac25 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -168,17 +168,55 @@ $("#edit_poll_questions_"+question_id).show(); $("#poll_questions_title_"+question_id).focus(); } - //单选题 - function add_single_answer(doc) - { - var li = doc.parent().after("
  • " + - ""+ - "
  • "); - var select_items =$("label[name='select_items']",li.parent()); - for(var i=0; i:   "); + // 选项的选择 + function toggle_select(doc, type){ + if(doc.hasClass("question_choice_blue")){ + doc.removeClass("question_choice_blue").addClass("question_choice_white"); + if(type == "1"){ + $("#question_standard_answer").html("请点击选项"); + $("#exercise_choice").val(""); + }else{ + var eles = doc.parent().parent().find("a.question_choice_blue"); + var str = ""; + if(eles.length > 0){ + for(var i=0; i" + + ""+ + "
    "); + var select_items =$("li.new_answer",li.parent()); + li.prev().prev().find("a.question_choice_white").html(String.fromCharCode(64 + select_items.length)); + doc.prev("a.question_choice_dash").html(String.fromCharCode(64 + select_items.length + 1)); + } function add_candidate_answer(doc) { doc.parent().after("
  • " + @@ -214,10 +252,11 @@ { var parent = doc.parent().parent(); doc.parent().remove(); - var select_items =$("label[name='select_items']",parent); + + var select_items =$("li.ur_item",parent); var candiate_items =$("label[name='candiate_items']",parent); for(var i=0; i:   "); + $(select_items[i]).find("a.choice_btn").html(String.fromCharCode(64 + parseInt(i+1))); } for(var i=0; i:   "); diff --git a/app/views/exercise/_new_MC.html.erb b/app/views/exercise/_new_MC.html.erb index 054285825..6ebf3bd40 100644 --- a/app/views/exercise/_new_MC.html.erb +++ b/app/views/exercise/_new_MC.html.erb @@ -3,6 +3,14 @@ :url=>create_exercise_question_exercise_path(exercise.id), :remote=>true ) do |f| %>
    +
    + <% score = exercise.exercise_questions.where("question_type=1").last.nil? ? "": exercise.exercise_questions.where("question_type=1").last.question_score %> + + 分 + 请点击选项 + 标准答案: +
    +
    @@ -10,52 +18,44 @@
      -
    • - <% score = exercise.exercise_questions.where("question_type=1").last.nil? ? "": exercise.exercise_questions.where("question_type=1").last.question_score %> - - 分 -
    • -
      -
    • - - - - -
    • -
      -
    • - - - - -
    • -
      -
    • - - - - -
    • -
      -
    • - - - - -
    • + +
    • + A + + +
    • +
      +
    • + B + + +
    • +
      +
    • + C + + +
    • +
      +
    • + D + + +
    • +
      +
    • + E +
      新建选项
      +
    • +
      -
    • - - -
    • -
    diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb index d8dbf0adb..965772051 100644 --- a/app/views/exercise/_new_MCQ.html.erb +++ b/app/views/exercise/_new_MCQ.html.erb @@ -3,6 +3,14 @@ :url=>create_exercise_question_exercise_path(exercise.id), :remote=>true ) do |f| %>
    +
    + <% score = exercise.exercise_questions.where("question_type=2").last.nil? ? "": exercise.exercise_questions.where("question_type=2").last.question_score %> + + 分 + 请点击选项 + 标准答案: +
    +
    @@ -10,52 +18,43 @@
      -
    • - <% score = exercise.exercise_questions.where("question_type=2").last.nil? ? "": exercise.exercise_questions.where("question_type=2").last.question_score %> - - 分 -
    • -
      -
    • - - - + +
    • + A +
    • -
    • - - - +
    • + B +
    • -
    • - - - +
    • + C +
    • -
    • - - - +
    • + D +
    • - - + E +
      新建选项
    • -
      +
    diff --git a/app/views/exercise/_new_question.html.erb b/app/views/exercise/_new_question.html.erb index faadb08a9..23aae4cb3 100644 --- a/app/views/exercise/_new_question.html.erb +++ b/app/views/exercise/_new_question.html.erb @@ -14,7 +14,7 @@ alert("请先保存正在编辑的题目再新建。"); } else{ $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MC', :locals => {:exercise=>exercise}) %>"); - $("#poll_questions_title").focus(); + $("#question_score").focus(); } } @@ -26,7 +26,7 @@ alert("请先保存正在编辑的题目再新建。"); } else{ $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MCQ', :locals => {:exercise=>exercise}) %>"); - $("#poll_questions_title").focus(); + $("#question_score").focus(); } } @@ -38,7 +38,7 @@ alert("请先保存正在编辑的题目再新建。"); } else{ $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_single', :locals => {:exercise=>exercise}) %>"); - $("#poll_questions_title").focus(); + $("#question_score").focus(); } } diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index d0fce87c8..669a1b8db 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -3,6 +3,12 @@ :url=>create_exercise_question_exercise_path(exercise.id), :remote=>true ) do |f| %>
    +
    + <% score = exercise.exercise_questions.where("question_type=3").last.nil? ? "": exercise.exercise_questions.where("question_type=3").last.question_score %> + + 分 +
    +
    @@ -10,12 +16,6 @@
      -
    • - <% score = exercise.exercise_questions.where("question_type=3").last.nil? ? "": exercise.exercise_questions.where("question_type=3").last.question_score %> - - 分 -
    • -
    • @@ -42,8 +42,8 @@
    diff --git a/app/views/exercise/_show_head.html.erb b/app/views/exercise/_show_head.html.erb index 4cc5a6cf8..b59eb11c7 100644 --- a/app/views/exercise/_show_head.html.erb +++ b/app/views/exercise/_show_head.html.erb @@ -1,5 +1,5 @@ -
    - +
    +

    <%= exercise.exercise_name%>

    @@ -12,5 +12,10 @@ <% end %>
    <%= exercise.exercise_description.nil? ? "" :exercise.exercise_description.html_safe%>
    +
    \ No newline at end of file diff --git a/db/migrate/20161129084352_add_column_to_exercises.rb b/db/migrate/20161129084352_add_column_to_exercises.rb new file mode 100644 index 000000000..ea3d01667 --- /dev/null +++ b/db/migrate/20161129084352_add_column_to_exercises.rb @@ -0,0 +1,6 @@ +class AddColumnToExercises < ActiveRecord::Migration + def change + add_column :exercises, :question_random, :integer, :default => 0 + add_column :exercises, :choice_random, :integer, :default => 0 + end +end diff --git a/db/schema.rb b/db/schema.rb index bd3645e2c..9109f785d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20161128072528) do +ActiveRecord::Schema.define(:version => 20161129084352) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -820,11 +820,13 @@ ActiveRecord::Schema.define(:version => 20161128072528) do t.integer "exercise_status" t.integer "user_id" t.integer "time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.datetime "publish_time" t.datetime "end_time" t.integer "show_result" + t.integer "question_random", :default => 0 + t.integer "choice_random", :default => 0 end create_table "first_pages", :force => true do |t| diff --git a/public/stylesheets/css/courses.css b/public/stylesheets/css/courses.css index 91a22a177..7ea9346cc 100644 --- a/public/stylesheets/css/courses.css +++ b/public/stylesheets/css/courses.css @@ -604,3 +604,10 @@ a:hover.ex_icon_edit{ background:url(/images/course/icons.png) -21px -276px no- .archive_course_notice {width:220px; position:absolute; padding:5px 10px; white-space:nowrap; background-color:#fff; right:-265px; top:-15px; box-shadow:0px 2px 8px rgba(146, 153, 169, 0.5);} .archive_course_notice em {display:block; border-width:10px; position:absolute;top:26px; left:-20px; border-style:dashed solid dashed dashed; border-color:transparent #eaeaea transparent transparent; font-size:0; line-height:0;} .archive_course_notice span {display:block; border-width:10px; position:absolute;top:26px; left:-18px; border-style:dashed solid dashed dashed; border-color:transparent #fff transparent transparent; font-size:0; line-height:0;} + +/* 新版测验 */ +.blue_select{ background: #3b94d6; font-size: 12px; color: #fff; padding: 5px 10px;} +.grey_select{ background: #c3c3c3; font-size: 12px; color: #fff; padding: 5px 10px;} +a.question_choice_white{ background: #fff; color: #000000; width: 34px; height: 30px; border: 1px solid #ddd; text-align: center; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} +a.question_choice_blue{ background: #3b94d6; color: #fff; width: 34px; height: 30px; border: 1px solid #ddd; text-align: center; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} +.question_choice_dash{ background: #fff; color: #000000; width: 34px; height: 30px; border: 1px dashed #ddd; text-align: center; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} \ No newline at end of file From c745f69e95d83f457bd3c1b57d8deff51124c638 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 1 Dec 2016 15:44:15 +0800 Subject: [PATCH 07/28] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=88=90=E5=91=98?= =?UTF-8?q?=E5=88=97=E8=A1=A8=EF=BC=8Cfork=E5=88=97=E8=A1=A8=EF=BC=8C?= =?UTF-8?q?=E5=85=B3=E6=B3=A8=E5=88=97=E8=A1=A8=E6=A0=B7=E5=BC=8F=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E3=80=82=E5=B9=B6=E4=BF=AE=E6=94=B9=E5=B0=8F=E9=93=83?= =?UTF-8?q?=E9=93=9B=E6=B6=88=E6=81=AF=E7=9A=84=E7=8F=AD=E7=BA=A7=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E7=9A=84=E7=94=B3=E8=AF=B7=E6=96=87=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 8 ++++---- app/views/issues/_statistics.html.erb | 2 +- app/views/projects/member_forked.html.erb | 5 ++++- app/views/projects/project_watcherlist.html.erb | 4 ++++ app/views/users/_join_course_course_message.html.erb | 6 +++--- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index b9d61e61e..dcd337df2 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -543,12 +543,12 @@ class ProjectsController < ApplicationController @users -= watched.watcher_users if @watched end @watchers = @project.watcher_users - @limit = 20 + @limit = 32 @is_remote = true @watchers_count = @watchers.count @watcher_pages = Paginator.new @watchers_count, @limit, params['page'] || 1 @offset ||= @watcher_pages.offset - @watchers = paginateHelper @watchers, 20 + @watchers = paginateHelper @watchers, @limit end end @@ -611,14 +611,14 @@ class ProjectsController < ApplicationController @applied_members = appied_project_members(@project, @members) end end - @members = paginateHelper @members + @members = paginateHelper @members, 32 end def member_forked @forked_projects = Project.where(:forked_from_project_id => @project.id) - @limit = 20 + @limit = 32 @is_remote = true @forked_count = @forked_projects.count @forked_pages = Paginator.new @forked_count, @limit, params['page'] || 1 diff --git a/app/views/issues/_statistics.html.erb b/app/views/issues/_statistics.html.erb index 8b1fc6f22..d284aabb4 100644 --- a/app/views/issues/_statistics.html.erb +++ b/app/views/issues/_statistics.html.erb @@ -4,7 +4,7 @@
    -
      +
      • <%= link_to "所有#{@issues_filter.count}".html_safe, "", :remote => true, :class => "new_roadmap_type_nomal", :id => "new_roadmap_type_1", :id => "new_roadmap_type_1" %>
      • diff --git a/app/views/projects/member_forked.html.erb b/app/views/projects/member_forked.html.erb index 668feef98..b3cfad1d4 100644 --- a/app/views/projects/member_forked.html.erb +++ b/app/views/projects/member_forked.html.erb @@ -1,3 +1,4 @@ +<% if @forked_count > 0 %>

        成员本页面展示Fork了 <%= link_to @project.owner.try(:show_name), user_path(@project.owner) %>/<%= link_to @project.name, project_path(@project) %> 的用户

          @@ -24,4 +25,6 @@
    - +<% else %> + <%= render :partial => "projects/no_data" %> +<% end %> diff --git a/app/views/projects/project_watcherlist.html.erb b/app/views/projects/project_watcherlist.html.erb index 440975e68..c421f4f81 100644 --- a/app/views/projects/project_watcherlist.html.erb +++ b/app/views/projects/project_watcherlist.html.erb @@ -1,3 +1,4 @@ +<% if @watchers.count > 0 %>

    成员 本页面展示关注了 <%= link_to @project.owner.try(:show_name), user_path(@project.owner) %>/<%= link_to @project.name, project_path(@project) %> 的用户

      @@ -24,6 +25,9 @@
    +<% else %> + <%= render :partial => "projects/no_data" %> +<% end %> diff --git a/app/views/users/_join_course_course_message.html.erb b/app/views/users/_join_course_course_message.html.erb index c69d66ad0..eacbfac8c 100644 --- a/app/views/users/_join_course_course_message.html.erb +++ b/app/views/users/_join_course_course_message.html.erb @@ -1,11 +1,11 @@
  • 系统提示 - ">您有了新的课程成员申请: + ">您有了新的班级成员申请:
  • - <% content = User.find(ma.course_message_id).name+"申请成为课程\""+"#{Course.find(ma.course_id).name}"+"\"的"+"#{ma.content && ma.content.include?('9') ? "教师" : "教辅"}" %> + <% content = User.find(ma.course_message_id).name+"申请成为课程\""+"#{Course.find(ma.course_id).name}"+"\"的"+"#{ma.content && ma.content.include?('9') ? "教师" : "助教"}" %> <%= link_to content, user_path(User.find(ma.course_message_id), :course_id => ma.course_id), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :target => '_blank', :title => "#{content}" %> @@ -14,7 +14,7 @@
  • + <% if @tip_all_attachments > 0 %>

    <%= render :partial => "files/tip_attachment_count" %> @@ -124,5 +125,8 @@

    <%= render :partial => 'project_list',:locals => {project: @project, all_attachments: @all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments} %>
    + <% else %> + <%= render :partial => "projects/no_data" %> + <% end %>
    <%# html_title(l(:label_attachment_plural)) -%> \ No newline at end of file diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index a9f70f999..aa51842aa 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -214,6 +214,9 @@
    新建 + <% if @issues.empty? %> + <%= render :partial => "projects/no_data" %> + <% else %> <% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %> <%= form_tag({:controller => 'issues', :action => 'index', :project_id => @project},:remote=>'xls', :method => :get,:id=>"issue_query_form", :class => 'query_form') do %> <%= hidden_field_tag 'set_filter', '1' %> @@ -236,7 +239,6 @@ <%= calendar_for('issue_create_date_start_show')%> -
    • @@ -309,9 +311,7 @@
    <% end %> <% end %> -<% if @issues.empty? %> -

    <%= l(:label_no_data) %>

    -<% else %> +
    <%= render :partial => 'issues/all_list', :locals => {:issues => @issues, :query => @query,:issue_pages=>@issue_pages,:issue_count=>@issue_count,:project=>@project,:subject=>@subject} %>
    diff --git a/app/views/projects/_no_data.html.erb b/app/views/projects/_no_data.html.erb index 249a67af0..bc8b97547 100644 --- a/app/views/projects/_no_data.html.erb +++ b/app/views/projects/_no_data.html.erb @@ -1,4 +1,4 @@ -
    +

    没有数据可供显示!

    \ No newline at end of file diff --git a/app/views/projects/member_forked.html.erb b/app/views/projects/member_forked.html.erb index b3cfad1d4..d5dba7ae2 100644 --- a/app/views/projects/member_forked.html.erb +++ b/app/views/projects/member_forked.html.erb @@ -26,5 +26,7 @@
    <% else %> +
    <%= render :partial => "projects/no_data" %> +
    <% end %> diff --git a/app/views/projects/project_watcherlist.html.erb b/app/views/projects/project_watcherlist.html.erb index c421f4f81..1c97e2855 100644 --- a/app/views/projects/project_watcherlist.html.erb +++ b/app/views/projects/project_watcherlist.html.erb @@ -26,7 +26,9 @@
    <% else %> +
    <%= render :partial => "projects/no_data" %> +
    <% end %> diff --git a/app/views/pull_requests/index.html.erb b/app/views/pull_requests/index.html.erb index f2591b6ea..4053e6739 100644 --- a/app/views/pull_requests/index.html.erb +++ b/app/views/pull_requests/index.html.erb @@ -62,6 +62,8 @@ <% else %> +
    <%= render :partial => "projects/no_data" %> +
    <% end %> diff --git a/app/views/users/_project_boardlist.html.erb b/app/views/users/_project_boardlist.html.erb index dbc0b3992..c18b003d2 100644 --- a/app/views/users/_project_boardlist.html.erb +++ b/app/views/users/_project_boardlist.html.erb @@ -2,6 +2,7 @@

    讨论区列表

    + <% if topics.any? %>
    排序: <%= link_to "时间", {:controller => 'boards', :action => 'index', :type => @type, :sort => @b_sort, :order => 1 }, :class => "sortTxt", :remote => true %> @@ -15,7 +16,6 @@
    - <% if topics.any? %> <% topics.each do |activity| %>
    @@ -59,11 +59,11 @@
    - <% else %> -

    <%= l(:label_no_data) %>

    - <% end %>
    + <% else %> + <%= render :partial => "projects/no_data" %> + <% end %>