From 5c4e4e7c8ad2190c35595ba914ef78c2b24472ef Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 7 Jul 2016 16:55:34 +0800 Subject: [PATCH 01/99] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=8F=AD=E7=BA=A7=E5=90=8E=E5=86=8D=E5=88=A0=E9=99=A4=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=EF=BC=8C=E6=8F=90=E7=A4=BA=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/syllabuses/_delete_syllabus.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/syllabuses/_delete_syllabus.html.erb b/app/views/syllabuses/_delete_syllabus.html.erb index fbc0a0995..b043186aa 100644 --- a/app/views/syllabuses/_delete_syllabus.html.erb +++ b/app/views/syllabuses/_delete_syllabus.html.erb @@ -1,6 +1,6 @@
- <% if @syllabus.courses.empty? %> + <% if @syllabus.courses.empty? || @syllabus.courses.not_deleted.empty? %> 确认删除该课程吗? <% else %> 该课程下已经存在班级,不能删除。 @@ -8,7 +8,7 @@

- <% if @syllabus.courses.empty? %> + <% if @syllabus.courses.empty?|| @syllabus.courses.not_deleted.empty? %> <%=link_to '确认', syllabus_path(@syllabus), :class => 'Blue-btn fl', :method => 'delete'%> 关闭 <% else %> From 41fc812ca4444ad8b8d3756b935d76960385dd02 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 7 Jul 2016 17:34:38 +0800 Subject: [PATCH 02/99] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=8F=AD=E7=BA=A7?= =?UTF-8?q?=E9=85=8D=E7=BD=AE--=E6=B7=BB=E5=8A=A0=E6=88=90=E5=91=98?= =?UTF-8?q?=EF=BC=9A=E7=94=A8=E6=88=B7=E5=90=8D=E7=A7=B0=E5=A4=AA=E9=95=BF?= =?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/views/courses/_member.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/courses/_member.html.erb b/app/views/courses/_member.html.erb index 1bfe3cbd7..95177c92c 100644 --- a/app/views/courses/_member.html.erb +++ b/app/views/courses/_member.html.erb @@ -1,7 +1,7 @@ <% @members.each do |member| %>
  • <%#= link_to_user_header member.principal,true,:class => "w150 c_orange fl" %> - <%= link_to "#{member.principal}(#{member.principal.show_name})", user_path(member.principal), :class => "w150 linkBlue fl" %> + <%= link_to "#{member.principal}(#{member.principal.show_name})", user_path(member.principal), :class => "w150 linkBlue fl", :style=>"white-space: nowrap;overflow: hidden;text-overflow: ellipsis;", :title => "#{member.principal}(#{member.principal.show_name})" %> <%= zh_course_role(h member.roles.sort.collect(&:to_s).join(', ')) %> <%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member), From 00d59a55961924b64f857739b17f455b377108cc Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 11 Jul 2016 15:47:33 +0800 Subject: [PATCH 03/99] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=9D=90=E4=B8=8B=E4=B8=8B=EF=BC=8C=E6=8F=90=E7=A4=BA=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E7=9A=84=E8=A1=A8=E8=BE=BE=E5=BD=A2=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/_show.html.erb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb index 484e8eb0e..cfc5c42ad 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -59,9 +59,14 @@
  • 内容: -
    - <%= work.description.html_safe if work.description%> -
    + <% com_contents = work.work_status %> + <% if com_contents != 0 && work.description %> +
    + <%= work.description.html_safe if work.description%> +
    + <% else %> + 该作品未在线下完成提交 + <% end %>
  • From 97599849ee6d76e960a5a40b4207f68ae6212353 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 11 Jul 2016 16:03:45 +0800 Subject: [PATCH 04/99] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E4=B8=AD=E4=BD=9C=E5=93=81=E4=B8=8B=E5=86=85=E5=AE=B9=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/_show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb index cfc5c42ad..039baa386 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -62,7 +62,7 @@ <% com_contents = work.work_status %> <% if com_contents != 0 && work.description %>
    - <%= work.description.html_safe if work.description%> + <%= work.description.html_safe %>
    <% else %> 该作品未在线下完成提交 From 304f18ac5e179d76b81192cb86b83da2c2cbdddf Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 12 Jul 2016 15:05:42 +0800 Subject: [PATCH 05/99] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E4=B8=AD=EF=BC=8C=E5=AF=B9=E5=8A=A8=E6=80=81=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E7=9A=84=E9=A1=B5=E9=9D=A2=E5=91=88=E7=8E=B0?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/show.html.erb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index b9d97e18a..cabbb5d04 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -9,7 +9,23 @@
    -
    班级动态
    +
    班级动态 + <% if params[:type] == "homework" %> + <%= ">作业动态" %> + <% elsif params[:type] == "news" %> + <%= ">通知动态" %> + <% elsif params[:type] == "attachment" %> + <%= ">资源库动态" %> + <% elsif params[:type] == "message" %> + <%= ">论坛动态" %> + <% elsif params[:type] == "journalsForMessage" %> + <%= ">留言动态" %> + <% elsif params[:type] == "poll" %> + <%= ">问卷动态" %> + <% else %> + <%= ">全部动态" %> + <% end %> +
      • From dcc37ef847c52769b93526506f5a144632e39f8a Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 13 Jul 2016 16:58:31 +0800 Subject: [PATCH 06/99] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E7=95=8C=E9=9D=A2=E4=B8=AD=EF=BC=8C=E7=8F=AD?= =?UTF-8?q?=E7=BA=A7=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6=E4=B8=8B=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9A=82=E6=97=A0=E5=88=86=E7=8F=AD=E7=9A=84?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 22 ++++++++++++++++------ app/helpers/student_work_helper.rb | 4 ++++ config/locales/zh.yml | 1 + 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 4c3a608de..1d0b80f70 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -381,14 +381,24 @@ class StudentWorkController < ApplicationController @is_evaluation = @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status == 2 && !@is_teacher #是不是匿评 @show_all = false - course_group = CourseGroup.find_by_id(@group) if @group - if course_group - group_students = course_group.users - if group_students.empty? - student_in_group = '(0)' + if @group + if @group == "0" + none_group_students = @course.members.select{ |member| member.course_group_id == 0 } + if none_group_students.empty? + student_in_group = '(0)' + else + student_in_group = '(' + none_group_students.map{ |member| member.user_id }.join(',') + ')' + end else - student_in_group = '(' + group_students.map{|user| user.id}.join(',') + ')' + course_group = CourseGroup.find_by_id(@group) + group_students = course_group.users + if group_students.empty? + student_in_group = '(0)' + else + student_in_group = '(' + group_students.map{ |user| user.id }.join(',') + ')' + end end + #开放作品 || 老师 || 超级管理员 || 禁用匿评&&作业截止&&已提交作品 显示所有列表 if (@homework.is_open == 1 && @course.is_public == 1) || (@homework.is_open == 1 && @course.is_public == 0 && User.current.member_of_course?(@course)) || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.has_committed.where(:user_id => User.current.id).empty?) if @order == 'lastname' diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb index 42a3a6538..4f0a2ca6d 100644 --- a/app/helpers/student_work_helper.rb +++ b/app/helpers/student_work_helper.rb @@ -101,6 +101,10 @@ module StudentWorkHelper if course.course_groups && !course.course_groups.empty? base = [] base << l(:label_chose_group) + base << -1 + result << base + base = [] + base << l(:label_no_group) base << 0 result << base course.course_groups.each do |group| diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 9c19fcbbb..dbb3ff074 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2101,6 +2101,7 @@ zh: label_file_lost_list: 缺失文件列表 lable_unset: 未设置 label_chose_group: 请选择分班 + label_no_group: 暂无 label_hostedz_organization: 主办单位 label_hosted_by: 国防科学技术大学并行与分布处理国家重点实验室 From 7fe3f9fe716aa3509ccf2eac9a65eb1252a1ca76 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 15 Jul 2016 20:30:50 +0800 Subject: [PATCH 07/99] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/wechat.yml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/config/wechat.yml b/config/wechat.yml index d839f1606..6b3799706 100644 --- a/config/wechat.yml +++ b/config/wechat.yml @@ -20,26 +20,26 @@ default: &default encrypt_mode: false # if true must fill encoding_aes_key #production - encoding_aes_key: "QGfP13YP4BbQGkkrlYuxpn4ZIDXpBJww4fxl8CObvNw" - jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket" - - #template - binding_succ_notice: "jjpDrgFErnmkrE9tf2M3o0t31ZrJ7mr0YtuE_wyLaMc" - journal_notice: "uC1zAw4F2q6HTA3Pcj8VUO6wKKKiYFwnPJB4iXxpdoM" - homework_message_notice: "tCf7teCVqc2vl2LZ_hppIdWmpg8yLcrI8XifxYePjps" - class_notice: "MQ_mFupbXP-9jWbeHT3C5xqNBvPo8EIlNv4ULakSpJA" - create_class_notice: "2GtJJGzzNlNy2i0UrsjEDlvfSVIUXQfSo47stpcQAVw" - - #test -# encoding_aes_key: "QyocNOkRmrT5HzBpCG54EVPUQjk86nJapXNVDQm6Yy6" +# encoding_aes_key: "QGfP13YP4BbQGkkrlYuxpn4ZIDXpBJww4fxl8CObvNw" # jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket" # # #template -# binding_succ_notice: "n4KLwcWNrIMYkKxWL2hUwzunm5RTT54EbWem2MIUapU" -# journal_notice: "XpHHYkqSGkwuF9vHthRdmPQLvCFRQ4_NbRBP12T7ciE" -# homework_message_notice: "Kom0TsYYKsNKCS6luweYVRo9z-mH0wRPr24b1clGCPQ" -# class_notice: "8LVu33l6bP-56SDomVgHn-yJc57YpCwwJ81rAJgRONk" -# create_class_notice: "9CDIvHIKiGwPEQWRw_-wieec1o50tMXQPPZIfECKu0I" +# binding_succ_notice: "jjpDrgFErnmkrE9tf2M3o0t31ZrJ7mr0YtuE_wyLaMc" +# journal_notice: "uC1zAw4F2q6HTA3Pcj8VUO6wKKKiYFwnPJB4iXxpdoM" +# homework_message_notice: "tCf7teCVqc2vl2LZ_hppIdWmpg8yLcrI8XifxYePjps" +# class_notice: "MQ_mFupbXP-9jWbeHT3C5xqNBvPo8EIlNv4ULakSpJA" +# create_class_notice: "2GtJJGzzNlNy2i0UrsjEDlvfSVIUXQfSo47stpcQAVw" + + #test + encoding_aes_key: "QyocNOkRmrT5HzBpCG54EVPUQjk86nJapXNVDQm6Yy6" + jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket" + + #template + binding_succ_notice: "n4KLwcWNrIMYkKxWL2hUwzunm5RTT54EbWem2MIUapU" + journal_notice: "XpHHYkqSGkwuF9vHthRdmPQLvCFRQ4_NbRBP12T7ciE" + homework_message_notice: "Kom0TsYYKsNKCS6luweYVRo9z-mH0wRPr24b1clGCPQ" + class_notice: "8LVu33l6bP-56SDomVgHn-yJc57YpCwwJ81rAJgRONk" + create_class_notice: "9CDIvHIKiGwPEQWRw_-wieec1o50tMXQPPZIfECKu0I" production: <<: *default From 51692eadd619f6ffbd5ebab9890916c425134806 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sun, 17 Jul 2016 00:49:35 +0800 Subject: [PATCH 08/99] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E4=B8=8A=E7=BA=BF?= =?UTF-8?q?=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/wechats_helper.rb | 20 +++++++++ app/views/wechats/user_activities.html.erb | 28 +----------- config/application.rb | 5 ++- lib/tasks/wechat.rake | 31 +++++++++++++ public/javascripts/wechat/build/app.min.js | 51 ++++++++++++++++------ 5 files changed, 95 insertions(+), 40 deletions(-) create mode 100644 app/helpers/wechats_helper.rb create mode 100644 lib/tasks/wechat.rake diff --git a/app/helpers/wechats_helper.rb b/app/helpers/wechats_helper.rb new file mode 100644 index 000000000..5c6b3da8c --- /dev/null +++ b/app/helpers/wechats_helper.rb @@ -0,0 +1,20 @@ +#coding=utf-8 +# + +module WechatsHelper + def include_wechat_jsfile + if Rails.env.production? + javascript_include_tag '/javascripts/wechat/build/app.min.js' + else + wechat_path = File.join(Rails.root, "public", "javascripts", "wechat") + srcs = Rails.application.config.wechat_srcs + paths = [] + srcs.each do |src| + Dir.glob(wechat_path+ "/#{src}" ) do |path| + paths << path[File.join(Rails.root, "public").to_s.size, path.size] + end + end + javascript_include_tag *paths + end + end +end diff --git a/app/views/wechats/user_activities.html.erb b/app/views/wechats/user_activities.html.erb index 6c3da9cf4..d21449648 100644 --- a/app/views/wechats/user_activities.html.erb +++ b/app/views/wechats/user_activities.html.erb @@ -10,7 +10,7 @@ - + <%= stylesheet_link_tag '/stylesheets/weui/weixin.css' %> - - - - - - - - - - - - - - - - - - - - - - - - - +<%= include_wechat_jsfile %> diff --git a/config/application.rb b/config/application.rb index 6f5542a1e..3885751f7 100644 --- a/config/application.rb +++ b/config/application.rb @@ -66,6 +66,7 @@ module RedmineApp # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' + config.assets.digest = true config.action_mailer.perform_deliveries = false @@ -82,6 +83,8 @@ module RedmineApp end end + config.wechat_srcs = ['app.js','others/factory.js','others/filter.js', 'controllers/*.js', 'directives/*.js', 'others/routes.js'] + config.before_initialize do end @@ -93,4 +96,4 @@ module RedmineApp end end -end \ No newline at end of file +end diff --git a/lib/tasks/wechat.rake b/lib/tasks/wechat.rake new file mode 100644 index 000000000..bbba9994c --- /dev/null +++ b/lib/tasks/wechat.rake @@ -0,0 +1,31 @@ +#coding=utf-8 +# + +def compress(srcs, outfile) + wechat_path = File.join(Rails.root, "public", "javascripts", "wechat") + out_buffer = '' + + srcs.each do |src| + Dir.glob("#{wechat_path}/#{src}").each do |path| + puts "assets #{path}" + out_buffer = out_buffer + "\n//#{File.basename(path)}\n" + Uglifier.compile(File.read(path)) + end + end + + File.open(File.join(wechat_path, "build/#{outfile}"), 'w+') {|f| f.write(out_buffer)} +end + + +namespace :wechat do + desc "assets javascript file" + task :assets => :environment do + srcs = Rails.application.config.wechat_srcs + compress(srcs, 'app.min.js') + end + + desc "minify angularjs" + task :minify => :environment do + srcs = ['../jquery-1.3.2.js','angular.js', 'angular-route.js', 'angular-sanitize.min.js'] + compress(srcs, 'angular.all.min.js') + end +end diff --git a/public/javascripts/wechat/build/app.min.js b/public/javascripts/wechat/build/app.min.js index b704dfb6e..f7838e901 100644 --- a/public/javascripts/wechat/build/app.min.js +++ b/public/javascripts/wechat/build/app.min.js @@ -1,24 +1,49 @@ -var app=angular.module("wechat",["ngRoute"]);app.constant("config",{rootPath:"/assets/wechat/",rootUrl:"/",apiUrl:"/api/v1/"}),app.run(["$rootScope","auth","$location","$routeParams",function(t,a,e,r){g_redirect_path&&g_redirect_path.length>1&&(e.path(g_redirect_path),g_redirect_path=null),t.$on("$routeChangeError",function(t,a,r){a&&a.templateUrl&&(a.templateUrl.endsWith("login.html")||a.templateUrl.endsWith("reg.html")||e.path("/login"))}),t.$on("$routeChangeStart",function(t,a,e){})}]); -app.factory("alertService",function(){function t(){this.title=null,this.message=null,this.visible=null,this.cb=null}return t.prototype.showMessage=function(t,i,e){this.message=i,this.title=t,this.visible=!0,this.cb=e},t.prototype.dismiss=function(){this.message=null,this.title=null,this.visible=!1,this.cb&&this.cb()},{create:function(){return new t}}}),app.factory("auth",["$http","$routeParams","$q","session","config",function(t,i,e,a,c){var s=function(){var c=e.defer(),s=o();if(s&&s.length>10)c.resolve(s);else{window.g_code||i.code||a.get("code");t.post("/wechat/get_bind",{}).then(function(t){0!=t.data.status?c.reject(t.data.message):(a.save("token",t.data.token),c.resolve(t.data.token))})["catch"](function(t){c.reject(t)})}return c.promise},o=function(){return a.get("token")};return{get_bind:s,token:o}}]),app.factory("session",function(){return{save:function(t,i){sessionStorage.setItem(t,i)},get:function(t){return sessionStorage.getItem(t)}}}),app.factory("rms",function(){var t={},i=function(i,e){t[i]=e},e=function(i){return t[i]};return{save:i,get:e}}),app.factory("common",["$http","auth","$routeParams","rms",function(t,i,e,a){var c=function(e,a,c,s){if(c.comment&&!(c.comment.length<=0)){var o=c.comment.replace(/\n/g,"
        "),n={type:a,content:o,token:i.token()};c.disabled=!0,t({method:"POST",url:apiUrl+"new_comment/"+e,data:n}).then(function(t){c.disabled=!1,"function"==typeof s&&s()},function(t){})}},s=function(e,a){return t({method:"GET",url:apiUrl+a+"/"+e+"?token="+i.token()})},o=function(e){t({method:"POST",url:apiUrl+"praise/"+e.act_id,data:{token:i.token(),type:e.act_type}}).then(function(t){console.log(t.data)},function(t){})},n=function(e){t({method:"POST",url:apiUrl+"praise/"+e.act_id,data:{token:i.token(),type:e.act_type}}).then(function(t){console.log(t.data)},function(t){})},r=function(t){t.scope.formData={comment:""};var i=function(i){s(i,t.type).then(function(i){t.loadCallback(i.data)},function(t){})};i(t.id),t.scope.addReply=function(e){console.log(e.comment),c(t.id,t.replyType,e,function(){t.scope.formData={comment:""},i(t.id),"function"==typeof t.replyCallback&&t.replyCallback()})},t.scope.addPraise=function(t){activities=a.get("activities")||[],course_activities=a.get("course_activities")||[],project_activities=a.get("project_activities")||[];for(var i in activities)if(activities[i].act_id==t.act_id){activities[i].praise_count+=1,activities[i].has_praise=!0;break}for(var i in course_activities)if(course_activities[i].act_id==t.act_id){course_activities[i].praise_count+=1,course_activities[i].has_praise=!0;break}for(var i in project_activities)if(project_activities[i].act_id==t.act_id){project_activities[i].praise_count+=1,project_activities[i].has_praise=!0;break}a.save("activities",activities),a.save("course_activities",course_activities),a.save("project_activities",project_activities),t.praise_count+=1,t.has_praise=!0,o(t)},t.scope.decreasePraise=function(t){activities=a.get("activities")||[],course_activities=a.get("course_activities")||[],project_activities=a.get("project_activities")||[];for(var i in activities)if(activities[i].act_id==t.act_id){activities[i].praise_count-=1,activities[i].has_praise=!1;break}for(var i in course_activities)if(course_activities[i].act_id==t.act_id){course_activities[i].praise_count-=1,course_activities[i].has_praise=!1;break}for(var i in project_activities)if(project_activities[i].act_id==t.act_id){project_activities[i].praise_count-=1,project_activities[i].has_praise=!1;break}a.save("activities",activities),a.save("course_activities",course_activities),a.save("project_activities",project_activities),t.praise_count-=1,t.has_praise=!1,n(t)}};return{init:r,addCommonReply:c,loadCommonData:s,addCommonPraise:o,decreaseCommonPraise:n}}]); -app.filter("safeHtml",["$sce",function(t){return function(n){return t.trustAsHtml(n)}}]),app.filter("identify",function(){return function(t){return"TeachingAsistant"==t?"教辅":""}}); -app.controller("ActivityController",["$anchorScroll","$location","$scope","$http","$timeout","auth","rms","common","alertService",function(a,e,t,i,c,s,o,r,_){t.replaceUrl=function(a){return a},t.menus=["所有动态","课程动态","项目动态"],t.alertService=_.create(),console.log("ActivityController load"),t.page=o.get("page")||0,t.activities=o.get("activities")||[],t.has_more=o.get("has_more"),t.course_page=o.get("course_page")||0,t.course_activities=o.get("course_activities")||[],t.course_has_more=o.get("course_has_more"),t.project_page=o.get("project_page")||0,t.project_activities=o.get("project_activities")||[],t.project_has_more=o.get("project_has_more"),t.loadActData=function(a,e){switch(container_type="All",a){case 1:container_type="All",t.page=e;break;case 2:container_type="Course",t.course_page=e;break;case 3:container_type="Project",t.project_page=e}i({method:"POST",url:apiUrl+"activities",data:{token:s.token(),page:e,container_type:container_type}}).then(function(a){if(a.data.page>0)switch(a.data.container_type){case"All":t.activities=t.activities.concat(a.data.data);break;case"Course":t.course_activities=t.course_activities.concat(a.data.data);break;case"Project":t.project_activities=t.project_activities.concat(a.data.data);break;case 3:}else switch(a.data.container_type){case"All":t.activities=a.data.data;break;case"Course":t.course_activities=a.data.data;break;case"Project":t.project_activities=a.data.data;break;case 3:}switch(a.data.container_type){case"All":o.save("activities",t.activities),t.has_more=a.data.count+10*a.data.page1&&(e.path(g_redirect_path),g_redirect_path=null),t.$on("$routeChangeError",function(t,a){a&&a.templateUrl&&(a.templateUrl.endsWith("login.html")||a.templateUrl.endsWith("reg.html")||e.path("/login"))}),t.$on("$routeChangeStart",function(){})}]); +//factory.js +app.factory("alertService",function(){function t(){this.title=null,this.message=null,this.visible=null,this.cb=null}return t.prototype.showMessage=function(t,i,e){this.message=i,this.title=t,this.visible=!0,this.cb=e},t.prototype.dismiss=function(){this.message=null,this.title=null,this.visible=!1,this.cb&&this.cb()},{create:function(){return new t}}}),app.factory("auth",["$http","$routeParams","$q","session","config",function(t,i,e,a){var c=function(){var c=e.defer(),o=s();if(o&&o.length>10)c.resolve(o);else{{window.g_code||i.code||a.get("code")}t.post("/wechat/get_bind",{}).then(function(t){0!=t.data.status?c.reject(t.data.message):(a.save("token",t.data.token),c.resolve(t.data.token))})["catch"](function(t){c.reject(t)})}return c.promise},s=function(){return a.get("token")};return{get_bind:c,token:s}}]),app.factory("session",function(){return{save:function(t,i){sessionStorage.setItem(t,i)},get:function(t){return sessionStorage.getItem(t)}}}),app.factory("rms",function(){var t={},i=function(i,e){t[i]=e},e=function(i){return t[i]};return{save:i,get:e}}),app.factory("common",["$http","auth","$routeParams","rms",function(t,i,e,a){var c=function(e,a,c,s){if(c.comment&&!(c.comment.length<=0)){var o=c.comment.replace(/\n/g,"
        "),n={type:a,content:o,token:i.token()};c.disabled=!0,t({method:"POST",url:apiUrl+"new_comment/"+e,data:n}).then(function(){c.disabled=!1,"function"==typeof s&&s()},function(){})}},s=function(e,a){return t({method:"GET",url:apiUrl+a+"/"+e+"?token="+i.token()})},o=function(e){t({method:"POST",url:apiUrl+"praise/"+e.act_id,data:{token:i.token(),type:e.act_type}}).then(function(t){console.log(t.data)},function(){})},n=function(e){t({method:"POST",url:apiUrl+"praise/"+e.act_id,data:{token:i.token(),type:e.act_type}}).then(function(t){console.log(t.data)},function(){})},r=function(t){t.scope.formData={comment:""};var i=function(i){s(i,t.type).then(function(i){t.loadCallback(i.data)},function(){})};i(t.id),t.scope.addReply=function(e){console.log(e.comment),c(t.id,t.replyType,e,function(){t.scope.formData={comment:""},i(t.id),"function"==typeof t.replyCallback&&t.replyCallback()})},t.scope.addPraise=function(t){activities=a.get("activities")||[],course_activities=a.get("course_activities")||[],project_activities=a.get("project_activities")||[];for(var i in activities)if(activities[i].act_id==t.act_id){activities[i].praise_count+=1,activities[i].has_praise=!0;break}for(var i in course_activities)if(course_activities[i].act_id==t.act_id){course_activities[i].praise_count+=1,course_activities[i].has_praise=!0;break}for(var i in project_activities)if(project_activities[i].act_id==t.act_id){project_activities[i].praise_count+=1,project_activities[i].has_praise=!0;break}a.save("activities",activities),a.save("course_activities",course_activities),a.save("project_activities",project_activities),t.praise_count+=1,t.has_praise=!0,o(t)},t.scope.decreasePraise=function(t){activities=a.get("activities")||[],course_activities=a.get("course_activities")||[],project_activities=a.get("project_activities")||[];for(var i in activities)if(activities[i].act_id==t.act_id){activities[i].praise_count-=1,activities[i].has_praise=!1;break}for(var i in course_activities)if(course_activities[i].act_id==t.act_id){course_activities[i].praise_count-=1,course_activities[i].has_praise=!1;break}for(var i in project_activities)if(project_activities[i].act_id==t.act_id){project_activities[i].praise_count-=1,project_activities[i].has_praise=!1;break}a.save("activities",activities),a.save("course_activities",course_activities),a.save("project_activities",project_activities),t.praise_count-=1,t.has_praise=!1,n(t)}};return{init:r,addCommonReply:c,loadCommonData:s,addCommonPraise:o,decreaseCommonPraise:n}}]); +//filter.js +app.filter("safeHtml",["$sce",function(t){return function(n){return t.trustAsHtml(n)}}]),app.filter("identify",function(){return function(t){return"TeachingAsistant"==t?"\u6559\u8f85":""}}); +//activity.js +app.controller("ActivityController",["$anchorScroll","$location","$scope","$http","$timeout","auth","rms","common","alertService",function(a,e,t,i,c,s,o,r,_){t.replaceUrl=function(a){return a},t.menus=["\u6240\u6709\u52a8\u6001","\u8bfe\u7a0b\u52a8\u6001","\u9879\u76ee\u52a8\u6001"],t.alertService=_.create(),console.log("ActivityController load"),t.page=o.get("page")||0,t.activities=o.get("activities")||[],t.has_more=o.get("has_more"),t.course_page=o.get("course_page")||0,t.course_activities=o.get("course_activities")||[],t.course_has_more=o.get("course_has_more"),t.project_page=o.get("project_page")||0,t.project_activities=o.get("project_activities")||[],t.project_has_more=o.get("project_has_more"),t.loadActData=function(a,e){switch(container_type="All",a){case 1:container_type="All",t.page=e;break;case 2:container_type="Course",t.course_page=e;break;case 3:container_type="Project",t.project_page=e}i({method:"POST",url:apiUrl+"activities",data:{token:s.token(),page:e,container_type:container_type}}).then(function(a){if(a.data.page>0)switch(a.data.container_type){case"All":t.activities=t.activities.concat(a.data.data);break;case"Course":t.course_activities=t.course_activities.concat(a.data.data);break;case"Project":t.project_activities=t.project_activities.concat(a.data.data);break;case 3:}else switch(a.data.container_type){case"All":t.activities=a.data.data;break;case"Course":t.course_activities=a.data.data;break;case"Project":t.project_activities=a.data.data;break;case 3:}switch(a.data.container_type){case"All":o.save("activities",t.activities),t.has_more=a.data.count+10*a.data.page0?u.alertService_2.showMessage("提示","您确定要删除该班级吗?",function(){e.post(l.apiUrl+"courses/"+t.id+"/del",{token:a.token()}).then(function(e){0!=e.data.status?u.alertService_1.showMessage("出错了",e.data.message):u.alertService_1.showMessage("提示","删除班级成功",function(){u.syllabus.courses.splice(s,1)}),console.log(e.data.data)})}):u.syllabus.courses.splice(s,1)},u.newClass=function(s,t){if(s.$setSubmitted(),console.log(t),!s.$valid)return void console.log(s.$error);var r=[],c=[];for(var d in u.syllabus.courses){var b=u.syllabus.courses[d];b.id?b.tmpname!=b.name&&c.push({id:b.id,name:b.tmpname}):r.push(b.tmpname)}e.post(l.apiUrl+"syllabuses/"+i+"/edit",{token:a.token(),id:i,title:u.syllabus.tmptitle,add_courses:r,modify_courses:c}).then(function(s){0!=s.data.status?u.alertService_1.showMessage("出错了",s.data.message):u.alertService_1.showMessage("提示","保存课程成功",function(){n.save("syllabuses",[]),o.path("/class_list")}),console.log(s.data.data)})},u.fadeText=function(){s.change=!0}}]); +//edit_class.js +app.controller("EditClassController",["$scope","$http","auth","config","alertService","$location","$routeParams","rms",function(s,e,a,l,t,o,r,n){var u=s;u.syllabus=n.get("current_edit_syllobus");var i=r.id;if(u.syllabus||e.get(l.apiUrl+"syllabuses/"+i+"?token="+a.token()).then(function(s){if(console.log(s.data),u.syllabus=s.data.data,u.syllabus){for(var e in u.syllabus.courses){var a=u.syllabus.courses[e];a.tmpname=a.name}u.syllabus.tmptitle=u.syllabus.title}}),console.log(u.syllabus),u.syllabus){for(var c in u.syllabus.courses){var d=u.syllabus.courses[c];d.tmpname=d.name}u.syllabus.tmptitle=u.syllabus.title}u.alertService_1=t.create(),u.alertService_2=t.create(),u.addClass=function(){u.syllabus.courses.push({can_setting:!0})},u.deleteClass=function(s){var t=u.syllabus.courses[s];t.id>0?u.alertService_2.showMessage("\u63d0\u793a","\u60a8\u786e\u5b9a\u8981\u5220\u9664\u8be5\u73ed\u7ea7\u5417\uff1f",function(){e.post(l.apiUrl+"courses/"+t.id+"/del",{token:a.token()}).then(function(e){0!=e.data.status?u.alertService_1.showMessage("\u51fa\u9519\u4e86",e.data.message):u.alertService_1.showMessage("\u63d0\u793a","\u5220\u9664\u73ed\u7ea7\u6210\u529f",function(){u.syllabus.courses.splice(s,1)}),console.log(e.data.data)})}):u.syllabus.courses.splice(s,1)},u.newClass=function(s,t){if(s.$setSubmitted(),console.log(t),!s.$valid)return void console.log(s.$error);var r=[],c=[];for(var d in u.syllabus.courses){var b=u.syllabus.courses[d];b.id?b.tmpname!=b.name&&c.push({id:b.id,name:b.tmpname}):r.push(b.tmpname)}e.post(l.apiUrl+"syllabuses/"+i+"/edit",{token:a.token(),id:i,title:u.syllabus.tmptitle,add_courses:r,modify_courses:c}).then(function(s){0!=s.data.status?u.alertService_1.showMessage("\u51fa\u9519\u4e86",s.data.message):u.alertService_1.showMessage("\u63d0\u793a","\u4fdd\u5b58\u8bfe\u7a0b\u6210\u529f",function(){n.save("syllabuses",[]),o.path("/class_list")}),console.log(s.data.data)})},u.fadeText=function(){s.change=!0}}]); +//homework.js app.controller("HomeworkController",["$scope","$http","$routeParams","auth","common",function(o,e,l,n,r){r.init({id:l.id,scope:o,type:"whomeworks",replyType:"HomeworkCommon",loadCallback:function(e){console.log(e),o.homework=e.data},replyCallback:function(){}})}]); -app.controller("InviteCodeController",["$scope","$http","$routeParams","config","auth",function(t,e,i,n,o){var a=t;a.course={};var c=i.id;e.get(n.apiUrl+"courses/"+c+"?token="+o.token()).then(function(t){console.log(t.data),a.course=t.data.data}),a.share=function(){window.WeixinJSBridge.invoke("sendAppMessage",{appid:"wxf694495398c7d470",type:"link",data_url:"",img_url:"http://pnewsapp.tc.qq.com/newsapp_bt/0/9963967/640",img_height:370,img_width:550,link:"http://view.inews.qq.com/a/WXN2013101101385701",desc:"desc",title:"title"},function(t){})}}]); +//invite_code.js +app.controller("InviteCodeController",["$scope","$http","$routeParams","config","auth",function(t,e,i,n,o){var a=t;a.course={};var c=i.id;e.get(n.apiUrl+"courses/"+c+"?token="+o.token()).then(function(t){console.log(t.data),a.course=t.data.data}),a.share=function(){window.WeixinJSBridge.invoke("sendAppMessage",{appid:"wxf694495398c7d470",type:"link",data_url:"",img_url:"http://pnewsapp.tc.qq.com/newsapp_bt/0/9963967/640",img_height:370,img_width:550,link:"http://view.inews.qq.com/a/WXN2013101101385701",desc:"desc",title:"title"},function(){})}}]); +//issue.js app.controller("IssueController",["$scope","$http","$routeParams","auth","common",function(o,e,l,s,t){t.init({id:l.id,scope:o,type:"issues",replyType:"Issue",loadCallback:function(e){console.log(e),o.issue=e.data},replyCallback:function(){}})}]); +//journals.js app.controller("JournalsController",["$scope","$http","$routeParams","auth","common",function(o,a,e,l,n){n.init({id:e.id,scope:o,type:"journal_for_messages",replyType:"JournalsForMessage",loadCallback:function(a){o.message=a.data},replyCallback:function(){}})}]); -app.controller("LoginController",["$scope","$http","$location","$routeParams","alertService","config","auth","session",function(e,o,t,a,i,n,s,l){s.get_bind().then(function(){t.path("/activities")}),a.code&&l.save("code",a.code);var r=e;r.loginFailed=!1,r.alertService=i.create(),r.findPwdDialog=i.create(),r.login=function(a,i){return a.$setSubmitted(),console.log(i),a.$valid?(console.log(apiUrl+"auth"),void o.post(n.apiUrl+"users/wxbind",{login:i.login,password:i.password}).then(function(o){console.log(o.data),r.loginFailed=0!=o.data.status,e.loginFailed?r.alertService.showMessage("出错了",o.data.message):r.alertService.showMessage("提示",o.data.message,function(){t.path("/activities")})})["catch"](function(e){r.alertService.showMessage("出错了",e)})):void console.log(a.$error)},r.showBox=function(){r.findPwdDialog.showMessage("提示","请访问www.trustie.net获取密码,谢谢!")},r.goReg=function(){t.path("/reg")}}]); -app.controller("MyResourceController",["$scope","$http","auth","config","$location","rms",function(e,a,o,s,r,t){var c=e;c.menus=["课件","作业","测验"],c.resources=[],c.homeworks=[],c.exercise=[],c.resources_tag=!1,c.homeworks_tag=!1,c.exercises_tag=!1,c.page=t.get("page")||0,c.resources=t.get("resources")||[],c.has_more=t.get("has_more"),c.homework_page=t.get("homework_page")||0,c.homeworks=t.get("homeworks")||[],c.homework_has_more=t.get("homework_has_more"),c.exercise_page=t.get("exercise_page")||0,c.exercise=t.get("exercise")||[],c.exercise_has_more=t.get("exercise_has_more"),c.searchText="",c.sendFile=function(e){r.path("/send_class_list").search({id:e.id})},c.loadResourceData=function(e,s){1==e?(c.page=s,a({method:"POST",url:apiUrl+"resources",data:{token:o.token(),page:s}}).then(function(e){c.resources_tag=!0,e.data.page>0?c.resources=c.resources.concat(e.data.data):c.resources=e.data.data,t.save("resources",c.resources),c.has_more=e.data.count+10*e.data.page0?c.homeworks=c.homeworks.concat(e.data.data):c.homeworks=e.data.data,t.save("homeworks",c.homeworks),c.homework_has_more=e.data.count+10*e.data.page0?c.exercise=c.exercise.concat(e.data.data):c.exercise=e.data.data,t.save("exercise",c.exercise),c.exercise_has_more=e.data.count+10*e.data.page0?c.resources.concat(e.data.data):e.data.data,t.save("resources",c.resources),c.has_more=e.data.count+10*e.data.page0?c.homeworks.concat(e.data.data):e.data.data,t.save("homeworks",c.homeworks),c.homework_has_more=e.data.count+10*e.data.page0?c.exercise.concat(e.data.data):e.data.data,t.save("exercise",c.exercise),c.exercise_has_more=e.data.count+10*e.data.page Date: Mon, 18 Jul 2016 11:08:02 +0800 Subject: [PATCH 09/99] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=EF=BC=9A=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E5=A2=9E=E5=8A=A0=E5=8F=91=E9=80=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/courses.rb | 9 +- app/api/mobile/apis/resources.rb | 16 ++- app/services/resources_service.rb | 119 ++++++++++++++++++ public/assets/wechat/class.html | 2 +- public/assets/wechat/myresource.html | 6 +- .../javascripts/wechat/controllers/class.js | 20 +-- .../wechat/controllers/myresource.js | 11 +- .../wechat/controllers/send_class_list.js | 5 +- 8 files changed, 172 insertions(+), 16 deletions(-) diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index caabad198..aa1e573ed 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -200,8 +200,13 @@ module Mobile # course = Course.find(params[:id]) cs = CoursesService.new course = cs.show_course(params,current_user) - present :data, course, with: Mobile::Entities::Course,user: current_user - { status: 0} + + if course[:course][:is_delete] == 1 + {status:-1, message: '该班级不存在或已被删除啦' } + else + present :data, course, with: Mobile::Entities::Course,user: current_user + present :status, 0 + end end end diff --git a/app/api/mobile/apis/resources.rb b/app/api/mobile/apis/resources.rb index d5823d5b4..ebfef7f2d 100644 --- a/app/api/mobile/apis/resources.rb +++ b/app/api/mobile/apis/resources.rb @@ -85,12 +85,26 @@ module Mobile requires :token, type: String requires :course_ids, type: Array[Integer] requires :send_id, type: Integer + requires :send_type, type: Integer end post 'send' do authenticate! rs = ResourcesService.new - ori, flag, save_message = rs.send_resource_to_course(current_user,params) + + ori = nil + flag = false + save_message = nil + + case params[:send_type] + when 1 + ori, flag, save_message = rs.send_resource_to_course(current_user,params) + when 2 + ori, flag, save_message = rs.send_homework_to_course(current_user,params) + when 3 + ori, flag, save_message = rs.send_exercise_to_course(current_user,params) + end + if flag present :status, 0 else diff --git a/app/services/resources_service.rb b/app/services/resources_service.rb index bc97437e4..b56da8ad3 100644 --- a/app/services/resources_service.rb +++ b/app/services/resources_service.rb @@ -49,6 +49,125 @@ class ResourcesService [@ori, @flag, @save_message] end + def send_homework_to_course user,params + homework = HomeworkCommon.find params[:send_id].to_i + @ori = homework + course_ids = params[:course_ids] + @flag = false + unless course_ids.nil? + course_ids.each do |course_id| + course = Course.find course_id.to_i + new_homework = HomeworkCommon.new + new_homework.name = homework.name + new_homework.user_id = user.id + new_homework.description = homework.description + new_homework.homework_type = homework.homework_type + new_homework.late_penalty = homework.late_penalty + new_homework.course_id = course.id + new_homework.teacher_priority = homework.teacher_priority + new_homework.anonymous_comment = homework.anonymous_comment + new_homework.quotes = 0 + new_homework.is_open = homework.is_open + homework.attachments.each do |attachment| + att = attachment.copy + att.container_id = nil + att.container_type = nil + att.copy_from = attachment.id + att.save + new_homework.attachments << att + end + homework_detail_manual = homework.homework_detail_manual + homework_detail_programing = homework.homework_detail_programing + homework_detail_group = homework.homework_detail_group + if homework_detail_manual + new_homework.homework_detail_manual = HomeworkDetailManual.new + new_homework_detail_manual = new_homework.homework_detail_manual + new_homework_detail_manual.ta_proportion = homework_detail_manual.ta_proportion + new_homework_detail_manual.comment_status = 0 + new_homework_detail_manual.evaluation_num = homework_detail_manual.evaluation_num + new_homework_detail_manual.absence_penalty = homework_detail_manual.absence_penalty + end + if homework_detail_programing + new_homework.homework_detail_programing = HomeworkDetailPrograming.new + new_homework.homework_detail_programing.ta_proportion = homework_detail_programing.ta_proportion + new_homework.homework_detail_programing.language = homework_detail_programing.language + homework.homework_tests.each_with_index do |homework_test| + new_homework.homework_tests << HomeworkTest.new( + input: homework_test.input, + output: homework_test.output + ) + end + end + + if homework_detail_group + new_homework.homework_detail_group = HomeworkDetailGroup.new + new_homework.homework_detail_group.min_num = homework_detail_group.min_num + new_homework.homework_detail_group.max_num = homework_detail_group.max_num + new_homework.homework_detail_group.base_on_project = homework_detail_group.base_on_project + end + if new_homework.save + new_homework_detail_manual.save if new_homework_detail_manual + new_homework.homework_detail_programing.save if new_homework.homework_detail_programing + new_homework.homework_detail_group.save if new_homework.homework_detail_group + @flag = true + else + @flag = false + @save_message = new_homework.errors.full_messages + break + end + homework.update_column(:quotes, homework.quotes+1) + end + end + [@ori, @flag, @save_message] + end + + def send_exercise_to_course user,params + # send_id = params[:send_id] + # @ori = Attachment.find_by_id(send_id) + # course_ids = params[:course_ids] + # @flag = false + # unless course_ids.nil? + # course_ids.each do |id| + # next if @ori.blank? + # @exist = false + # Course.find(id).attachments.each do |att| #如果课程中包含该资源 + # if att.id == @ori.id || (!att.copy_from.nil? && !@ori.copy_from.nil? && att.copy_from == @ori.copy_from) || att.copy_from == @ori.id || att.id == @ori.copy_from + # att.created_on = Time.now + # att.save + # @exist = true + # @flag = true + # break + # end + # end + # next if @exist + # attach_copied_obj = @ori.copy + # attach_copied_obj.tag_list.add(@ori.tag_list) # tag关联 + # attach_copied_obj.container = Course.find(id) + # attach_copied_obj.created_on = Time.now + # attach_copied_obj.author_id = user.id + # attach_copied_obj.is_public = 0 + # attach_copied_obj.copy_from = @ori.copy_from.nil? ? @ori.id : @ori.copy_from #发送要添加copy_from + # if attach_copied_obj.attachtype == nil + # attach_copied_obj.attachtype = 4 + # end + # if attach_copied_obj.save + # # 更新引用次数 + # quotes = @ori.quotes.to_i + 1 + # @ori.update_attribute(:quotes, quotes) unless @ori.nil? + # @ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now) + # @flag = true + # else + # @flag = false + # @save_message = attach_copied_obj.errors.full_messages + # break + # end + # + # end + # end + + [@ori, @flag, @save_message] + end + # 我的资源-课件 已发布的 def all_course_attachments user diff --git a/public/assets/wechat/class.html b/public/assets/wechat/class.html index c328ed226..2f9af6554 100644 --- a/public/assets/wechat/class.html +++ b/public/assets/wechat/class.html @@ -56,5 +56,5 @@ - +
    diff --git a/public/assets/wechat/myresource.html b/public/assets/wechat/myresource.html index c89f39684..28fc69cc3 100644 --- a/public/assets/wechat/myresource.html +++ b/public/assets/wechat/myresource.html @@ -12,7 +12,7 @@
    - {{r.filename}}发送
    + {{r.filename}}发送
    大小:{{r.attafile_size}}
    @@ -22,7 +22,7 @@ 请登录Trustie网站,在PC浏览器中上传课件。

    -
    {{r.homework_name}}发送
    +
    {{r.homework_name}}发送
    @@ -32,7 +32,7 @@ 请登录Trustie网站,在PC浏览器中创建作业。

    -
    {{r.exercise_name}}发送
    +
    {{r.exercise_name}}发送
    diff --git a/public/javascripts/wechat/controllers/class.js b/public/javascripts/wechat/controllers/class.js index 87703b681..cf2a3ee88 100644 --- a/public/javascripts/wechat/controllers/class.js +++ b/public/javascripts/wechat/controllers/class.js @@ -1,4 +1,4 @@ -app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams', function($scope, config, $http, auth, $location, $routeParams){ +app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams','alertService', function($scope, config, $http, auth, $location, $routeParams,alertService){ var vm = $scope; var courseid = $routeParams.id; @@ -97,15 +97,14 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location } } - - - vm.course = {}; vm.students = []; vm.teachers = []; vm.resources = []; vm.homeworks = []; vm.exercises = []; + + vm.alertService = alertService.create(); vm.invite = function(){ $location.path("/invite_code").search({id: courseid}); @@ -118,9 +117,16 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location $http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then( function(response) { console.log(response.data); - vm.course = response.data.data; - resetMenu(vm.course.current_user_is_teacher); - vm.tab(1); + + if (response.data.status == 0){ + vm.course = response.data.data; + resetMenu(vm.course.current_user_is_teacher); + vm.tab(1); + } + else{ + vm.alertService.showMessage('提示', response.data.message); + } + } ); diff --git a/public/javascripts/wechat/controllers/myresource.js b/public/javascripts/wechat/controllers/myresource.js index fb564cde8..15428bb34 100644 --- a/public/javascripts/wechat/controllers/myresource.js +++ b/public/javascripts/wechat/controllers/myresource.js @@ -10,21 +10,30 @@ app.controller('MyResourceController', ['$scope', '$http', 'auth', 'config', '$l vm.homeworks_tag = false; vm.exercises_tag = false; + //课件 vm.page = rms.get('page') || 0; vm.resources = rms.get("resources") || []; vm.has_more = rms.get("has_more"); + //作业 vm.homework_page = rms.get('homework_page') || 0; vm.homeworks = rms.get("homeworks") || []; vm.homework_has_more = rms.get("homework_has_more"); + //测验 vm.exercise_page = rms.get('exercise_page') || 0; vm.exercise = rms.get("exercise") || []; vm.exercise_has_more = rms.get("exercise_has_more"); vm.searchText = ""; - vm.sendFile = function(r){ + //发送类别 1课件 2作业 3测验 + vm.myresource_sendIndex = rms.get('myresource_sendIndex') || 1; + + vm.sendFile = function(r,index){ + vm.myresource_sendIndex = index; + rms.save('myresource_sendIndex',index); + $location.path("/send_class_list").search({id: r.id}); } diff --git a/public/javascripts/wechat/controllers/send_class_list.js b/public/javascripts/wechat/controllers/send_class_list.js index 16875af9f..c80943e39 100644 --- a/public/javascripts/wechat/controllers/send_class_list.js +++ b/public/javascripts/wechat/controllers/send_class_list.js @@ -2,6 +2,9 @@ app.controller('SendClassListController', ['$scope', '$http','$routeParams', 'co var vm = $scope; var send_id = $routeParams.id; + //发送类别 1课件 2作业 3测验 + vm.myresource_sendIndex = rms.get('myresource_sendIndex') || 1; + vm.alertService = alertService.create(); vm.syllabuses = []; @@ -39,7 +42,7 @@ app.controller('SendClassListController', ['$scope', '$http','$routeParams', 'co } $http.post(config.apiUrl + "resources/send", { - token: auth.token(), course_ids: course_ids, send_id: send_id + token: auth.token(), course_ids: course_ids, send_id: send_id,send_type:vm.myresource_sendIndex }).then(function(response){ console.log(response.data); if(response.data.status == 0){ From a9ee1d10cd62636c8c4ee1076aa65c7c1235dca6 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 18 Jul 2016 11:19:56 +0800 Subject: [PATCH 10/99] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=8F=AD=E7=BA=A7?= =?UTF-8?q?=E6=88=90=E5=91=98=E7=9A=84=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=EF=BC=8C=E8=B7=B3=E8=BD=AC=E8=87=B3=E8=AF=A5=E7=8F=AD=E7=BA=A7?= =?UTF-8?q?=E7=9A=84=E6=88=90=E5=91=98=E9=85=8D=E7=BD=AE=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 4 +++- app/views/users/_user_message_course.html.erb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index a9d84c2d9..601b9e4da 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -301,7 +301,6 @@ class CoursesController < ApplicationController def member ## 有角色参数的才是课程,没有的就是项目 if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course))) - @render_file = 'new_member_list' @score_sort_by = "desc" @sort_type = params[:sort_type] ? params[:sort_type] : "score" @@ -414,6 +413,9 @@ class CoursesController < ApplicationController end def settings + #添加成员消息状态 + join_course_messages = CourseMessage.where("user_id =? and course_message_type =? and course_id =? and status = ? and viewed =?", User.current.id, 'JoinCourse', @course.id, 1, 0) + join_course_messages.update_all(:viewed => true) if User.current.allowed_to?(:as_teacher,@course) @select_tab = params[:tab] @issue_custom_fields = IssueCustomField.sorted.all diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index c27002d24..fa2be7ae1 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -653,7 +653,7 @@ ">您增加了新的班级成员:
  • - <%= link_to User.find(ma.course_message_id).login+"("+(User.find(ma.course_message_id).realname ? User.find(ma.course_message_id).realname : User.find(ma.course_message_id).login) +")", user_path(ma.course_message_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %> + <%= link_to User.find(ma.course_message_id).login+"("+(User.find(ma.course_message_id).realname ? User.find(ma.course_message_id).realname : User.find(ma.course_message_id).login) +")", {:controller => 'courses', :action => 'settings', :id => ma.course_id, :tab=>'member'}, :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %> From 9e5e7a75b0a3a81ba728538c5199e9976d283e2c Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 18 Jul 2016 14:09:41 +0800 Subject: [PATCH 11/99] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E5=8C=BF=E8=AF=84=E5=90=8E=EF=BC=8C=E8=80=81?= =?UTF-8?q?=E5=B8=88=E7=82=B9=E5=87=BB=E6=A8=A1=E6=8B=9F=E7=AD=94=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E5=8D=B4=E5=BC=B9=E5=87=BA=E5=8C=BF=E8=AF=84=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/new_user_commit_homework.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/new_user_commit_homework.html.erb b/app/views/users/new_user_commit_homework.html.erb index 238102879..84503f837 100644 --- a/app/views/users/new_user_commit_homework.html.erb +++ b/app/views/users/new_user_commit_homework.html.erb @@ -7,7 +7,7 @@ $(function(){ $("#RSide").removeAttr("id"); $("#Container").css("width","1000px"); - <%if @homework.anonymous_comment == 0 && @homework.homework_detail_manual.comment_status != 1%> + <%if !@is_test && @homework.anonymous_comment == 0 && @homework.homework_detail_manual.comment_status != 1%> $('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/new_student_work_alert') %>'); showModal('ajax-modal', '360px'); $('#ajax-modal').siblings().remove(); From ff13d2e572045bd6af626ae58f699e96e7462de2 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Mon, 18 Jul 2016 14:24:59 +0800 Subject: [PATCH 12/99] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=8F=91=E9=80=81=EF=BC=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=8F=91=E9=80=81=E7=9A=84=E6=9D=83=E9=99=90=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/courses.rb | 6 +++--- app/api/mobile/entities/attachment.rb | 8 ++++++++ app/api/mobile/entities/exercise.rb | 8 ++++++++ app/api/mobile/entities/homework.rb | 7 +++++++ app/controllers/wechats_controller.rb | 15 ++++++++------ config/menu.yml.test | 20 +++++++++++++------ public/assets/wechat/class.html | 6 +++--- public/assets/wechat/myresource.html | 6 +++--- .../javascripts/wechat/controllers/class.js | 9 +++++++-- .../wechat/controllers/send_class_list.js | 2 +- 10 files changed, 63 insertions(+), 24 deletions(-) diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index aa1e573ed..1c6fd7008 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -217,7 +217,7 @@ module Mobile get "homeworks/:id" do cs = CoursesService.new homeworks = cs.homework_list params,current_user - present :data, homeworks, with: Mobile::Entities::Homework + present :data, homeworks, with: Mobile::Entities::Homework,user: current_user present :status, 0 end @@ -264,7 +264,7 @@ module Mobile post ":course_id/attachments" do cs = CoursesService.new count = cs.course_attachments params - present :data, count, with: Mobile::Entities::Attachment + present :data, count, with: Mobile::Entities::Attachment,user: current_user present :status, 0 end @@ -398,7 +398,7 @@ module Mobile course = Course.find(params[:course_id]) exercises = course.exercises.where("exercise_status <> 1").order("created_at desc") - present :data,exercises,with:Mobile::Entities::Exercise + present :data,exercises,with:Mobile::Entities::Exercise,user: current_user present :status,0 end diff --git a/app/api/mobile/entities/attachment.rb b/app/api/mobile/entities/attachment.rb index 49cb6bd2b..028ad633d 100644 --- a/app/api/mobile/entities/attachment.rb +++ b/app/api/mobile/entities/attachment.rb @@ -3,6 +3,7 @@ module Mobile class Attachment < Grape::Entity include Redmine::I18n include ActionView::Helpers::NumberHelper + include ApplicationHelper def self.attachment_expose(field) expose field do |f,opt| if f.is_a?(Hash) && f.key?(field) @@ -22,6 +23,7 @@ module Mobile (number_to_human_size(f.filesize)).gsub("ytes", "").to_s when :coursename f.course.nil? ? "" : f.course.name + end end end @@ -36,6 +38,12 @@ module Mobile attachment_expose :file_dir attachment_expose :attafile_size attachment_expose :coursename #所属班级名 + expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options| + current_user = options[:user] + current_user_is_teacher = false + current_user_is_teacher = is_course_teacher(current_user,instance.course) + current_user_is_teacher + end end end end \ No newline at end of file diff --git a/app/api/mobile/entities/exercise.rb b/app/api/mobile/entities/exercise.rb index 05066f8a4..ce6a2fb39 100644 --- a/app/api/mobile/entities/exercise.rb +++ b/app/api/mobile/entities/exercise.rb @@ -27,6 +27,14 @@ module Mobile expose :exercise_name expose :exercise_description exercise_expose :coursename #所属班级名 + + expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options| + current_user = options[:user] + current_user_is_teacher = false + current_user_is_teacher = is_course_teacher(current_user,instance.course) + current_user_is_teacher + end + end end end diff --git a/app/api/mobile/entities/homework.rb b/app/api/mobile/entities/homework.rb index 3f1631c96..cea15ece9 100644 --- a/app/api/mobile/entities/homework.rb +++ b/app/api/mobile/entities/homework.rb @@ -98,6 +98,13 @@ module Mobile homework_expose :coursename #所属班级名 + expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options| + current_user = options[:user] + current_user_is_teacher = false + current_user_is_teacher = is_course_teacher(current_user,instance.course) + current_user_is_teacher + end + end end end \ No newline at end of file diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index ea305d967..c72e04e14 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -78,12 +78,7 @@ class WechatsController < ActionController::Base end # When user view URL in the menu button on :view, with: 'http://wechat.somewhere.com/view_url' do |request, view| - uw = user_binded?(request[:FromUserName]) - unless uw - sendBind(request) - else - request.reply.text "#{request[:FromUserName]} view #{view}" - end + request.reply.text "#{request[:FromUserName]} view #{view}" end # When user sent the imsage @@ -147,6 +142,14 @@ class WechatsController < ActionController::Base default_msg(request) end + on :click, with: 'PROJECT' do |request, key| + request.reply.text "此功能正在开发中,很快就会上线,谢谢!" + end + + on :click, with: 'JOIN_PROJECT' do |request, key| + request.reply.text "此功能正在开发中,很快就会上线,谢谢!" + end + on :click, with: 'JOIN_CLASS' do |request, key| uw = user_binded?(request[:FromUserName]) unless uw diff --git a/config/menu.yml.test b/config/menu.yml.test index a43d72816..521ff290a 100644 --- a/config/menu.yml.test +++ b/config/menu.yml.test @@ -2,18 +2,22 @@ button: - type: "view" name: "我的动态" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://ucloudtest.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=activities#wechat_redirect" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=activities#wechat_redirect" - - name: "我的课程" + name: "我的群组" sub_button: - type: "view" - name: "课程" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://ucloudtest.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=class_list#wechat_redirect" + name: "我的课程" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=class_list#wechat_redirect" + - + type: "click" + name: "我的项目" + key: "PROJECT" - type: "view" - name: "资源" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://ucloudtest.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=myresource#wechat_redirect" + name: "我的宝库" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=myresource#wechat_redirect" - name: "更多" @@ -22,6 +26,10 @@ button: type: "click" name: "加入班级" key: "JOIN_CLASS" + - + type: "click" + name: "加入项目" + key: "JOIN_PROJECT" - type: "click" name: "反馈" diff --git a/public/assets/wechat/class.html b/public/assets/wechat/class.html index 2f9af6554..01628c2f4 100644 --- a/public/assets/wechat/class.html +++ b/public/assets/wechat/class.html @@ -23,7 +23,7 @@
  • -
    {{r.filename}}发送
    +
    {{r.filename}}发送

    暂无课件,
    请登录Trustie网站,在PC浏览器中上传课件。

    @@ -42,14 +42,14 @@
    -
    {{r.homework_name}}发送
    +
    {{r.homework_name}}发送

    暂无作业,
    请登录Trustie网站,在PC浏览器中上传作业。

    -
    {{r.exercise_name}}发送
    +
    {{r.exercise_name}}发送

    暂无小测验,
    请登录Trustie网站,在PC浏览器中上传小测验。

    diff --git a/public/assets/wechat/myresource.html b/public/assets/wechat/myresource.html index 28fc69cc3..c06c57238 100644 --- a/public/assets/wechat/myresource.html +++ b/public/assets/wechat/myresource.html @@ -12,7 +12,7 @@
    - {{r.filename}}发送
    + {{r.filename}}发送
    大小:{{r.attafile_size}}
    @@ -22,7 +22,7 @@ 请登录Trustie网站,在PC浏览器中上传课件。

    -
    {{r.homework_name}}发送
    +
    {{r.homework_name}}发送
    @@ -32,7 +32,7 @@ 请登录Trustie网站,在PC浏览器中创建作业。

    -
    {{r.exercise_name}}发送
    +
    {{r.exercise_name}}发送
    diff --git a/public/javascripts/wechat/controllers/class.js b/public/javascripts/wechat/controllers/class.js index cf2a3ee88..75e1709cc 100644 --- a/public/javascripts/wechat/controllers/class.js +++ b/public/javascripts/wechat/controllers/class.js @@ -1,4 +1,4 @@ -app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams','alertService', function($scope, config, $http, auth, $location, $routeParams,alertService){ +app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams','alertService','rms', function($scope, config, $http, auth, $location, $routeParams,alertService,rms){ var vm = $scope; var courseid = $routeParams.id; @@ -104,13 +104,18 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location vm.homeworks = []; vm.exercises = []; + //发送类别 1课件 2作业 3测验 + vm.myresource_sendIndex = rms.get('myresource_sendIndex') || 1; + vm.alertService = alertService.create(); vm.invite = function(){ $location.path("/invite_code").search({id: courseid}); }; - vm.sendFile = function(r){ + vm.sendFile = function(r,index){ + vm.myresource_sendIndex = index; + rms.save('myresource_sendIndex',index); $location.path("/send_class_list").search({id: r.id}); } diff --git a/public/javascripts/wechat/controllers/send_class_list.js b/public/javascripts/wechat/controllers/send_class_list.js index c80943e39..1eabfa94c 100644 --- a/public/javascripts/wechat/controllers/send_class_list.js +++ b/public/javascripts/wechat/controllers/send_class_list.js @@ -46,7 +46,7 @@ app.controller('SendClassListController', ['$scope', '$http','$routeParams', 'co }).then(function(response){ console.log(response.data); if(response.data.status == 0){ - vm.alertService.showMessage('提示', '发送成功', function () { + vm.alertService.showMessage('发送成功', '题目已发送到目标班级的作业列表,但需要您访问Trustie网站设置发布和截止时间,以激活相应作业,谢谢!', function () { window.history.back(); }); } else { From fea8d56d8d6087eed9e662e10fa02d9348731d45 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Mon, 18 Jul 2016 14:28:45 +0800 Subject: [PATCH 13/99] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=89=88=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/wechat.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/wechat.yml b/config/wechat.yml index f09cca3d5..8b2caffc8 100644 --- a/config/wechat.yml +++ b/config/wechat.yml @@ -8,12 +8,12 @@ default: &default #secret: "743e038392f1d89540e95f8f7645849a" #production - appid: "wx8e1ab05163a28e37" - secret: "beb4d3bc4b32b3557811680835357841" +# appid: "wx8e1ab05163a28e37" +# secret: "beb4d3bc4b32b3557811680835357841" #test -# appid: "wxc09454f171153c2d" -# secret: "dff5b606e34dcafe24163ec82c2715f8" + appid: "wxc09454f171153c2d" + secret: "dff5b606e34dcafe24163ec82c2715f8" token: "123456" access_token: "1234567" From 8e3488132b07b3fb3abb7d711f8eec4a063c88d7 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 18 Jul 2016 14:43:47 +0800 Subject: [PATCH 14/99] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=EF=BC=9A=E5=85=AC=E5=85=B1=E9=A2=98=E5=BA=93=E4=B8=AD=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E7=9A=84=E5=8D=B4=E6=98=AF=E6=88=91=E7=9A=84=E9=A2=98?= =?UTF-8?q?=E5=BA=93=EF=BC=8C=E6=88=91=E7=9A=84=E9=A2=98=E5=BA=93=E4=B8=AD?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=9A=84=E5=8D=B4=E6=98=AF=E5=85=AC=E5=85=B1?= =?UTF-8?q?=E9=A2=98=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 6 +++--- app/views/users/_show_user_homeworks.html.erb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f5684f202..c870fdc3b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -709,9 +709,9 @@ class UsersController < ApplicationController @user = User.current @select_course = params[:select_course] ? 1 : 0 #@user_homeworks = HomeworkCommon.where(:user_id => @user.id).order("created_at desc") - visible_course = Course.where("is_public = 1 && is_delete = 0") - visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")" - @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("created_at desc") + courses = @user.courses.where("is_delete = 1") + course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")" + @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and course_id not in #{course_ids}").order("#{@order} #{@b_sort}") @type = params[:type] @limit = 15 @is_remote = true diff --git a/app/views/users/_show_user_homeworks.html.erb b/app/views/users/_show_user_homeworks.html.erb index 46e075412..f54f49865 100644 --- a/app/views/users/_show_user_homeworks.html.erb +++ b/app/views/users/_show_user_homeworks.html.erb @@ -1,8 +1,8 @@
    选用题库中的题目
    - 公共题库 - 我的题库 + 我的题库 + 公共题库
    From b2f9839d1347dbacc0493b607964396d683f53a3 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Mon, 18 Jul 2016 14:43:54 +0800 Subject: [PATCH 15/99] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=EF=BC=9A=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=89=88=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/menu.yml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/config/menu.yml b/config/menu.yml index 1817ab44d..0acb58b96 100644 --- a/config/menu.yml +++ b/config/menu.yml @@ -2,18 +2,22 @@ button: - type: "view" name: "我的动态" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8e1ab05163a28e37&redirect_uri=https://www.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=123#wechat_redirect" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=activities#wechat_redirect" - - name: "我的课程" + name: "我的群组" sub_button: - - type: "click" - name: "课程" - key: "DEV" + type: "view" + name: "我的课程" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=class_list#wechat_redirect" - type: "click" - name: "资源" - key: "DEV" + name: "我的项目" + key: "PROJECT" + - + type: "view" + name: "我的宝库" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=myresource#wechat_redirect" - name: "更多" @@ -22,6 +26,10 @@ button: type: "click" name: "加入班级" key: "JOIN_CLASS" + - + type: "click" + name: "加入项目" + key: "JOIN_PROJECT" - type: "click" name: "反馈" From 03d6afd1c45f96d147a55764e1e323ff64eaceb7 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 18 Jul 2016 15:52:04 +0800 Subject: [PATCH 16/99] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=8A=E5=91=A8?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E8=8E=B7=E5=8F=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 20 ++++++++++++++++++++ app/views/courses/show.html.erb | 17 +---------------- config/locales/courses/zh.yml | 10 ++++++++++ 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index d1f4bfe97..ee520cb77 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -591,6 +591,26 @@ module CoursesHelper Course.tagged_with(tag_name).order('updated_at desc') end + # 获取动态列表名称 + def get_acts_list_type type + case type + when "homework" + ">" + l(:label_homework_acts) + when "news" + ">" + l(:label_news_acts) + when "attachment" + ">" + l(:label_attachment_acts) + when "message" + ">" + l(:label_message_acts) + when "journalsForMessage" + ">" + l(:label_journalsForMessage_acts) + when "poll" + ">" + l(:label_poll_acts) + else + ">" + l(:label_all_cats) + end + end + #分班下拉框 def course_group_option course type = [] diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index cabbb5d04..bf209ddb5 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -10,22 +10,7 @@
    班级动态 - <% if params[:type] == "homework" %> - <%= ">作业动态" %> - <% elsif params[:type] == "news" %> - <%= ">通知动态" %> - <% elsif params[:type] == "attachment" %> - <%= ">资源库动态" %> - <% elsif params[:type] == "message" %> - <%= ">论坛动态" %> - <% elsif params[:type] == "journalsForMessage" %> - <%= ">留言动态" %> - <% elsif params[:type] == "poll" %> - <%= ">问卷动态" %> - <% else %> - <%= ">全部动态" %> - <% end %> -
    + <%= get_acts_list_type @type %>
      • diff --git a/config/locales/courses/zh.yml b/config/locales/courses/zh.yml index 29d6b236c..9a07e0fa8 100644 --- a/config/locales/courses/zh.yml +++ b/config/locales/courses/zh.yml @@ -29,6 +29,16 @@ zh: label_upload_files: 上传资源 label_apply_join_course: 申请加入班级 label_apply_for_homework: 申请引用作业 + + #动态名称 + label_homework_acts: 作业动态 + label_news_acts: 通知动态 + label_attachment_acts: 资源库动态 + label_message_acts: 论坛动态 + label_journalsForMessage_acts: 留言动态 + label_poll_acts: 问卷动态 + label_all_cats: 全部动态 + # # 课程托管平台主页 # From fdf925a0b8fbef14a33b80a4a2c20df962af89bf Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 18 Jul 2016 16:40:04 +0800 Subject: [PATCH 17/99] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E7=95=99=E8=A8=80=E5=8A=A8=E6=80=81=EF=BC=9A=E5=A6=82=E5=9B=BE?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E5=BD=93=E5=89=8D=E7=94=A8=E6=88=B7=E8=87=AA?= =?UTF-8?q?=E5=B7=B1=E7=9A=84=E7=95=99=E8=A8=80=E5=8D=B4=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E5=88=A0=E9=99=A4=EF=BC=8C=E2=80=9C=E5=B1=95=E5=BC=80=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E2=80=9D=E5=90=8E=E5=8F=88=E5=8F=AF=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E4=BA=86=EF=BC=8C=E5=88=B7=E6=96=B0=E7=BD=91=E9=A1=B5=E5=90=8E?= =?UTF-8?q?=E5=8F=88=E5=88=A0=E9=99=A4=E4=B8=8D=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 1 - .../users/_course_journalsformessage.html.erb | 6 ++-- app/views/users/_journal_replies.html.erb | 2 +- .../users/_journal_reply_banner.html.erb | 2 +- .../users/_user_journalsformessage.html.erb | 6 ++-- app/views/users/all_journals.js.erb | 2 +- public/javascripts/application.js | 34 ------------------- 7 files changed, 9 insertions(+), 44 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c870fdc3b..ec95ce38b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -3315,7 +3315,6 @@ class UsersController < ApplicationController @journals = get_all_children(journals, obj) @type = 'JournalsForMessage' @user_activity_id = params[:div_id].to_i if params[:div_id] - @allow_delete = params[:allow_delete] when 'Issue' obj = Issue.where('id = ?', params[:id].to_i).first @journals = obj.journals.reorder("created_on desc") diff --git a/app/views/users/_course_journalsformessage.html.erb b/app/views/users/_course_journalsformessage.html.erb index 64ba9f6df..c9fe344ba 100644 --- a/app/views/users/_course_journalsformessage.html.erb +++ b/app/views/users/_course_journalsformessage.html.erb @@ -40,16 +40,16 @@
    <% all_comments = []%> <% count=get_all_children(all_comments, activity).count %> - <% allow_delete = (activity.user == User.current || User.current.admin? || User.current.allowed_to?(:as_teacher,activity.course)) %> + <%# allow_delete = (activity.user == User.current || User.current.admin? || User.current.allowed_to?(:as_teacher,activity.course)) %> <%# count = fetch_user_leaveWord_reply(activity).count %>
    - <%= render :partial => 'users/journal_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :allow_delete => allow_delete} %> + <%= render :partial => 'users/journal_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> <% all_comments = []%> <% comments = get_all_children(all_comments, activity)[0..2] %> <% if count > 0 %>
    - <%= render :partial => 'users/journal_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'JournalsForMessage', :allow_delete => allow_delete, :activity_id =>activity.id}%> + <%= render :partial => 'users/journal_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'JournalsForMessage', :activity_id =>activity.id}%>
    <% end %> diff --git a/app/views/users/_journal_replies.html.erb b/app/views/users/_journal_replies.html.erb index 7fc708ebb..e6b9f6f7b 100644 --- a/app/views/users/_journal_replies.html.erb +++ b/app/views/users/_journal_replies.html.erb @@ -68,7 +68,7 @@ :title => l(:button_reply)) %> - <% if allow_delete %> + <% if comment.creator_user == User.current || User.current.admin? %> <%= link_to('删除', {:controller => 'words', :action => 'destroy', :object_id => comment, :user_id => comment.user, :user_activity_id => user_activity_id, :activity_id => activity_id}, :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "fr mr20", :title => l(:button_delete)) %> <% end %> diff --git a/app/views/users/_journal_reply_banner.html.erb b/app/views/users/_journal_reply_banner.html.erb index c231f473d..25175542f 100644 --- a/app/views/users/_journal_reply_banner.html.erb +++ b/app/views/users/_journal_reply_banner.html.erb @@ -10,7 +10,7 @@
    <%#= format_date(activity.updated_on) %>
    <%if count>3 %> diff --git a/app/views/users/_user_journalsformessage.html.erb b/app/views/users/_user_journalsformessage.html.erb index 4fb79ee2d..dfbe751ef 100644 --- a/app/views/users/_user_journalsformessage.html.erb +++ b/app/views/users/_user_journalsformessage.html.erb @@ -64,15 +64,15 @@
    <% all_comments = []%> <% count=get_all_children(all_comments, activity).count %> - <% allow_delete = (activity.user == User.current || User.current.admin?) %> + <%# allow_delete = (activity.user == User.current || User.current.admin?) %>
    - <%= render :partial => 'users/journal_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :allow_delete => allow_delete} %> + <%= render :partial => 'users/journal_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> <% all_comments = []%> <% comments = get_all_children(all_comments, activity)[0..2] %> <% if count > 0 %>
    - <%= render :partial => 'users/journal_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'JournalsForMessage', :allow_delete => allow_delete, :activity_id =>activity.id}%> + <%= render :partial => 'users/journal_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'JournalsForMessage', :activity_id =>activity.id}%>
    <% end %> diff --git a/app/views/users/all_journals.js.erb b/app/views/users/all_journals.js.erb index b7485def3..b5ccdad9e 100644 --- a/app/views/users/all_journals.js.erb +++ b/app/views/users/all_journals.js.erb @@ -1,7 +1,7 @@ <% if params[:type] == 'HomeworkCommon' %> $('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/homework_replies', :locals => {:comments => @journals, :is_in_course =>@is_in_course,:course_activity=>@course_activity, :is_teacher => @is_teacher, :user_activity_id => @user_activity_id}) %>'); <% elsif params[:type] == 'JournalsForMessage' %> -$('#reply_div_<%= @user_activity_id %>').html('<%=escape_javascript(render :partial => 'users/journal_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :allow_delete => @allow_delete, :activity_id =>params[:id].to_i}) %>'); +$('#reply_div_<%= @user_activity_id %>').html('<%=escape_javascript(render :partial => 'users/journal_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :activity_id =>params[:id].to_i}) %>'); <% elsif params[:type] == 'Message' %> $('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/message_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :activity_id => params[:id].to_i,:is_course => @is_course, :is_board => @is_board}) %>'); <% elsif params[:type] == 'BlogComment' %> diff --git a/public/javascripts/application.js b/public/javascripts/application.js index fb7c6cda2..c3435d153 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1340,40 +1340,6 @@ function expand_all_reply(container, btnid, id, type, div_id) { } } -function expand_journal_reply(container, btnid, id, type, div_id, allow_delete) { - var target = $(container); - var btn = $(btnid); - if (btn.data('init') == '0') { - btn.data('init', 1); - $.get( - '/users/all_journals', - { - type: type, - id: id, - div_id: div_id, - allow_delete: allow_delete - }, - function(data) { - - } - ); - btn.html('收起回复'); - //target.show(); - } else if(btn.data('init') == '1') { - btn.data('init', 3); - btn.html('展开更多'); - target.hide(); - target.eq(0).show(); - target.eq(1).show(); - target.eq(2).show(); - } - else { - btn.data('init', 1); - btn.html('收起回复'); - target.show(); - } -} - function expand_message_reply(container, btnid, id, type, div_id, is_course, is_board) { var target = $(container); var btn = $(btnid); From bc0d8cd299fe8e9772d045ea25eb0d26cee1b4f8 Mon Sep 17 00:00:00 2001 From: txz Date: Tue, 19 Jul 2016 10:25:45 +0800 Subject: [PATCH 18/99] =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=8F=AD=E7=BA=A7?= =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=E5=AD=97=E4=BD=93=E5=8F=98=E7=81=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/edit_class.html | 4 ++-- public/javascripts/wechat/controllers/edit_class.js | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/public/assets/wechat/edit_class.html b/public/assets/wechat/edit_class.html index 5953e046b..d6bc7e03c 100644 --- a/public/assets/wechat/edit_class.html +++ b/public/assets/wechat/edit_class.html @@ -3,9 +3,9 @@
    管理课程
    -
    课程
    +
    课程
    -
    班级删除
    +
    班级删除
    完成
    diff --git a/public/javascripts/wechat/controllers/edit_class.js b/public/javascripts/wechat/controllers/edit_class.js index b5ee1a025..5f377e594 100644 --- a/public/javascripts/wechat/controllers/edit_class.js +++ b/public/javascripts/wechat/controllers/edit_class.js @@ -107,8 +107,4 @@ app.controller('EditClassController', ['$scope', '$http', 'auth', 'config', 'ale } - vm.fadeText = function () { - $scope.change = true; - } - }] ); \ No newline at end of file From bc1b4c1b85efeb091ab0ec12b8af31ea84fed1d3 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Tue, 19 Jul 2016 10:50:36 +0800 Subject: [PATCH 19/99] =?UTF-8?q?=E7=8F=AD=E7=BA=A7=E9=82=80=E8=AF=B7?= =?UTF-8?q?=E7=A0=81=E5=BC=B9=E6=A1=86=E4=BF=AE=E6=94=B9=EF=BC=8C=E6=88=91?= =?UTF-8?q?=E7=9A=84=E5=8A=A8=E6=80=81=E5=9B=9E=E5=A4=8D=E6=95=B0=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/courses.rb | 2 +- app/api/mobile/entities/activity.rb | 20 +++++---- app/api/mobile/entities/blog_comment.rb | 4 +- app/api/mobile/entities/issue.rb | 4 +- app/api/mobile/entities/jours.rb | 4 +- app/api/mobile/entities/message.rb | 3 ++ app/api/mobile/entities/news.rb | 3 ++ app/services/courses_service.rb | 4 +- public/assets/wechat/class_list.html | 3 +- public/assets/wechat/myresource.html | 1 + public/assets/wechat/templates/alert3.html | 15 +++++++ .../wechat/controllers/class_list.js | 43 ++++++++++--------- public/javascripts/wechat/directives/alert.js | 24 +++++++++++ public/javascripts/wechat/others/factory.js | 3 ++ 14 files changed, 97 insertions(+), 36 deletions(-) create mode 100644 public/assets/wechat/templates/alert3.html diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 1c6fd7008..60e00280e 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -397,7 +397,7 @@ module Mobile authenticate! course = Course.find(params[:course_id]) - exercises = course.exercises.where("exercise_status <> 1").order("created_at desc") + exercises = course.exercises.where("exercise_status <> 1").reorder("created_at desc") present :data,exercises,with:Mobile::Entities::Exercise,user: current_user present :status,0 end diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index 9e2a39a5a..bdeff7ae9 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -20,15 +20,17 @@ module Mobile ac.act unless ac.nil? || ac.act.nil? end when :reply_count - if ac.act_type == "HomeworkCommon" - ac.nil? || ac.act.nil? ? 0 : ac.act.journals_for_messages.count - elsif ac.act_type == "News" - ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count - elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" - ac.nil? || ac.act.nil? ? 0 : ac.act.children.count - elsif ac.act_type == "Issue" - ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count - end + # if ac.act_type == "HomeworkCommon" + # ac.nil? || ac.act.nil? ? 0 : ac.act.journals_for_messages.count + # elsif ac.act_type == "News" + # ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count + # elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" + # ac.nil? || ac.act.nil? ? 0 : ac.act.children.count + # elsif ac.act_type == "Issue" + # ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count + # end + all_comments = [] + ac.nil? || ac.act.nil? ? 0 : get_all_children(all_comments, ac.act).count when :subject if ac.act_type == "HomeworkCommon" ac.act.name unless ac.nil? || ac.act.nil? diff --git a/app/api/mobile/entities/blog_comment.rb b/app/api/mobile/entities/blog_comment.rb index 67904d11e..a61864900 100644 --- a/app/api/mobile/entities/blog_comment.rb +++ b/app/api/mobile/entities/blog_comment.rb @@ -25,7 +25,9 @@ module Mobile when :act_id u.id when :comment_count - u.children.count + # u.children.count + all_comments = [] + get_all_children(all_comments, u).count end end end diff --git a/app/api/mobile/entities/issue.rb b/app/api/mobile/entities/issue.rb index ef3d09450..b99ea03a5 100644 --- a/app/api/mobile/entities/issue.rb +++ b/app/api/mobile/entities/issue.rb @@ -23,7 +23,9 @@ module Mobile when :issue_status IssueStatus.find(issue.status_id).name when :journals_count - issue.journals.where("notes is not null and notes != ''").count + # issue.journals.where("notes is not null and notes != ''").count + all_comments = [] + get_all_children(all_comments, f).count when :project_name issue.project.name when :praise_count diff --git a/app/api/mobile/entities/jours.rb b/app/api/mobile/entities/jours.rb index 15e22174c..f98d7a9ed 100644 --- a/app/api/mobile/entities/jours.rb +++ b/app/api/mobile/entities/jours.rb @@ -18,7 +18,9 @@ module Mobile when :lasted_comment time_from_now f.created_on when :reply_count - f.children.count + # f.children.count + all_comments = [] + get_all_children(all_comments, f).count when :praise_count get_activity_praise_num(f) when :act_type diff --git a/app/api/mobile/entities/message.rb b/app/api/mobile/entities/message.rb index 051c92886..d58192378 100644 --- a/app/api/mobile/entities/message.rb +++ b/app/api/mobile/entities/message.rb @@ -30,6 +30,9 @@ module Mobile 'Message' when :act_id u.id + when :replies_count + all_comments = [] + get_all_children(all_comments, u).count end end end diff --git a/app/api/mobile/entities/news.rb b/app/api/mobile/entities/news.rb index 4f973d82e..ff1452b1c 100644 --- a/app/api/mobile/entities/news.rb +++ b/app/api/mobile/entities/news.rb @@ -24,6 +24,9 @@ module Mobile 'News' when :act_id f.id + when :comments_count + all_comments = [] + get_all_children(all_comments, f).count end end elsif f.is_a?(Hash) && !f.key?(field) diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 39c77de4b..091e2749e 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -392,7 +392,7 @@ class CoursesService def homework_list params,current_user course = Course.find(params[:id]) if course.is_public != 0 || current_user.member_of_course?(course) - bids = course.homework_commons.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).page(params[:page] || 1).per(20).order('created_at DESC') + bids = course.homework_commons.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).page(params[:page] || 1).per(20).reorder('created_at DESC') bids = bids.like(params[:name]) if params[:name].present? homeworks = [] bids.each do |bid| @@ -495,7 +495,7 @@ class CoursesService def course_attachments params result = [] course = Course.find(params[:course_id]) - attachments = course.attachments.where("is_publish = 1").order("created_on desc") + attachments = course.attachments.where("is_publish = 1").reorder("created_on desc") if !params[:name].nil? && params[:name] != "" attachments.each do |atta| result << atta if atta.filename.include?(params[:name]) diff --git a/public/assets/wechat/class_list.html b/public/assets/wechat/class_list.html index a3c709cb5..d0074f343 100644 --- a/public/assets/wechat/class_list.html +++ b/public/assets/wechat/class_list.html @@ -36,5 +36,6 @@ 我的资源
    - + +
    \ No newline at end of file diff --git a/public/assets/wechat/myresource.html b/public/assets/wechat/myresource.html index c06c57238..90fb13892 100644 --- a/public/assets/wechat/myresource.html +++ b/public/assets/wechat/myresource.html @@ -20,6 +20,7 @@

    暂无课件,
    请登录Trustie网站,在PC浏览器中上传课件。

    +
    {{r.homework_name}}发送
    diff --git a/public/assets/wechat/templates/alert3.html b/public/assets/wechat/templates/alert3.html new file mode 100644 index 000000000..11e2c6d28 --- /dev/null +++ b/public/assets/wechat/templates/alert3.html @@ -0,0 +1,15 @@ +
    +
    +
    +

    {{message}}

    +
    + +
    + 取消 +
    +
    +
    + 确定 +
    +
    +
    \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/class_list.js b/public/javascripts/wechat/controllers/class_list.js index b3f8a6ea3..9e0087135 100644 --- a/public/javascripts/wechat/controllers/class_list.js +++ b/public/javascripts/wechat/controllers/class_list.js @@ -8,7 +8,8 @@ app.controller('ClassListController', ['$scope', 'config', 'auth', '$http', '$lo var vm = $scope; vm.syllabuses = rms.get('syllabuses') || []; - vm.alertService = alertService.create(); + vm.alertService_1 = alertService.create(); + vm.alertService_3 = alertService.create(); var loadClassList = function () { $http.get(config.apiUrl + "syllabuses?token=" + auth.token()).then( @@ -36,7 +37,7 @@ app.controller('ClassListController', ['$scope', 'config', 'auth', '$http', '$lo function (response) { console.log(response.data); if (response.data.auth == 0) { - vm.alertService.showMessage('提示', '非教师身份不能创建课程哦~'); + vm.alertService_1.showMessage('提示', '非教师身份不能创建课程哦~'); } else{ $location.path("/new_class"); @@ -50,26 +51,28 @@ app.controller('ClassListController', ['$scope', 'config', 'auth', '$http', '$lo } vm.joinClass = function () { - var code = window.prompt("请输入5位班级邀请码(不区分大小写)"); - if (code && code.length == 5) { - $http.post(config.apiUrl + "courses/join", { - token: auth.token(), - invite_code: code - }).then(function (response) { - console.log(response.data); - if (response.data.status != 0) { - vm.alertService.showMessage('错误', response.data.message); - } else { - vm.alertService.showMessage('提示', '加入课程成功'); - loadClassList(); + vm.alertService_3.showMessage('提示', '请输入5位班级邀请码(不区分大小写)', function(){ + if (vm.alertService_3.invite && vm.alertService_3.invite.length == 5) { + $http.post(config.apiUrl + "courses/join", { + token: auth.token(), + invite_code: vm.alertService_3.invite + }).then(function (response) { + console.log(response.data); + if (response.data.status != 0) { + vm.alertService_1.showMessage('错误', response.data.message); + } else { + vm.alertService_1.showMessage('提示', '加入课程成功'); + vm.alertService_3.invite = ""; + loadClassList(); + } + }); + } else { + if(vm.alertService_3.invite){ + vm.alertService_1.showMessage('错误', '邀请码格式不正确'); } - }); - } else { - if(code){ - vm.alertService.showMessage('错误', '邀请码格式不正确'); - } - } + } + }); }; vm.onSetting = function (syllabus) { diff --git a/public/javascripts/wechat/directives/alert.js b/public/javascripts/wechat/directives/alert.js index 4b703811c..e9401de34 100644 --- a/public/javascripts/wechat/directives/alert.js +++ b/public/javascripts/wechat/directives/alert.js @@ -40,3 +40,27 @@ app.directive('myAlert2', ['config', function(config){ } } }]); + +app.directive('myAlert3', ['config', function(config){ + return { + templateUrl: config.rootPath+ 'templates/alert3.html', + scope: { + title: "=", + message: "=", + visible: "=", + cb: "=", + invite: "=" + }, + link: function(scope){ + scope.dismiss = function(){ + scope.visible = false; + }; + scope.confirm = function(){ + scope.visible = false; + if(typeof scope.cb === 'function'){ + scope.cb(); + } + } + } + } +}]); diff --git a/public/javascripts/wechat/others/factory.js b/public/javascripts/wechat/others/factory.js index 6c7709df3..2b0d4f994 100644 --- a/public/javascripts/wechat/others/factory.js +++ b/public/javascripts/wechat/others/factory.js @@ -4,6 +4,7 @@ app.factory('alertService', function(){ this.message = null; this.visible = null; this.cb = null; + this.invite = ""; } Alert.prototype.showMessage = function(title, msg, cb){ @@ -11,12 +12,14 @@ app.factory('alertService', function(){ this.title = title; this.visible = true; this.cb = cb; + this.invite = ""; } Alert.prototype.dismiss = function(){ this.message = null; this.title = null; this.visible = false; + this.invite = ""; if(this.cb) {this.cb();} } From ea88c92d31a1e815042d1f82d5ab694a437d2625 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Tue, 19 Jul 2016 10:54:04 +0800 Subject: [PATCH 20/99] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/api.rb | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index 9b4bdb5d6..5a0345207 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -1,25 +1,25 @@ #coding=utf-8 module Mobile - require_relative 'middleware/error_handler' - require_relative 'apis/auth' - require_relative 'apis/users' - require_relative 'apis/courses' - require_relative 'apis/watches' - require_relative 'apis/upgrade' - require_relative 'apis/homeworks' - require_relative 'apis/comments' - require_relative 'apis/issues' - require_relative 'apis/activities' - require_relative 'apis/whomeworks' - require_relative 'apis/newss' - require_relative 'apis/journal_for_messages' - require_relative 'apis/messages' - require_relative 'apis/blog_comments' - require_relative 'apis/new_comment' - require_relative 'apis/praise' - require_relative 'apis/resources' - require_relative 'apis/syllabuses' + # require_relative 'middleware/error_handler' + # require_relative 'apis/auth' + # require_relative 'apis/users' + # require_relative 'apis/courses' + # require_relative 'apis/watches' + # require_relative 'apis/upgrade' + # require_relative 'apis/homeworks' + # require_relative 'apis/comments' + # require_relative 'apis/issues' + # require_relative 'apis/activities' + # require_relative 'apis/whomeworks' + # require_relative 'apis/newss' + # require_relative 'apis/journal_for_messages' + # require_relative 'apis/messages' + # require_relative 'apis/blog_comments' + # require_relative 'apis/new_comment' + # require_relative 'apis/praise' + # require_relative 'apis/resources' + # require_relative 'apis/syllabuses' class API < Grape::API version 'v1', using: :path From 27965bee01f71556b32854ed285b8d9093b805c2 Mon Sep 17 00:00:00 2001 From: txz Date: Tue, 19 Jul 2016 11:17:46 +0800 Subject: [PATCH 21/99] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E7=8F=AD=E7=BA=A7?= =?UTF-8?q?=E5=BC=B9=E6=A1=86=E6=A0=B7=E5=BC=8F=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/templates/alert3.html | 4 ++-- public/stylesheets/weui/weixin.css | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/public/assets/wechat/templates/alert3.html b/public/assets/wechat/templates/alert3.html index 11e2c6d28..c7516450c 100644 --- a/public/assets/wechat/templates/alert3.html +++ b/public/assets/wechat/templates/alert3.html @@ -5,11 +5,11 @@
    - 取消 + 取消
    - 确定 + 确定
    \ No newline at end of file diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index 7082955e3..a81541e39 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -55,6 +55,8 @@ blockquote {border:1px solid #d4d4d4; padding: 0.6em; margin: 5px 0.4em 5px 1.4e a {color:#707070;} a.c-grey {color:#707070;} a.c-grey2 {color:#9a9a9a;} +a.c-grey3 {color:#353535;} +a.c-green {color:#0bb20c;} a:link,a:visited{text-decoration:none;} a:hover,a:active{cursor:pointer;} a.link-blue {color:#269ac9;} @@ -154,7 +156,7 @@ a.underline {text-decoration:underline;} /*20150612加入班级样式*/ .add-class-box {position:fixed; width:80%; max-width:300px; min-width:240px; font-size:15px; color:#444; background-color:#fff; margin:0 auto; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); border-radius:5px; top:50%; left:50%; transform: translate(-50%,-50%);} -.add-class-tip {padding-top:20px; padding-bottom:20px;} +.add-class-tip {padding-top:1.2em; padding-bottom:.5em; font-weight:400;} .class-number-input {width:80%; max-width:240px; height:28px; border:1px solid #ccc; padding-left:5px; margin:0 auto; display:block;} .cancel-btn {width:49%; height:37px; line-height:37px; text-align:center; vertical-align:middle; border-top:1px solid #ccc;} .submit-btn {width:49%; height:37px; line-height:37px; text-align:center; vertical-align:middle; border-top:1px solid #ccc;} From 2af1a5ffb9fd111f8fc299facf688edeea54157a Mon Sep 17 00:00:00 2001 From: txz Date: Tue, 19 Jul 2016 15:07:11 +0800 Subject: [PATCH 22/99] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=8F=AD=E7=BA=A7?= =?UTF-8?q?=E5=92=8C=E7=AE=A1=E7=90=86=E7=8F=AD=E7=BA=A7=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=A1=86=E9=AB=98=E5=BA=A6=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/weui/weixin.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index a81541e39..ac3faeec4 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -155,7 +155,7 @@ a.underline {text-decoration:underline;} .locked_btn_cir {background: url("/images/wechat/locked.png") 0 0 no-repeat; cursor: default;} /*20150612加入班级样式*/ -.add-class-box {position:fixed; width:80%; max-width:300px; min-width:240px; font-size:15px; color:#444; background-color:#fff; margin:0 auto; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); border-radius:5px; top:50%; left:50%; transform: translate(-50%,-50%);} +.add-class-box {position:fixed; width:80%; max-width:300px; min-width:240px; font-size:15px; color:#444; background-color:#fff; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); border-radius:5px; top:50%; left:50%; transform: translate(-50%,-50%);} .add-class-tip {padding-top:1.2em; padding-bottom:.5em; font-weight:400;} .class-number-input {width:80%; max-width:240px; height:28px; border:1px solid #ccc; padding-left:5px; margin:0 auto; display:block;} .cancel-btn {width:49%; height:37px; line-height:37px; text-align:center; vertical-align:middle; border-top:1px solid #ccc;} @@ -211,7 +211,7 @@ a.underline {text-decoration:underline;} .students-amount {height:14px; line-height:14px; vertical-align:middle; padding:2px 5px; background-color:#e6e6e6; border-radius:10px;} .new-class-btn {font-size:15px; color:#fff; background-color:#3b94d6; padding:10px 40px; border-radius:20px; display:inline-block; margin:0 auto;} .join-class-btn {font-size:15px; color:#444; background-color:#ccc; padding:10px 40px; border-radius:20px; display:inline-block; margin:0 auto;} -.new-class-input {width:60%; color:#555; height:35px; line-height:35px; vertical-align:middle; border:none; outline:none;} +.new-class-input {width:60%; color:#555; height:16px; line-height:16px; vertical-align:middle; border:none; outline:none; padding:10px 0;} /*20160616登录注册*/ .login-wrap {padding:0 10px;} From 5b3c6cc012be4e08cc6a04a75a2fe5d272def8d3 Mon Sep 17 00:00:00 2001 From: txz Date: Tue, 19 Jul 2016 15:41:40 +0800 Subject: [PATCH 23/99] =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=A1=86=E9=AB=98?= =?UTF-8?q?=E5=BA=A6=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/directives/input_auto.js | 4 ++-- public/stylesheets/weui/weixin.css | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/javascripts/wechat/directives/input_auto.js b/public/javascripts/wechat/directives/input_auto.js index 28cb792ab..1f2550882 100644 --- a/public/javascripts/wechat/directives/input_auto.js +++ b/public/javascripts/wechat/directives/input_auto.js @@ -8,11 +8,11 @@ app.directive('inputAuto',function(){ element.on('input',function(){ console.log(sendButton); copyContainer.html(element[0].value); - var textHeight = copyContainer[0].scrollHeight; + var textHeight = copyContainer[0].scrollHeight-10; element.css('height', textHeight + 'px'); }); sendButton.on('click',function(){ - element.css('height','28px'); + element.css('height','18px'); }); } } diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index ac3faeec4..a5b7d3a7a 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -129,8 +129,8 @@ a.underline {text-decoration:underline;} .post-reply-date, .post-reply-trigger {font-size:13px;} .post-input-container {position:relative; padding-right:70px;} .copy-input-container {position:relative; padding-right:70px;} -.copy-input {width:100%; height:28px; line-height:28px; padding:0 5px; vertical-align: middle; font-size:12px; border-radius:3px; position:absolute; left:-999em;} -.post-reply-input {width:100%; height:28px; max-height:84px; line-height:28px; vertical-align: middle; font-size:13px; border:1px solid #e6e6e6; outline:none; padding:0 5px; margin:0; border-radius:3px; overflow-y:auto; resize:none; background-color:#f0eff4;} +.copy-input {width:100%; height:18px; line-height:18px; padding:5px; vertical-align: middle; font-size:12px; border-radius:3px; position:absolute; left:-999em;} +.post-reply-input {width:100%; height:18px; max-height:54px; line-height:18px; vertical-align: middle; font-size:13px; border:1px solid #e6e6e6; outline:none; padding:5px; margin:0; border-radius:3px; overflow-y:auto; resize:none; background-color:#f0eff4;} .post-reply-submit {position:absolute; font-size:13px; height:30px; line-height:30px; vertical-align:middle; padding:0 8px; color:#fff; background-color:#269ac9; outline:none; border:none; top:0; right:0;} .reply-icon {background:url(/images/wechat/icon_list.gif) -150px -155px no-repeat; width:20px; height:20px; display:inline-block; vertical-align:middle;} .praise-icon {background:url(/images/wechat/icon_list.gif) -36px -88px no-repeat; width:20px; height:20px; display:inline-block; vertical-align:middle;} From cf04bb5ec6b6257d4d46ae52271079c2e56aa0c0 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 19 Jul 2016 15:59:52 +0800 Subject: [PATCH 24/99] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E4=B8=8A=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 2 +- app/controllers/repositories_controller.rb | 2 +- app/models/changeset.rb | 4 ++-- lib/tasks/gitlab_act_project.rake | 5 +++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 03dbb5785..a94f1b33b 100644 --- a/Gemfile +++ b/Gemfile @@ -51,7 +51,7 @@ gem 'elasticsearch-rails' ### profile -gem 'oneapm_rpm' +# gem 'oneapm_rpm' group :development do gem 'grape-swagger' diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 6b41e39fc..65b4a15d6 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -48,7 +48,7 @@ class RepositoriesController < ApplicationController include RepositoriesHelper helper :project_score #@root_path = RepositoriesHelper::ROOT_PATH - require 'net/ssh' + # require 'net/ssh' rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed def new diff --git a/app/models/changeset.rb b/app/models/changeset.rb index f72342257..20b919d37 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -23,7 +23,7 @@ class Changeset < ActiveRecord::Base has_many :filechanges, :class_name => 'Change', :dependent => :delete_all # fq - has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy + has_many :forge_activities, :class_name => 'ForgeActivity', :as => :forge_act, :dependent => :destroy # end #Added by nie @@ -118,7 +118,7 @@ class Changeset < ActiveRecord::Base # 项目中提交动态,类型Changeset # type:0 为老版本即Trsutie数据 1为gitlab中获取的动态 def act_as_forge_activity - self.acts << ForgeActivity.new(:user_id => self.user_id, :project_id => self.project_id, :type => true) + self.forge_acts << ForgeActivity.new(:user_id => self.user_id, :project_id => self.project_id, :type => true) end def scan_for_issues diff --git a/lib/tasks/gitlab_act_project.rake b/lib/tasks/gitlab_act_project.rake index ee9ca1a9a..91990b175 100644 --- a/lib/tasks/gitlab_act_project.rake +++ b/lib/tasks/gitlab_act_project.rake @@ -11,8 +11,9 @@ namespace :gitlab do # 总的提交次数 commit_count = g.user_static(project.gpid, :rev => g_default_branch).count pages = commit_count / 20 + 1 - pages.each do |page| - commits = g.commits(g_project.gpid, :ref_name => g_default_branch, :page => page) + puts "#{pages}" + (0..pages).each do |page| + commits = g.commits(project.gpid, :ref_name => g_default_branch, :page => page) commits.each do |commit| Changeset.create(:project_id => project.id, :repository_id => project.gpid, :revision => commit.id, :committer => commit.author_email, :comments => Redmine::CodesetUtil.to_utf8(commit.title, 'UTF-8'), :committed_on => commit.created_at) end From 707df88c7f7fa964ae43f3ac745bcc07556d06b2 Mon Sep 17 00:00:00 2001 From: txz Date: Tue, 19 Jul 2016 16:05:39 +0800 Subject: [PATCH 25/99] =?UTF-8?q?tab=E5=AE=B9=E5=99=A8=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E7=99=BE=E5=88=86=E7=99=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/weui/weixin.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index a5b7d3a7a..8a755b323 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -86,7 +86,7 @@ a.underline {text-decoration:underline;} .btn2 {width:145px; height:35px; color:#fff; font-size:15px; line-height:35px; text-align:center; vertical-align:middle; margin:18px auto 20px auto; border-radius:50px; display:block;} /*tab*/ -.tab-wrap {position:relative; line-height:38px; display:-webkit-box; display:-moz-box; display:-ms-flexbox; display:-webkit-flex; display:flex; font-size:13px; background-color:#fff;} +.tab-wrap {position:relative; width:100%; line-height:38px; display:-webkit-box; display:-moz-box; display:-ms-flexbox; display:-webkit-flex; display:flex; font-size:13px; background-color:#fff;} .tab-wrap a {position:relative; display:block; -webkit-box-flex:1; -moz-box-flex:1; -ms-flex:1; flex:1;} .tab-wrap a:first-child:after {display:none;} .tab-wrap a:after {content:" "; position:absolute; left:0; top:0; width:1px; height:100%; border-left:1px solid #ccc; color:#707070;} From 7808bb5ebec68f357471016efe883a23b3e7db12 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 19 Jul 2016 17:37:39 +0800 Subject: [PATCH 26/99] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=9D=9E=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E8=BF=9C=E7=94=A8=E6=88=B7=E5=B8=96=E5=AD=90=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E7=AE=A1=E7=90=86=E5=91=98=E5=B8=96=E5=AD=90=E7=BD=AE?= =?UTF-8?q?=E9=A1=B6=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/views/boards/_course_new.html.erb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/views/boards/_course_new.html.erb b/app/views/boards/_course_new.html.erb index df61d2b9c..32cec24d5 100644 --- a/app/views/boards/_course_new.html.erb +++ b/app/views/boards/_course_new.html.erb @@ -130,11 +130,13 @@

    - <% unless @comments.empty? %> -
    -
    回复(<%=@comments.count %>)
    -
    -
    -
    - <% @comments.each_with_index do |reply,i| %> - -
    -
    - <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %> -
    -
    -
    - <% if reply.try(:author).try(:realname) == ' ' %> - <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> - <% else %> - <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> - <% end %> -
    -
    - <%= reply.comments.html_safe%> -
    -
    - <%= format_time(reply.created_on) %> - -
    -

    -
    -
    -
    - <% end %> -
    - - <% end %> -
    - <% if @news.commentable? %> -
    - -
    -
    - <%= form_for @comment, :url=>{:controller => 'comments', :action => 'create', :id => @news}, :html => {:multipart => true, :id => 'add_comment_form'} do |f| %> -
    - <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> - <%= f.kindeditor :comments, :editor_id => 'comment_editor', - :owner_id => @comment.nil? ? 0: @comment.id, - :owner_type => OwnerTypeHelper::COMMENT, - :width => '99%', - :height => 100, - :minHeight=>100, - :input_html => { :id => 'comment_content', - :class => 'talk_text fl', - :maxlength => 5000 }%> -
    -

    -

    - - <%= l(:label_cancel_with_space) %> - - - <%= l(:label_comment_with_space) %> - -

    - <% end %> -
    -
    -
    - <% end %> + <%= render :partial => 'news/news_all_replies' %>
    @@ -97,90 +82,7 @@
    - <% unless @comments.empty? %> -
    -
    回复(<%=@comments.count %>)
    -
    -
    -
    - <% @comments.each_with_index do |reply,i| %> - -
    -
    - <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %> -
    -
    -
    - <% if reply.try(:author).try(:realname) == ' ' %> - <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> - <% else %> - <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> - <% end %> -
    -
    - <%= reply.comments.html_safe%> -
    -
    - <%= format_time(reply.created_on) %> - -
    -

    -
    -
    -
    - <% end %> -
    - - <% end %> -
    - <% if @news.commentable? %> -
    - -
    -
    - <%= form_for @comment, :url=>{:controller => 'comments', :action => 'create', :id => @news}, :html => {:multipart => true, :id => 'add_comment_form'} do |f| %> -
    - <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> - <%= f.kindeditor :comments, :editor_id => 'comment_editor', - :owner_id => @comment.nil? ? 0: @comment.id, - :owner_type => OwnerTypeHelper::COMMENT, - :width => '99%', - :height => 100, - :minHeight=>100, - :input_html => { :id => 'comment_content', - :class => 'talk_text fl', - :maxlength => 5000 }%> -
    -

    -

    - - <%= l(:label_cancel_with_space) %> - - - <%= l(:label_comment_with_space) %> - -

    - <% end %> -
    -
    -
    - <% end %> + <%= render :partial => 'news/news_all_replies' %>
    -
  • -
    - <%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_user.id) %> -
    -
    -
    - <%= link_to comment.creator_user.show_name, user_url_in_org(comment.creator_user.id), :class => "newsBlue mr10 f14" %> - <%= time_from_now(comment.created_on) %> -
    - <% if !comment.parent.nil? && !comment.parent.parent.nil? %> - <%= render :partial => 'users/message_contents', :locals => {:comment => comment}%> - <% end %> - <% 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 => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => type, :user_activity_id => user_activity_id, :activity_id => activity_id, :homepage => homepage}, - :remote => true, - :method => 'get', - :title => l(:button_reply)) if !comment.root.locked? %> - - - <% if comment.author == User.current %> - <%= link_to( - l(:button_delete), - {:controller => 'blog_comments',:action => 'destroy', :id => comment.id, :user_activity_id => user_activity_id, :homepage => homepage}, - :method => :delete, - :remote => true, - :class => 'fr mr20', - :data => {:confirm => l(:text_are_you_sure)}, - :title => l(:button_delete)) %> - <% end %> - -
    -
    -
    -

    - <% end %> -
    -
    -
  • - <% end %> - \ No newline at end of file diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index 783193e46..874a6b403 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -294,28 +294,12 @@ <% count=activity.journals_for_messages.count %>
    -
    -
    回复 - ︿ - <%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - -
    -
    - <%if count>3 %> - - <% end %> -
    + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity} %> <% comments = activity.journals_for_messages.reorder("created_on desc").limit(3) %> <% if count > 0 %>
    - <%=render :partial => 'users/homework_replies', :locals => {:comments => comments, :is_in_course => -1,:course_activity=>course_activity, :is_teacher => is_teacher, :user_activity_id => user_activity_id} %> + <%=render :partial => 'users/news_replies', :locals => {:comments => comments, :type => 'HomeworkCommon', :is_in_course => -1,:course_activity=>course_activity, :is_teacher => is_teacher, :user_activity_id => user_activity_id} %>
    <% end %> diff --git a/app/views/users/_course_journalsformessage.html.erb b/app/views/users/_course_journalsformessage.html.erb index c9fe344ba..3225a1a8b 100644 --- a/app/views/users/_course_journalsformessage.html.erb +++ b/app/views/users/_course_journalsformessage.html.erb @@ -40,16 +40,14 @@
    <% all_comments = []%> <% count=get_all_children(all_comments, activity).count %> - <%# allow_delete = (activity.user == User.current || User.current.admin? || User.current.allowed_to?(:as_teacher,activity.course)) %> - <%# count = fetch_user_leaveWord_reply(activity).count %>
    - <%= render :partial => 'users/journal_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> <% all_comments = []%> <% comments = get_all_children(all_comments, activity)[0..2] %> <% if count > 0 %>
    - <%= render :partial => 'users/journal_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'JournalsForMessage', :activity_id =>activity.id}%> + <%= render :partial => 'users/message_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'JournalsForMessage', :activity_id =>activity.id}%>
    <% end %> diff --git a/app/views/users/_course_message.html.erb b/app/views/users/_course_message.html.erb index 48daa6e95..0c16a4367 100644 --- a/app/views/users/_course_message.html.erb +++ b/app/views/users/_course_message.html.erb @@ -81,7 +81,7 @@ <% all_comments = []%> <% count=get_all_children(all_comments, activity).count %>
    - <%= render :partial => 'users/message_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id,:is_course => is_course,:is_board =>is_board} %> + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id,:is_course => is_course,:is_board =>is_board} %> <% all_comments = []%> <% comments = get_all_children(all_comments, activity)[0..2] %> diff --git a/app/views/users/_course_news.html.erb b/app/views/users/_course_news.html.erb index 18f16b068..f46282ff8 100644 --- a/app/views/users/_course_news.html.erb +++ b/app/views/users/_course_news.html.erb @@ -62,6 +62,7 @@
    + <% count=activity.comments.count %>
    <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> @@ -69,31 +70,32 @@ <% comments = activity.comments.reorder("created_on desc").limit(3) %> <% if count > 0 %>
    - <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%> + <%= render :partial => 'users/news_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'News', :activity_id => activity.id} %> +
    + <% end %> + <% if activity.commentable? %> +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
    +
    + <% if User.current.logged? %> +
    + <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%> + +
    + + +
    +

    + <% end%> +
    + <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %> +
    +
    +
    <% end %> - -
    -
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
    -
    - <% if User.current.logged? %> -
    - <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%> - -
    - - -
    -

    - <% end%> -
    - <% else %> - <%= render :partial => "users/show_unlogged" %> - <% end %> -
    -
    -
    -
    -
  • -
    - <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %> -
    -
    -
    - <%= link_to comment.user.show_name, user_path(comment.user_id), :class => "newsBlue mr10 f14" %> - <%= time_from_now(comment.created_on) %> -
    - <% unless comment.m_parent_id.nil? %> - <% parents_rely = [] %> - <% parents_rely = get_reply_parents parents_rely, comment %> - <% length = parents_rely.length %> -
    - <% if length <= 3 %> - <%=render :partial => 'users/comment_reply', :locals => {:comment => comment.parent} %> - <% else %> -
    -
    -
    - <%=render :partial => 'users/comment_reply', :locals => {:comment => parents_rely[length - 1]} %> -
    - <%=render :partial => 'users/comment_reply_detail', :locals => {:comment => parents_rely[length - 2]} %> -
    -
    - - - <%= link_to '点击展开隐藏楼层', show_all_replies_users_path(:comment => comment, :type => comment.class),:remote=>true %> -
    - <%=render :partial => 'users/comment_reply_detail', :locals => {:comment => parents_rely[0]} %> -
    - <% end %> -
    - <% end %> -
    - <%= comment.notes.html_safe %> -
    -
    -
    - - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> - - - <%= link_to( - l(:button_reply), - {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => 'HomeworkCommon', :is_in_course => is_in_course, :user_activity_id => user_activity_id, :course_activity => course_activity}, - :remote => true, - :method => 'get', - :title => l(:button_reply)) %> - - - - <% if User.current.admin? ||is_teacher || comment.user == User.current%> - <%= link_to('删除', {:controller => 'words', :action => 'destroy', :object_id => comment, :user_id => comment.user,:is_in_course => is_in_course, :user_activity_id => user_activity_id, :course_activity => course_activity}, - :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "fr mr20", :title => l(:button_delete)) %> - <% end %> - -
    -
    -
    -

    -
    -
    -
  • - <% end %> - \ No newline at end of file diff --git a/app/views/users/_journal_reply_banner.html.erb b/app/views/users/_journal_reply_banner.html.erb deleted file mode 100644 index 25175542f..000000000 --- a/app/views/users/_journal_reply_banner.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -
    -
    - 回复 - ︿ - <%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - -
    -
    <%#= format_date(activity.updated_on) %>
    - <%if count>3 %> -
    - - 展开更多 - -
    - <% end %> -
    \ No newline at end of file diff --git a/app/views/users/_message_replies.html.erb b/app/views/users/_message_replies.html.erb index c6f9d91b0..10a8e2b55 100644 --- a/app/views/users/_message_replies.html.erb +++ b/app/views/users/_message_replies.html.erb @@ -13,7 +13,7 @@
    <%= link_to comment.creator_user.show_name, user_url_in_org(comment.creator_user.id), :class => "newsBlue mr10 f14" %> - <%= time_from_now(comment.created_on) %> + <%= time_from_now(comment.respond_to?(:created_on) ? comment.created_on : comment.created_at) %>
    <% if !comment.parent.nil? && !comment.parent.parent.nil? %> <%= render :partial => 'users/message_contents', :locals => {:comment => comment}%> @@ -28,6 +28,7 @@ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + <% if type == 'Message' %> <%= link_to( l(:button_reply), @@ -37,7 +38,7 @@ :title => l(:button_reply)) %> - <% if comment.course_destroyable_by?(User.current) %> + <% if comment.course_destroyable_by?(User.current) %> <%= link_to( l(:button_delete), delete_board_message_path(comment,:board_id =>comment.board.id, :user_activity_id => user_activity_id, :activity_id => activity_id, :is_course => is_course, :is_board => is_board), @@ -48,6 +49,61 @@ :title => l(:button_delete) ) %> <% end %> + <% elsif type == 'JournalsForMessage' %> + + <%= link_to( + l(:button_reply), + {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => type, :user_activity_id => user_activity_id, :activity_id => activity_id}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) %> + + + <% if comment.creator_user == User.current || User.current.admin? %> + <%= link_to('删除', {:controller => 'words', :action => 'destroy', :object_id => comment, :user_id => comment.user, :user_activity_id => user_activity_id, :activity_id => activity_id}, + :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "fr mr20", :title => l(:button_delete)) %> + <% end %> + <% elsif type == 'OrgDocumentComment' %> + + <%= link_to( + l(:button_reply), + {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => type, :user_activity_id => user_activity_id, :activity_id => activity_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 => 'destroy', :id => comment.id, :user_activity_id => user_activity_id}, + :method => :delete, + :remote => true, + :class => 'fr mr20', + :data => {:confirm => l(:text_are_you_sure)}, + :title => l(:button_delete)) %> + <% end %> + <% elsif type == 'BlogComment' %> + + <%= link_to( + l(:button_reply), + {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => type, :user_activity_id => user_activity_id, :activity_id => activity_id, :homepage => homepage}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) if !comment.root.locked? %> + + + <% if comment.author == User.current %> + <%= link_to( + l(:button_delete), + {:controller => 'blog_comments',:action => 'destroy', :id => comment.id, :user_activity_id => user_activity_id, :homepage => homepage}, + :method => :delete, + :remote => true, + :class => 'fr mr20', + :data => {:confirm => l(:text_are_you_sure)}, + :title => l(:button_delete)) %> + <% end %> + <% end %>
    diff --git a/app/views/users/_message_reply_banner.html.erb b/app/views/users/_message_reply_banner.html.erb deleted file mode 100644 index 0c8cda379..000000000 --- a/app/views/users/_message_reply_banner.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -
    -
    - 回复 - ︿ - <%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - -
    -
    <%#= format_date(activity.updated_on) %>
    - <%if count>3 %> -
    - - 展开更多 - -
    - <% end %> -
    \ No newline at end of file diff --git a/app/views/users/_journal_replies.html.erb b/app/views/users/_news_replies.html.erb similarity index 58% rename from app/views/users/_journal_replies.html.erb rename to app/views/users/_news_replies.html.erb index e6b9f6f7b..e6f28b653 100644 --- a/app/views/users/_journal_replies.html.erb +++ b/app/views/users/_news_replies.html.erb @@ -13,20 +13,20 @@
    <%= link_to comment.creator_user.show_name, user_url_in_org(comment.creator_user.id), :class => "newsBlue mr10 f14" %> - <%= time_from_now(comment.created_on) %> + <%= time_from_now(comment.respond_to?(:created_on) ? comment.created_on : comment.created_at) %>
    - <% if !comment.parent.nil? && !comment.parent.parent.nil? %> + <% if !comment.parent.nil? %> <% parents_rely = [] %> - <% parents_rely = get_reply_parents_no_root parents_rely, comment %> + <% parents_rely = get_reply_parents parents_rely, comment %> <% length = parents_rely.length %>
    <% if length <= 3 %> - <%=render :partial => 'users/journal_comment_reply', :locals => {:comment => comment.parent} %> + <%=render :partial => 'users/comment_reply', :locals => {:comment => comment.parent} %> <% else %>
    - <%=render :partial => 'users/journal_comment_reply', :locals => {:comment => parents_rely[length - 1]} %> + <%=render :partial => 'users/comment_reply', :locals => {:comment => parents_rely[length - 1]} %>
    <%=render :partial => 'users/comment_reply_detail', :locals => {:comment => parents_rely[length - 2]} %>
    @@ -56,22 +56,36 @@
    - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + + <%= render :partial => "praise_tread/praise", :locals => {:activity => comment, :user_activity_id => comment.id, :type => "reply"} %> - + <% if type == 'HomeworkCommon' %> + <%= link_to( l(:button_reply), - {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => type, :user_activity_id => user_activity_id, :activity_id => activity_id}, + {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => 'HomeworkCommon', :is_in_course => is_in_course, :user_activity_id => user_activity_id, :course_activity => course_activity}, :remote => true, :method => 'get', :title => l(:button_reply)) %> - - - <% if comment.creator_user == User.current || User.current.admin? %> - <%= link_to('删除', {:controller => 'words', :action => 'destroy', :object_id => comment, :user_id => comment.user, :user_activity_id => user_activity_id, :activity_id => activity_id}, + + + <% if User.current.admin? ||is_teacher || comment.user == User.current%> + <%= link_to('删除', {:controller => 'words', :action => 'destroy', :object_id => comment, :user_id => comment.user,:is_in_course => is_in_course, :user_activity_id => user_activity_id, :course_activity => course_activity}, :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "fr mr20", :title => l(:button_delete)) %> - <% end %> + <% end %> + <% elsif type == 'News' %> + + <%= link_to( + l(:button_reply), + {:controller => 'users', :action => 'reply_to', :reply_id => comment.id, :type => type, :user_activity_id => user_activity_id, :activity_id => activity_id}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) %> + + + <%= link_to('删除', {:controller => 'comments', :action => 'destroy', :id => activity_id, :comment_id => comment, :user_activity_id => user_activity_id}, + :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "fr mr20", :title => l(:button_delete)) if News.find(activity_id).author == User.current %> + <% end %>
    diff --git a/app/views/users/_org_document_replies.html.erb b/app/views/users/_org_document_replies.html.erb deleted file mode 100644 index ce26cf70c..000000000 --- a/app/views/users/_org_document_replies.html.erb +++ /dev/null @@ -1,60 +0,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) %> -
      -
      -
      - <%= link_to comment.creator_user.show_name, user_url_in_org(comment.creator_user.id), :class => "newsBlue mr10 f14" %> - <%= time_from_now(comment.created_at) %> -
      - <% if !comment.parent.nil? && !comment.parent.parent.nil? %> - <%= render :partial => 'users/message_contents', :locals => {:comment => comment}%> - <% end %> - <% 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 => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => type, :user_activity_id => user_activity_id, :activity_id => activity_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 => 'destroy', :id => comment.id, :user_activity_id => user_activity_id}, - :method => :delete, - :remote => true, - :class => 'fr mr20', - :data => {:confirm => l(:text_are_you_sure)}, - :title => l(:button_delete)) %> - <% end %> - -
      -
      -
      -

      - <% end %> -
      -
      -
    • - <% end %> -
    \ No newline at end of file diff --git a/app/views/users/_project_message.html.erb b/app/views/users/_project_message.html.erb index d1bb99296..df75e8385 100644 --- a/app/views/users/_project_message.html.erb +++ b/app/views/users/_project_message.html.erb @@ -82,7 +82,7 @@ <%# allow_delete = (activity.user == User.current || User.current.admin? || User.current.allowed_to?(:as_teacher,activity.course)) %> <%# count = fetch_user_leaveWord_reply(activity).count %>
    - <%= render :partial => 'users/message_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id,:is_course => is_course,:is_board =>is_board} %> + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id,:is_course => is_course,:is_board =>is_board} %> <% all_comments = []%> <% comments = get_all_children(all_comments, activity)[0..2] %> diff --git a/app/views/users/_project_news.html.erb b/app/views/users/_project_news.html.erb index cdceb490d..4c7ec2b04 100644 --- a/app/views/users/_project_news.html.erb +++ b/app/views/users/_project_news.html.erb @@ -62,11 +62,11 @@ <% count=activity.comments.count %>
    <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> - + <% comments = activity.comments.reorder("created_on desc").limit(3) %> <% if count > 0 %>
    - <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%> + <%= render :partial => 'users/news_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'News', :activity_id => activity.id} %>
    <% end %> diff --git a/app/views/users/_reply_banner.html.erb b/app/views/users/_reply_banner.html.erb index 25175542f..43aebb89c 100644 --- a/app/views/users/_reply_banner.html.erb +++ b/app/views/users/_reply_banner.html.erb @@ -10,9 +10,27 @@
    <%#= format_date(activity.updated_on) %>
    <%if count>3 %> + <% if activity.class.to_s == 'HomeworkCommon' && is_in_course == -1 %> + + 展开更多 + + <% elsif activity.class.to_s == 'HomeworkCommon' %> + + 展开更多 + + <% elsif activity.class.to_s == 'Message' %> + + 展开更多 + + <% elsif activity.class.to_s == 'BlogComment' %> + + 展开更多 + + <% else %> + + 展开更多 + + <% end %> +
    <% end %>
    \ No newline at end of file diff --git a/app/views/users/_reply_to.html.erb b/app/views/users/_reply_to.html.erb index cb8b2e0ff..d1aad2d48 100644 --- a/app/views/users/_reply_to.html.erb +++ b/app/views/users/_reply_to.html.erb @@ -33,7 +33,6 @@ <%= hidden_field_tag 'is_course', params[:is_course], :value => @is_course %> <%= hidden_field_tag 'is_board', params[:is_board], :value => @is_board %> <%= hidden_field_tag 'parent_id', params[:parent_id], :value => reply.id %> - <%= hidden_field_tag 'reply_id', params[:reply_id], :value => reply.author.id %> <%= hidden_field_tag 'activity_id',params[:activity_id],:value =>@activity_id %> <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>@user_activity_id %>
    @@ -47,7 +46,6 @@ <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>@user_activity_id %> <%= hidden_field_tag 'parent_id', params[:parent_id], :value => reply.id %> - <%= hidden_field_tag 'reply_id', params[:reply_id], :value => reply.author_id %> <%= hidden_field_tag 'homepage', params[:homepage], :value => @homepage %>
    @@ -65,7 +63,16 @@

    <% end%> - <% end %> + <% elsif @type == 'News' %> + <%= form_for('new_form', :url => {:controller => 'comments',:action => 'reply', :id => reply.id}, :method => "post", :remote => true) do |f| %> + <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>@user_activity_id %> +
    + + +
    +

    + <% end%> + <% end %>
    diff --git a/app/views/users/_user_blog.html.erb b/app/views/users/_user_blog.html.erb index a19bfc016..b6cd9ebc3 100644 --- a/app/views/users/_user_blog.html.erb +++ b/app/views/users/_user_blog.html.erb @@ -44,13 +44,13 @@ <% all_comments = []%> <% count=get_all_children(all_comments, activity).count %>
    - <%= render :partial => 'users/blog_comment_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :homepage => 0} %> + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :homepage => 0} %> <% all_comments = []%> <% comments = get_all_children(all_comments, activity)[0..2] %> <% if count > 0 %>
    - <%= render :partial => 'users/blog_comments_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'BlogComment', :activity_id =>activity.id, :homepage => 0}%> + <%= render :partial => 'users/message_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'BlogComment', :activity_id =>activity.id, :homepage => 0}%>
    <% end %> diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index 4c8e17d5d..87277c80f 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -306,28 +306,12 @@ <% count=homework_common.journals_for_messages.count %>
    -
    -
    回复 - ︿ - <%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>homework_common, :user_activity_id=>homework_common.id,:type=>"activity"}%> - -
    -
    - <%if count>3 %> - - <% end %> -
    + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => homework_common, :user_activity_id => -1, :is_in_course => is_in_course,:course_activity=>-1} %> <% comments = homework_common.journals_for_messages.reorder("created_on desc").limit(3) %> <% if count > 0 %>
    - <%=render :partial => 'users/homework_replies', :locals => {:comments => comments, :is_in_course => is_in_course, :course_activity=> -1, :is_teacher => is_teacher, :user_activity_id => -1} %> + <%=render :partial => 'users/news_replies', :locals => {:comments => comments, :type => 'HomeworkCommon', :is_in_course => is_in_course,:course_activity=>-1, :is_teacher => is_teacher, :user_activity_id => -1} %>
    <% end %> diff --git a/app/views/users/_user_journalsformessage.html.erb b/app/views/users/_user_journalsformessage.html.erb index dfbe751ef..7880cde99 100644 --- a/app/views/users/_user_journalsformessage.html.erb +++ b/app/views/users/_user_journalsformessage.html.erb @@ -64,15 +64,14 @@
    <% all_comments = []%> <% count=get_all_children(all_comments, activity).count %> - <%# allow_delete = (activity.user == User.current || User.current.admin?) %>
    - <%= render :partial => 'users/journal_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> <% all_comments = []%> <% comments = get_all_children(all_comments, activity)[0..2] %> <% if count > 0 %>
    - <%= render :partial => 'users/journal_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'JournalsForMessage', :activity_id =>activity.id}%> + <%= render :partial => 'users/message_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'JournalsForMessage', :activity_id =>activity.id}%>
    <% end %> diff --git a/app/views/users/_user_syllabus_list.html.erb b/app/views/users/_user_syllabus_list.html.erb index 8e33696d6..b8bc55d47 100644 --- a/app/views/users/_user_syllabus_list.html.erb +++ b/app/views/users/_user_syllabus_list.html.erb @@ -59,7 +59,7 @@ <% end %> <% if courses.count > 3 %>
  • - 共<%=courses.count %>个课程,点击全部展开 + 共<%=courses.count %>个班级,点击全部展开
  • <% end %> <% end %> diff --git a/app/views/users/all_journals.js.erb b/app/views/users/all_journals.js.erb index b5ccdad9e..78640033a 100644 --- a/app/views/users/all_journals.js.erb +++ b/app/views/users/all_journals.js.erb @@ -1,13 +1,15 @@ <% if params[:type] == 'HomeworkCommon' %> -$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/homework_replies', :locals => {:comments => @journals, :is_in_course =>@is_in_course,:course_activity=>@course_activity, :is_teacher => @is_teacher, :user_activity_id => @user_activity_id}) %>'); +$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/news_replies', :locals => {:comments => @journals, :type => @type, :is_in_course =>@is_in_course,:course_activity=>@course_activity, :is_teacher => @is_teacher, :user_activity_id => @user_activity_id}) %>'); <% elsif params[:type] == 'JournalsForMessage' %> -$('#reply_div_<%= @user_activity_id %>').html('<%=escape_javascript(render :partial => 'users/journal_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :activity_id =>params[:id].to_i}) %>'); +$('#reply_div_<%= @user_activity_id %>').html('<%=escape_javascript(render :partial => 'users/message_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :activity_id =>params[:id].to_i}) %>'); <% elsif params[:type] == 'Message' %> $('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/message_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :activity_id => params[:id].to_i,:is_course => @is_course, :is_board => @is_board}) %>'); <% elsif params[:type] == 'BlogComment' %> -$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/blog_comments_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :activity_id => params[:id].to_i, :homepage => @homepage}) %>'); +$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/message_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :activity_id => params[:id].to_i, :homepage => @homepage}) %>'); <% elsif params[:type] == 'OrgDocumentComment' %> -$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/org_document_replies', :locals => {:comments => @journals, :user_activity_id => @user_activity_id, :type => @type, :activity_id => params[:id].to_i}) %>'); +$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/message_replies', :locals => {:comments => @journals, :user_activity_id => @user_activity_id, :type => @type, :activity_id => params[:id].to_i}) %>'); +<% elsif params[:type] == 'News' %> +$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/news_replies', :locals => {:comments => @journals, :user_activity_id => @user_activity_id, :type => @type, :activity_id => params[:id].to_i}) %>'); <% else %> $('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/all_replies', :locals => {:comments => @journals}) %>'); <% end %> diff --git a/app/views/users/show_all_replies.js.erb b/app/views/users/show_all_replies.js.erb index 2d4321bce..7b47b29d8 100644 --- a/app/views/users/show_all_replies.js.erb +++ b/app/views/users/show_all_replies.js.erb @@ -1,7 +1,7 @@ <% unless @comment.parent.nil? %> <% if params[:type] == 'JournalsForMessage' && (@comment.jour_type == 'Principal' || @comment.jour_type == 'Course') %> $('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/journal_comment_reply', :locals => {:comment => @comment.parent})%>"); - <% elsif (@comment.class.to_s == 'Message' || @comment.class.to_s == 'BlogComment' ) %> + <% elsif (@comment.class.to_s == 'Message' || @comment.class.to_s == 'BlogComment' || @comment.class.to_s == 'OrgDocumentComment') %> $('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/journal_comment_reply', :locals => {:comment => @comment.parent})%>"); <% else %> $('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/comment_reply', :locals => {:comment => @comment.parent})%>"); diff --git a/config/routes.rb b/config/routes.rb index 539d78df3..83d3bc68c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -207,6 +207,12 @@ RedmineApp::Application.routes.draw do resources :apply_project_masters delete 'apply_project_masters', :to => 'apply_project_masters#delete' + resources :comments do + member do + post 'reply' + get 'quote' + end + end # resources :organization, :except => [:show] do # # end diff --git a/db/migrate/20160719013955_add_column_to_comments.rb b/db/migrate/20160719013955_add_column_to_comments.rb new file mode 100644 index 000000000..6d0201c49 --- /dev/null +++ b/db/migrate/20160719013955_add_column_to_comments.rb @@ -0,0 +1,7 @@ +class AddColumnToComments < ActiveRecord::Migration + def change + add_column :comments, :parent_id, :integer + add_column :comments, :comments_count, :integer, :default => 0 + add_column :comments, :reply_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 32d29d31a..928adfe9b 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 => 20160709015740) do +ActiveRecord::Schema.define(:version => 20160719013955) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -387,6 +387,9 @@ ActiveRecord::Schema.define(:version => 20160709015740) do t.text "comments" t.datetime "created_on", :null => false t.datetime "updated_on", :null => false + t.integer "parent_id" + t.integer "comments_count", :default => 0 + t.integer "reply_id" end add_index "comments", ["author_id"], :name => "index_comments_on_author_id" @@ -562,9 +565,9 @@ ActiveRecord::Schema.define(:version => 20160709015740) do t.integer "excellent_option", :default => 0 t.integer "is_copy", :default => 0 t.integer "visits", :default => 0 + t.integer "syllabus_id" t.string "invite_code" t.string "qrcode" - t.integer "syllabus_id" end add_index "courses", ["invite_code"], :name => "index_courses_on_invite_code", :unique => true diff --git a/lib/redmine.rb b/lib/redmine.rb index cfd8b6824..ed40b4c04 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -198,7 +198,7 @@ Redmine::AccessControl.map do |map| map.project_module :news do |map| map.permission :manage_news, {:news => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member map.permission :view_news, {:news => [:index, :show]}, :public => true, :read => true - map.permission :comment_news, {:comments => :create} + map.permission :comment_news, {:comments => [:create, :reply]} end map.contest_module :contestnotifications do |map| From f979e80f24a73c3850e1db2b8c2518c83ae12c93 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 20 Jul 2016 17:05:55 +0800 Subject: [PATCH 38/99] =?UTF-8?q?Gitlab=E6=95=B0=E6=8D=AE=E6=B8=85?= =?UTF-8?q?=E7=90=86=E5=8F=8A=E8=BF=81=E7=A7=BB=EF=BC=8C=E4=B8=BB=E8=A6=81?= =?UTF-8?q?=E6=98=AF=E5=8E=86=E5=8F=B2=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/changeset.rb | 4 +--- lib/tasks/gitlab_act_project.rake | 15 ++++++++------- lib/tasks/gitlab_unused.rake | 11 +++++++++++ 3 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 lib/tasks/gitlab_unused.rake diff --git a/app/models/changeset.rb b/app/models/changeset.rb index 3a772eb6b..a9c3687a1 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -57,9 +57,7 @@ class Changeset < ActiveRecord::Base validates :committed_on, presence: true validates :commit_date, presence: true validates :scmid, uniqueness: {scope: :repository_id, allow_nil: true} - attr_accessible :product, :project_id, :repository_id, :revision, :committer, :comments, :committed_on - attr_accessible :type - + attr_accessible :type, :project_id, :repository_id, :revision, :committer, :comments, :committed_on scope :visible, lambda {|*args| includes(:repository => :project).where(Project.allowed_to_condition(args.shift || User.current, :view_changesets, *args)) } diff --git a/lib/tasks/gitlab_act_project.rake b/lib/tasks/gitlab_act_project.rake index 962dac221..142d5bf89 100644 --- a/lib/tasks/gitlab_act_project.rake +++ b/lib/tasks/gitlab_act_project.rake @@ -1,11 +1,11 @@ namespace :gitlab do desc "sync gitlab's commit acts to trustie" task :forge_acts => :environment do - begin - g = Gitlab.client - # projects = Project.find_by_sql("select * from projects where gpid is not null") - projects = Project.find_by_sql("select * from projects where gpid is not null and id != 2") - projects.each do |project| + g = Gitlab.client + # projects = Project.find_by_sql("select * from projects where gpid is not null") + projects = Project.find_by_sql("select * from projects where gpid is not null and id > 265") + projects.each do |project| + begin g_project = g.project(project.gpid) # 获取默认分支 g_default_branch = g_project.default_branch.nil? ? "master" : g_project.default_branch @@ -13,15 +13,16 @@ namespace :gitlab do commit_count = g.user_static(project.gpid, :rev => g_default_branch).count pages = commit_count / 20 + 1 puts "#{pages}" + puts "project id is #{project.id}" (0..pages).each do |page| commits = g.commits(project.gpid, :ref_name => g_default_branch, :page => page) commits.each do |commit| Changeset.create(:project_id => project.id, :repository_id => project.gpid, :revision => commit.id, :committer => commit.author_email, :comments => Redmine::CodesetUtil.to_utf8(commit.title, 'UTF-8'), :committed_on => commit.created_at, :type => true) end end + rescue Exception => e + puts e end - rescue Exception => e - puts e end end end diff --git a/lib/tasks/gitlab_unused.rake b/lib/tasks/gitlab_unused.rake new file mode 100644 index 000000000..0b90d9352 --- /dev/null +++ b/lib/tasks/gitlab_unused.rake @@ -0,0 +1,11 @@ +namespace :gitlab do + desc "sync gitlab's commit acts to trustie" + task :unused => :environment do + begin + Project.where("id in (161,236,266)").update_all(:gpid => nil) + Repository.where("project_id in (161,236,266)").destroy_all + rescue Exception => e + puts e + end + end +end From 6357f5be2a2dc6a2c442b04e22f20fd2c11668e0 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 21 Jul 2016 09:27:14 +0800 Subject: [PATCH 39/99] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=88=90=E5=91=98?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E8=8E=B7=E5=8F=96=E5=8D=95=E4=BD=8D=E4=B8=8D?= =?UTF-8?q?=E5=87=86=E7=A1=AE=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/helpers/application_helper.rb | 5 +++++ app/views/admin/users.html.erb | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 603084cd1..42a3491fb 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -38,6 +38,11 @@ module ApplicationHelper # super # end + # 获取用户单位 + # 优先获取高校信息,如果改信息不存在则获取occupation + def get_occupation_from_user user + School.where("id=?",user.user_extensions.school_id).first.try(:name).nil? ? user.user_extensions.occupation : School.where("id=?",user.user_extensions.school_id).first.try(:name) + end def update_visiti_count container container.update_column(:visits, container.visits + 1) diff --git a/app/views/admin/users.html.erb b/app/views/admin/users.html.erb index 2a757fdee..9215782bb 100644 --- a/app/views/admin/users.html.erb +++ b/app/views/admin/users.html.erb @@ -56,8 +56,7 @@ <%= checked_image user.admin? %> <%= format_time(user.created_on) %> <%= format_time(user.last_login_on) unless user.last_login_on.nil? %> - <% occupation = user.user_extensions.identity == 0 ? School.where("id=?",user.user_extensions.school_id).first.try(:name) : user.user_extensions.occupation %> - <%= truncate( occupation, :length => 12 ) %> + <%= truncate(get_occupation_from_user(user), :length => 12 ) %> <%= change_status_link(user) %> <%= delete_link user_path(user, :back_url => admin_users_path(params)) unless User.current == user %> From 7c2495c8a19393593b8dde3ebce8db2599249f51 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 21 Jul 2016 10:20:45 +0800 Subject: [PATCH 40/99] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E5=9C=A8=E7=BA=BF?= =?UTF-8?q?=E6=B5=8B=E9=AA=8C=E6=96=B0=E5=BB=BA=E5=8D=95=E9=80=89=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E6=97=B6=EF=BC=8C=E6=A0=B7=E5=BC=8F=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_edit_MC.html.erb | 2 +- app/views/exercise/_edit_MCQ.html.erb | 4 ++-- app/views/exercise/_exercise_form.html.erb | 2 +- app/views/exercise/_new_MCQ.html.erb | 8 ++++---- app/views/exercise/_show_MCQ.html.erb | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/views/exercise/_edit_MC.html.erb b/app/views/exercise/_edit_MC.html.erb index 06d3e00da..9dfa2c48f 100644 --- a/app/views/exercise/_edit_MC.html.erb +++ b/app/views/exercise/_edit_MC.html.erb @@ -8,7 +8,7 @@ $("#poll_question_standard_answer_<%=exercise_question.id %>").val("<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s)%>") $("#poll_answers_<%=exercise_question.id%>").html("<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>" + "
  • " + - "" + + "" + "" + "" + "" + diff --git a/app/views/exercise/_edit_MCQ.html.erb b/app/views/exercise/_edit_MCQ.html.erb index 48422be1c..186cebd18 100644 --- a/app/views/exercise/_edit_MCQ.html.erb +++ b/app/views/exercise/_edit_MCQ.html.erb @@ -8,7 +8,7 @@ $("#poll_question_standard_answer_<%=exercise_question.id %>").val("<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s)%>") $("#poll_answers_<%=exercise_question.id%>").html("<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>" + "
  • " + - "" + + "" + "" + "" + "" + @@ -34,7 +34,7 @@
    <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
  • - + diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index 9d70511e8..71389b313 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -171,7 +171,7 @@ //单选题 function add_single_answer(doc) { - var li = doc.parent().after("
  • " + + var li = doc.parent().after("
  • " + ""+ "
  • "); var select_items =$("label[name='select_items']",li.parent()); diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb index 875b9ec4c..11ec08d05 100644 --- a/app/views/exercise/_new_MCQ.html.erb +++ b/app/views/exercise/_new_MCQ.html.erb @@ -18,28 +18,28 @@
  • - +
  • - +
  • - +
  • - + diff --git a/app/views/exercise/_show_MCQ.html.erb b/app/views/exercise/_show_MCQ.html.erb index a7ee60aa3..f122e1256 100644 --- a/app/views/exercise/_show_MCQ.html.erb +++ b/app/views/exercise/_show_MCQ.html.erb @@ -54,28 +54,28 @@ '分'+ '
  • '+ '
  • '+ - ''+ + ''+ ''+ ''+ ''+ '
  • '+ '
    '+ '
  • '+ - ''+ + ''+ ''+ ''+ ''+ '
  • '+ '
    '+ '
  • '+ - ''+ + ''+ ''+ ''+ ''+ '
  • '+ '
    '+ '
  • '+ - ''+ + ''+ ''+ ''+ ''+ From f3c95906d8df80d977b274fa0675746bf6e858df Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 21 Jul 2016 10:30:48 +0800 Subject: [PATCH 41/99] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=BC=BA=E9=99=B7?= =?UTF-8?q?=E7=9A=84=E4=BA=8C=E7=BA=A7=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 22 +++--- app/controllers/users_controller.rb | 9 +++ app/models/journal.rb | 1 + app/views/blog_comments/show.html.erb | 9 +-- app/views/issues/_issue_replies.html.erb | 79 +++++++++---------- .../issues/_issue_reply_ke_form.html.erb | 20 ++--- app/views/issues/add_reply.js.erb | 11 ++- app/views/issues/delete_journal.js.erb | 7 +- app/views/issues/reply.js.erb | 7 +- app/views/messages/_course_show.html.erb | 9 +-- .../messages/_org_subfield_show.html.erb | 9 +-- app/views/messages/_project_show.html.erb | 9 +-- app/views/news/_news_all_replies.html.erb | 31 +------- app/views/org_document_comments/show.html.erb | 9 +-- .../_org_subfield_message.html.erb | 2 +- .../users/_comment_reply_detail.html.erb | 13 ++- app/views/users/_course_message.html.erb | 2 +- app/views/users/_message_contents.html.erb | 50 ++++++------ app/views/users/_message_replies.html.erb | 9 +-- app/views/users/_news_contents.html.erb | 29 +++++++ app/views/users/_news_replies.html.erb | 51 +++++------- app/views/users/_project_issue_reply.html.erb | 2 +- app/views/users/_project_message.html.erb | 2 +- app/views/users/_reply_to.html.erb | 10 +++ app/views/users/all_journals.js.erb | 2 +- .../20160720094503_add_column_to_journal.rb | 7 ++ db/schema.rb | 5 +- 27 files changed, 214 insertions(+), 202 deletions(-) create mode 100644 app/views/users/_news_contents.html.erb create mode 100644 db/migrate/20160720094503_add_column_to_journal.rb diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 44f0d15f4..921d7d12b 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -473,7 +473,6 @@ class IssuesController < ApplicationController def reply @issue = Issue.find(params[:id]) @jour = Journal.find(params[:journal_id]) - @tempContent = "
    #{ll(Setting.default_language, :text_user_wrote, @jour.user.realname.blank? ? @jour.user.login: @jour.user.realname)}
    #{@jour.notes.html_safe}
    ".html_safe respond_to do |format| format.js end @@ -482,17 +481,17 @@ class IssuesController < ApplicationController #给issue添加journ。回复内容包含 对某个被回复的journ的内容 def add_reply if User.current.logged? - jour = Journal.new - jour.user_id = User.current.id - jour.notes = params[:quote]+params[:notes] + jour = Journal.find(params[:journal_id]) @issue = Issue.find params[:id] - jour.journalized = @issue - jour.save - update_user_activity(@issue.class,@issue.id) - update_forge_activity(@issue.class,@issue.id) + new_jour = @issue.journals.build(:user_id => User.current.id, :reply_id => params[:journal_id], :notes => params[:content], :parent_id => jour.id) + @user_activity_id = params[:user_activity_id] + if new_jour.save + update_user_activity(@issue.class,@issue.id) + update_forge_activity(@issue.class,@issue.id) - respond_to do |format| - format.js + respond_to do |format| + format.js + end end end end @@ -501,7 +500,8 @@ class IssuesController < ApplicationController def delete_journal @issue = Issue.find(params[:id]) Journal.destroy(params[:journal_id]) - respond_to do |format| + @user_activity_id = params[:user_activity_id] + respond_to do |format| format.js end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6b9e8f4c9..2d16f1a2b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -98,6 +98,8 @@ class UsersController < ApplicationController @comment = OrgDocumentComment.find params[:comment].to_i when 'Comment' @comment = Comment.find params[:comment].to_i + when 'Journal' + @comment = Journal.find params[:comment].to_i end end @@ -142,6 +144,11 @@ class UsersController < ApplicationController @user_activity_id = params[:user_activity_id] @activity_id = params[:activity_id] @type = 'News' + when 'Issue' + @reply = Journal.find params[:reply_id] + @user_activity_id = params[:user_activity_id] + @activity_id = params[:activity_id] + @type = 'Issue' end respond_to do |format| format.js @@ -3329,6 +3336,8 @@ class UsersController < ApplicationController when 'Issue' obj = Issue.where('id = ?', params[:id].to_i).first @journals = obj.journals.reorder("created_on desc") + @type = 'Issue' + @user_activity_id = params[:div_id].to_i if params[:div_id] when 'BlogComment' obj = BlogComment.where('id = ?', params[:id].to_i).first @user_activity_id = params[:div_id].to_i if params[:div_id] diff --git a/app/models/journal.rb b/app/models/journal.rb index 0f88fcb7f..d2cc9e539 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -37,6 +37,7 @@ class Journal < ActiveRecord::Base has_many :at_messages, as: :at_message, dependent: :destroy acts_as_attachable attr_accessor :indice + acts_as_tree :counter_cache => :comments_count, :order => "#{Journal.table_name}.created_on ASC" acts_as_event :title =>Proc.new {|o| status = ((s = o.new_status) ? " (#{s})" : nil); "#{o.issue.tracker} ##{o.issue.project_index}#{status}: #{o.issue.subject}" }, :description =>:notes, diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb index bde98d456..f5c7c9094 100644 --- a/app/views/blog_comments/show.html.erb +++ b/app/views/blog_comments/show.html.erb @@ -135,13 +135,8 @@ <%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_user.id) %>
  • -
    - <%= link_to comment.creator_user.show_name, user_url_in_org(comment.creator_user.id), :class => "newsBlue mr10 f14" %> - <%= time_from_now(comment.created_on) %> -
    - <% if !comment.parent.nil? && !comment.parent.parent.nil? %> - <%= render :partial => 'users/message_contents', :locals => {:comment => comment}%> - <% end %> + <%= render :partial => 'users/message_contents', :locals => {:comment => comment}%> + <% if !comment.content_detail.blank? %>
    <%= comment.content_detail.html_safe %> diff --git a/app/views/issues/_issue_replies.html.erb b/app/views/issues/_issue_replies.html.erb index 7b5383c1e..344987913 100644 --- a/app/views/issues/_issue_replies.html.erb +++ b/app/views/issues/_issue_replies.html.erb @@ -1,55 +1,55 @@ +
    <% end %> \ No newline at end of file diff --git a/app/views/courses/_course_heroes.html.erb b/app/views/courses/_course_heroes.html.erb index ea05eea53..4699c12d2 100644 --- a/app/views/courses/_course_heroes.html.erb +++ b/app/views/courses/_course_heroes.html.erb @@ -1,9 +1,9 @@ <% hero_homework_scores = hero_homework_score(course, "desc") %> <% unless hero_homework_scores.map(&:score).detect{|s| s.to_i != 0}.nil? %>
      -

      +

      <% if (User.current.logged? && course.open_student == 1) || (User.current.member_of_course?(course)) || User.current.admin? %> - <%= link_to "班级英雄榜", course_member_path(course, :role => 2), :class => '' %> + <%= link_to "班级英雄榜", course_member_path(course, :role => 2), :class => 'sy_cblack' %> <% else %> 班级英雄榜 <% end %> diff --git a/app/views/courses/_recommendation.html.erb b/app/views/courses/_recommendation.html.erb index 1db2edf57..ea129577b 100644 --- a/app/views/courses/_recommendation.html.erb +++ b/app/views/courses/_recommendation.html.erb @@ -1,25 +1,15 @@ <% exc_course = excellent_course_recommend(course) %> <% unless exc_course.length == 0 %> -
        -

        <%= l(:label_homework_recommendation) %>:

        - <% exc_course.each do |e_course| %> -
      • <%= image_tag(url_to_avatar(e_course), :width => "40", :height => "40", :class => "fl mr10 rankPortrait", :alt => "logo") %> -
        -

        <%=link_to e_course.name, course_path(e_course.id), :class => "hidden fl w170" %>

        -

        - <% if visable_attachemnts_incourse(e_course).count > 0 %> - <%= l(:project_module_attachments) %>(<%= link_to visable_attachemnts_incourse(e_course).count, course_files_path(e_course), :class => "linkBlue2" %>) - <% end %> - <% if e_course.homework_commons.where("publish_time <= '#{Date.today}'").count > 0 %> - <%= l(:label_homework_commont) %>(<%= link_to e_course.homework_commons.where("publish_time <= '#{Date.today}'").count, homework_common_index_path(:course=>e_course.id), :class => "linkBlue2" %>) - <% end %> -

        -

        -
        -
        +
          + <% exc_course.each_with_index do |e_course, i| %> +
        • + <%= i+1 %> + <%=link_to e_course.name, course_path(e_course.id), :class => "sy_class_ltitle fl mb10" %> +

          作业<%=e_course.homework_commons.where("publish_time <= '#{Date.today}'").count %> + 资源<%=visable_attachemnts_incourse(e_course).count %> +

        • <% end %> -
        <% end %> diff --git a/app/views/courses/_tool_expand.html.erb b/app/views/courses/_tool_expand.html.erb index 52a971826..c41edf680 100644 --- a/app/views/courses/_tool_expand.html.erb +++ b/app/views/courses/_tool_expand.html.erb @@ -1,47 +1,53 @@ <% course_file_num = visable_attachemnts_incourse(@course).count%> <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %> +<% if show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %> +
      • + 问答区 + <%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'sy_class_add', :title =>"#{l(:label_message_new)}") %> +
      • +<% end %> <% if show_nav?(@course.homework_commons.count) %> - +
      • + 作业 + <%= link_to( "",homework_common_index_path(:course => @course.id,:is_new => 1), :class => 'sy_class_add', :title =>"#{l(:label_course_homework_new)}") if is_teacher %> +
      • <% end %> <% if show_nav?(@course.news.count) %> - +
      • + 通知 + <%= link_to( "",new_course_news_path(@course,:is_new=>1), :class => 'sy_class_add', :title =>"#{l(:label_course_news_new)}") if is_teacher %> +
      • <% end %> <% if show_nav?(course_file_num) %> - -<% end %> -<% if show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %> - + <% end %> <% if show_nav?(course_feedback_count) %> - +
      • + 留言 + <%= link_to "", course_feedback_path(@course), :class => 'sy_class_add', :title =>"#{l(:label_course_feedback)}", :id => "course_jour_count"%> +
      • <% end %> <% if show_nav?(course_poll_count) %> - +
      • + @course.id) %>">问卷调查 + <%= link_to( "", new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => 'sy_class_add', :title =>"#{l(:label_new_poll)}") if is_teacher %> +
      • <% end %> -<% if show_nav?(User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status=2").count) %> - +<% count = User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status <> 1").count %> +<% if show_nav?(count) %> +
      • + 在线测验 + <%= link_to( "", new_exercise_path(:course_id => @course.id), :class => 'sy_class_add', :title =>"新建试卷") if is_teacher %> +
      • +<% end %> +<% if show_nav?(0) %> +
      • + 统计 + +
      • <% end %> \ No newline at end of file diff --git a/app/views/courses/feedback.html.erb b/app/views/courses/feedback.html.erb index c45259efd..5eae03656 100644 --- a/app/views/courses/feedback.html.erb +++ b/app/views/courses/feedback.html.erb @@ -1,5 +1,7 @@ <% reply_allow = JournalsForMessage.create_by_user? User.current %> +
        +

        <%= l(:label_contest_userresponse) %>

        @@ -9,4 +11,5 @@ :locals => { :contest => @contest, :journals => @jour, :state => false} %> -<% html_title(l(:label_course_feedback)) -%> \ No newline at end of file +<% html_title(l(:label_course_feedback)) -%> +
        \ No newline at end of file diff --git a/app/views/courses/statistics_course.html.erb b/app/views/courses/statistics_course.html.erb new file mode 100644 index 000000000..ce3d65743 --- /dev/null +++ b/app/views/courses/statistics_course.html.erb @@ -0,0 +1,5 @@ +
        +
        +

        统计功能即将上线,届时我们一起享受教育大数据的红利吧!

        +
        +
        \ No newline at end of file diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index 9d70511e8..50df61cc9 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -2,7 +2,7 @@ diff --git a/app/views/exercise/_exercise_teacher.html.erb b/app/views/exercise/_exercise_teacher.html.erb index ce3928817..78bf2b7be 100644 --- a/app/views/exercise/_exercise_teacher.html.erb +++ b/app/views/exercise/_exercise_teacher.html.erb @@ -1,7 +1,7 @@ diff --git a/app/views/exercise/index.html.erb b/app/views/exercise/index.html.erb index 8637273f1..68adfb4d4 100644 --- a/app/views/exercise/index.html.erb +++ b/app/views/exercise/index.html.erb @@ -1,9 +1,7 @@ <%= stylesheet_link_tag 'polls', :media => 'all' %> +
        <%= render :partial => 'exercises_list'%> -
        \ No newline at end of file +
        +

    \ No newline at end of file diff --git a/app/views/exercise/student_exercise_list.html.erb b/app/views/exercise/student_exercise_list.html.erb index 02f161589..1cbe058a1 100644 --- a/app/views/exercise/student_exercise_list.html.erb +++ b/app/views/exercise/student_exercise_list.html.erb @@ -1,7 +1,7 @@ + + + + + + + + + +
    +
    +
    +
    +
    + <%=render :partial=>'layouts/project_info' %> +
    + +
    +
      +
    • <%= l(:label_main_teacher)%> :  <%= link_to(@course.teacher.lastname+@course.teacher.firstname, user_path(@course.teacher), :class => 'c_dblue') %>
    • +
    • <%= l(:label_class_period)%> :  <%= @course.class_period %> <%= l(:label_class_hour) %>
    • +
    • <%= l(:label_main_term)%> :  <%= current_time_and_term @course %>
    • + <% if @course.school%> +
    • <%= l(:label_course_organizers)%> :  <%= @course.school%>
    • + <% end%> +
    +
    + + <%# 更新访问数,刷新的时候更新访问次数 %> + <% update_visiti_count @course %> + <%# over %> + + + <%# 课程活跃度 %> +
    + <%= render :partial => 'courses/course_activity_users', :locals => {:course => @course} %> + <%# 课程英雄榜 %> + <%= render :partial => 'courses/course_heroes', :locals => {:course => @course} %> + + <% if @course.description && !@course.description.blank? %> +
    +
    +

    <%= l(:label_course_brief_introduction)%>:

    +
    + <%= textilizable(@course.description) if @course.description && !@course.description.blank? %> +
    +
    +
    + + + + +
    +
    + <% end %> +
    +

    <%= l(:label_tag)%>:

    +
    + <%= render :partial => 'tags/new_tag', :locals => {:obj => @course, :object_flag => "9"} %> +
    +
    +
    + + <%= render :partial => 'courses/recommendation', :locals => {:course => @course} %> +
    访问计数 <%= @course.visits.to_i %> (自2016年5月)
    +
    + +
    + <%= yield %> + <%#= render_flash_messages %> + <%#= call_hook :view_layouts_base_content %> +
    + +
    + +
    +
    + +
    +<%= render :partial => 'layouts/footer' %> +
    + +<%= render :partial => 'layouts/new_feedback' %> + + +<%= call_hook :view_layouts_base_body_bottom %> + + + + \ No newline at end of file diff --git a/app/views/layouts/_course_base_info.html.erb b/app/views/layouts/_course_base_info.html.erb new file mode 100644 index 000000000..bd152ac6e --- /dev/null +++ b/app/views/layouts/_course_base_info.html.erb @@ -0,0 +1,55 @@ +<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %> +<% teacher_num = TeacherAndAssistantCount(@course) %> +<% student_num = studentCount(@course) %> +<% course_file_num = visable_attachemnts_incourse(@course).count %> +

    + <%=link_to @course.syllabus.title, syllabus_path(@course.syllabus_id), :class => 'sy_cgrey' %> +  >  + <%=link_to @course.name, course_path(@course), :class => 'sy_cgrey' %> +

    + +<% if is_teacher %> +
    +
      +
    • +
        +
      • <%= link_to "班级配置", {:controller => 'courses', :action => 'settings', :id => @course}, :class => "postOptionLink" %>
      • +
      • <%= link_to @course.is_public == 0 ? "设为公开" : "设为私有", {:controller => 'courses', :action => 'private_or_public', :id => @course},:remote=>true,:confirm=>"您确定要设置为"+(@course.is_public == 0 ? "公开" : "私有")+"吗", :class => "postOptionLink" %>
      • +
      • <%= link_to "复制学期", copy_course_course_path(@course.id),:remote=>true, :class => "postOptionLink" %>
      • +
      • <%= link_to "进入课程", syllabus_path(@course.syllabus), :class => "postOptionLink", :target => "_blank" %>
      • +
      +
    • +
    +
    +<% end %> + +
    + +
    +

    邀请码
    <%=@course.generate_invite_code %>

    +
    +
    +
    +

    <%=@course.name %>

    + <%=@course.is_public == 0 ? '私有' : '公开' %> +

    + 教师:<%= course_teacher_link teacher_num %> + 学生:<%= course_student_link student_num %> + 资源:<%= link_to course_file_num, course_files_path(@course), :class => 'sy_cblue',:id=>'courses_files_count_info' %> +

    +
    +
    +

    + 主讲老师:<%= link_to(@course.teacher.show_name, user_path(@course.teacher), :class => 'sy_cblue') %> + 学时:<%= @course.class_period %>学时 + 学期:<%= current_time_and_term @course %> + 单位:<%= @course.school ? @course.school : '无' %> +

    + + <% unless is_teacher %> +
    <%= join_in_course_header(@course, User.current) %>
    + <% end %> +
    +
    \ No newline at end of file diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 1d749c5e8..9332ade4f 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -17,8 +17,8 @@ <%= javascript_heads %> <%= heads_for_theme %> <%= call_hook :view_layouts_base_html_head %> - <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public', 'css/structure','prettify', 'css/courses','css/popup'%> - <%= javascript_include_tag "course","sy_public", "syllabus","header","attachments",'prettify' %> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public', 'css/structure','prettify', 'css/courses','css/popup','sy_public','syllabus'%> + <%= javascript_include_tag "course","header","attachments",'prettify' %> <%= yield :header_tags -%> @@ -40,7 +40,7 @@ - \ No newline at end of file diff --git a/app/views/poll/show.html.erb b/app/views/poll/show.html.erb index 57969faa5..cd85b8067 100644 --- a/app/views/poll/show.html.erb +++ b/app/views/poll/show.html.erb @@ -1,4 +1,5 @@ <%= stylesheet_link_tag 'polls', :media => 'all' %> +

    @@ -221,3 +222,4 @@

    +
    \ No newline at end of file diff --git a/app/views/poll/statistics_result.html.erb b/app/views/poll/statistics_result.html.erb index da89bf26e..fb9e9d26b 100644 --- a/app/views/poll/statistics_result.html.erb +++ b/app/views/poll/statistics_result.html.erb @@ -1,4 +1,5 @@ <%= stylesheet_link_tag 'polls', :media => 'all' %> +

    @@ -32,4 +33,5 @@

    +
    \ No newline at end of file diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index 6bdc3753e..3ec6232db 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -7,7 +7,7 @@
    @@ -144,3 +146,4 @@ //$("#time").click(select); //$("#term").click(select); +
    \ No newline at end of file diff --git a/app/views/layouts/_syllabus_base_info.html.erb b/app/views/layouts/_syllabus_base_info.html.erb index 446473db5..335dc3335 100644 --- a/app/views/layouts/_syllabus_base_info.html.erb +++ b/app/views/layouts/_syllabus_base_info.html.erb @@ -52,9 +52,9 @@
    -<% if User.current.logged? && (User.current == syllabus.user || User.current.admin?)&&(syllabus.syllabus_type.nil? || syllabus.syllabus_type == 0 || syllabus.syllabus_type == ''||syllabus.credit.nil? || syllabus.credit == ''||syllabus.hours.nil? || syllabus.hours == ''||syllabus.theory_hours.nil? || syllabus.theory_hours == ''||syllabus.practice_hours.nil? || syllabus.practice_hours == ''||syllabus.applicable_major.nil? || syllabus.applicable_major == ''||syllabus.pre_course.nil? || syllabus.pre_course == '')%> - -<% end %> +<%# if User.current.logged? && (User.current == syllabus.user || User.current.admin?)&&(syllabus.syllabus_type.nil? || syllabus.syllabus_type == 0 || syllabus.syllabus_type == ''||syllabus.credit.nil? || syllabus.credit == ''||syllabus.hours.nil? || syllabus.hours == ''||syllabus.theory_hours.nil? || syllabus.theory_hours == ''||syllabus.practice_hours.nil? || syllabus.practice_hours == ''||syllabus.applicable_major.nil? || syllabus.applicable_major == ''||syllabus.pre_course.nil? || syllabus.pre_course == '')%> + +<%# end %>