From 65bd77f0ff25298ce5039a4b547c47346e47f099 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 18 Sep 2016 10:50:40 +0800 Subject: [PATCH 01/42] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E4=BA=8C=E7=BB=B4?= =?UTF-8?q?=E7=A0=81=E8=BF=87=E6=9C=9F=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 3 ++- app/models/project.rb | 3 ++- .../20160918024056_add_qrcode_expiretime_to_courses.rb | 5 +++++ .../20160918024214_add_qrcode_expiretime_to_projects.rb | 5 +++++ 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20160918024056_add_qrcode_expiretime_to_courses.rb create mode 100644 db/migrate/20160918024214_add_qrcode_expiretime_to_projects.rb diff --git a/app/models/course.rb b/app/models/course.rb index 659f9fcec..cc80a1b4b 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -495,10 +495,11 @@ class Course < ActiveRecord::Base def generate_qrcode ticket = self.qrcode - if !ticket || ticket.size < 10 + if !ticket || ticket.size < 10 || (Time.now.to_i > self.qrcode_expiretime) response = Wechat.api.qrcode_create_scene(invite_code, 2592000) logger.debug "response = #{response}" self.qrcode = response['ticket'] + self.qrcode_expiretime = Time.now.to_i+response['expire_seconds'] save! && reload ticket = qrcode end diff --git a/app/models/project.rb b/app/models/project.rb index 0d297bb3c..e80306036 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -930,10 +930,11 @@ class Project < ActiveRecord::Base def generate_qrcode ticket = self.qrcode - if !ticket || ticket.size < 10 + if !ticket || ticket.size < 10 || (Time.now.to_i > self.qrcode_expiretime) response = Wechat.api.qrcode_create_scene(invite_code, 2592000) logger.debug "response = #{response}" self.qrcode = response['ticket'] + self.qrcode_expiretime = Time.now.to_i+response['expire_seconds'] save! ticket = qrcode end diff --git a/db/migrate/20160918024056_add_qrcode_expiretime_to_courses.rb b/db/migrate/20160918024056_add_qrcode_expiretime_to_courses.rb new file mode 100644 index 000000000..17d8548cc --- /dev/null +++ b/db/migrate/20160918024056_add_qrcode_expiretime_to_courses.rb @@ -0,0 +1,5 @@ +class AddQrcodeExpiretimeToCourses < ActiveRecord::Migration + def change + add_column :courses, :qrcode_expiretime, :integer, :default => 0 + end +end diff --git a/db/migrate/20160918024214_add_qrcode_expiretime_to_projects.rb b/db/migrate/20160918024214_add_qrcode_expiretime_to_projects.rb new file mode 100644 index 000000000..870917443 --- /dev/null +++ b/db/migrate/20160918024214_add_qrcode_expiretime_to_projects.rb @@ -0,0 +1,5 @@ +class AddQrcodeExpiretimeToProjects < ActiveRecord::Migration + def change + add_column :projects, :qrcode_expiretime, :integer, :default => 0 + end +end From b783ec5b44823771de8f0d0cfe78ea554b764705 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 18 Sep 2016 13:19:37 +0800 Subject: [PATCH 02/42] . --- app/api/mobile/apis/courses.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index cbf8f4986..57feff084 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -123,6 +123,12 @@ module Mobile else cs = CoursesService.new status = cs.join_course_roles({role: roles_ids, openid: params[:openid], invite_code: params[:invite_code]}, current_user) + if params[:student_flag] && status[:state] == 0 + #查询分班信息 + + + end + { status: status[:state], message:CoursesService::JoinCourseError.message(status[:state]) From 04a2effceec5c8b07b230a51fd90cc5bb5bc2cc3 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 18 Sep 2016 16:12:38 +0800 Subject: [PATCH 03/42] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=88=86=E7=8F=AD=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/courses.rb | 30 ++++++++++---- app/services/courses_service.rb | 8 +++- public/assets/wechat/join_class.html | 2 + public/assets/wechat/join_classgroup.html | 32 +++++++++++++++ .../wechat/controllers/join_class.js | 8 +++- .../wechat/controllers/join_classgroup.js | 39 +++++++++++++++++++ public/javascripts/wechat/others/routes.js | 1 + 7 files changed, 111 insertions(+), 9 deletions(-) create mode 100644 public/assets/wechat/join_classgroup.html create mode 100644 public/javascripts/wechat/controllers/join_classgroup.js diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 57feff084..f0e4c867d 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -118,20 +118,18 @@ module Mobile roles_ids << "10" end + go_course_group = 0 + if roles_ids.length <= 0 {status:-1,message:"请至少选择一个角色"} else cs = CoursesService.new status = cs.join_course_roles({role: roles_ids, openid: params[:openid], invite_code: params[:invite_code]}, current_user) - if params[:student_flag] && status[:state] == 0 - #查询分班信息 - - - end - { status: status[:state], - message:CoursesService::JoinCourseError.message(status[:state]) + message:CoursesService::JoinCourseError.message(status[:state]), + go_coursegroup_flag:status[:go_coursegroup_flag], + course_id:status[:course_id] } end end @@ -756,6 +754,24 @@ module Mobile end out.merge(message: message) end + + desc '获取分班列表' + params do + requires :token, type:String + end + get ':course_id/course_groups' do + begin + authenticate! + course = Course.find(params[:course_id]) + groups = [] + groups = course.course_groups if course.course_groups + present :data,groups + present :status,0 + rescue + present :status,-1 + end + end + end end end diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 5add9979d..182d1150f 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -565,6 +565,8 @@ class CoursesService #多个角色加入课程 def join_course_roles params,current_user course = Course.find_by_invite_code(params[:invite_code]) if params[:invite_code] + go_coursegroup_flag = 0 + course_id = 0 @state = 10 if course @@ -621,6 +623,8 @@ class CoursesService course.members << members StudentsForCourse.create(:student_id => current_user.id, :course_id => course.id) @state = 0 + go_coursegroup_flag = 1 if course.course_groups + course_id = course.id send_wechat_join_class_notice current_user,course,10,0 else is_stu = false @@ -630,6 +634,8 @@ class CoursesService course.members << members StudentsForCourse.create(:student_id => current_user.id, :course_id =>course.id) is_stu = true + go_coursegroup_flag = 1 if course.course_groups + course_id = course.id send_wechat_join_class_notice current_user,course,10,0 end #如果已经发送过消息了,那么就要给个提示 @@ -674,7 +680,7 @@ class CoursesService else @state = 4 end - {:state => @state,:course => course} + {:state => @state,:course => course,:go_coursegroup_flag => go_coursegroup_flag,:course_id=>course_id} end diff --git a/public/assets/wechat/join_class.html b/public/assets/wechat/join_class.html index ad43db3a7..4c81ff2e4 100644 --- a/public/assets/wechat/join_class.html +++ b/public/assets/wechat/join_class.html @@ -25,5 +25,7 @@ +
{{tip_1}}
+ diff --git a/public/assets/wechat/join_classgroup.html b/public/assets/wechat/join_classgroup.html new file mode 100644 index 000000000..6da2f1503 --- /dev/null +++ b/public/assets/wechat/join_classgroup.html @@ -0,0 +1,32 @@ +
+
+
+
欢迎加入班级
+
{{current_course.name}}
+
选择分班
+ + +
+ 提示 +
    +
  • 该班级存在分班信息,请选择属于您的小班
  • +
  • 老师可以在班级的成员管理页,对所有成员进行修改
  • +
  • 学生可以在班级的我的同学页,对自己进行修改
  • +
+
+ +
+ 取消 + 确定 +
+
+ + +
\ No newline at end of file diff --git a/public/javascripts/wechat/controllers/join_class.js b/public/javascripts/wechat/controllers/join_class.js index 006fa0b59..8f7647b12 100644 --- a/public/javascripts/wechat/controllers/join_class.js +++ b/public/javascripts/wechat/controllers/join_class.js @@ -55,10 +55,16 @@ app.controller('JoinClassController', ['$scope', '$http', 'auth', 'config', 'ale assistant_flag:vm.assistant, student_flag:vm.student }).then(function(response){ + console.log(response); if(response.data.status == 0){ vm.alertService.showMessage('提示', response.data.message,function(){ rms.save('syllabuses',[]); - $location.path("/class_list"); + if(response.data.go_coursegroup_flag == 0){ + $location.path("/class_list"); + } + else{ + $location.path("/join_classgroup").search({id: response.data.course_id}); + } }); } else { vm.alertService.showMessage('提示', response.data.message); diff --git a/public/javascripts/wechat/controllers/join_classgroup.js b/public/javascripts/wechat/controllers/join_classgroup.js new file mode 100644 index 000000000..504643817 --- /dev/null +++ b/public/javascripts/wechat/controllers/join_classgroup.js @@ -0,0 +1,39 @@ + + +app.controller('JoinClassGroupController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms','wx','common', function($scope, $http, auth, config, alertService, $location,$routeParams, rms,wx,common){ + var vm = $scope; + + var course_id = $routeParams.id; + vm.alertService = alertService.create(); + + $http.get(config.apiUrl+ 'courses/'+course_id+"?token="+auth.token()).then( + function(response) { + console.log(response.data); + if (response.data.status == 0){ + vm.current_course = response.data.data; + console.log("courses"); + console.log(response.data.data); + } + else{ + vm.alertService.showMessage('提示', response.data.message); + } + if(!vm.current_course){ + vm.tip_1 = "该班级不存在或已被删除"; + } + } + ); + + if(vm.current_course){ + $http.get(config.apiUrl + 'courses/course_groups?token='+auth.token()+'&course_id='+course_id).then( + function(response) { + if(response.data.status == 0) { + vm.groups = response.data.groups; + } + else{ + vm.groups = []; + } + }); + } + + +}] ); \ No newline at end of file diff --git a/public/javascripts/wechat/others/routes.js b/public/javascripts/wechat/others/routes.js index e5c87d1ab..845995ec6 100644 --- a/public/javascripts/wechat/others/routes.js +++ b/public/javascripts/wechat/others/routes.js @@ -39,6 +39,7 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', func .when('/invite_code', {templateUrl: rootPath + 'invite_code.html', controller: 'InviteCodeController'}) .when('/send_class_list', makeRoute('send_class_list.html', 'SendClassListController')) .when('/join_class', makeRoute('join_class.html', 'JoinClassController')) + .when('/join_classgroup', makeRoute('join_classgroup.html', 'JoinClassGroupController')) .when('/review_class_member', makeRoute('review_class_member.html', 'ReviewClassMemberController')) .when('/class_publishnotice', makeRoute('class_publishnotice.html', 'ClassPublishNoticeController')) .when('/class_publishissue', makeRoute('class_publishissue.html', 'ClassPublishIssueController')) From 97394a6cbe529cff023cae4966f5bc686aaa0355 Mon Sep 17 00:00:00 2001 From: Tim Date: Sun, 18 Sep 2016 16:47:13 +0800 Subject: [PATCH 04/42] =?UTF-8?q?=E6=98=BE=E7=A4=BA=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E4=B8=8E=E7=8F=AD=E7=BA=A7=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 16 ++++++++-------- public/assets/wechat/class.html | 2 +- public/assets/wechat/class_publishissue.html | 2 +- public/assets/wechat/class_publishnotice.html | 2 +- public/assets/wechat/course_discussion.html | 2 +- public/assets/wechat/course_notice.html | 2 +- public/assets/wechat/homework_detail.html | 2 +- public/assets/wechat/invite_code.html | 2 +- public/assets/wechat/myresource.html | 4 ++-- public/assets/wechat/review_class_member.html | 4 ++-- public/stylesheets/weui/weixin.css | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 2d45f4d17..09490b766 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -40,7 +40,7 @@
- +
{{act.praise_count}}
@@ -75,7 +75,7 @@
- +
{{act.praise_count}}
@@ -111,7 +111,7 @@
- +
{{act.praise_count}}
@@ -147,7 +147,7 @@
- + @@ -405,7 +405,7 @@
- +
{{act.praise_count}}
@@ -440,7 +440,7 @@
- +
{{act.praise_count}}
@@ -476,7 +476,7 @@
- +
{{act.praise_count}}
@@ -512,7 +512,7 @@
- + diff --git a/public/assets/wechat/class.html b/public/assets/wechat/class.html index 836575b90..303b73057 100644 --- a/public/assets/wechat/class.html +++ b/public/assets/wechat/class.html @@ -1,6 +1,6 @@
-
邀请码
+
邀请码
diff --git a/public/assets/wechat/class_publishissue.html b/public/assets/wechat/class_publishissue.html index f4dd40552..5a65beabf 100644 --- a/public/assets/wechat/class_publishissue.html +++ b/public/assets/wechat/class_publishissue.html @@ -1,7 +1,7 @@
-
{{current_course.name}}
+
标题
diff --git a/public/assets/wechat/class_publishnotice.html b/public/assets/wechat/class_publishnotice.html index d27e378d3..e56c762a6 100644 --- a/public/assets/wechat/class_publishnotice.html +++ b/public/assets/wechat/class_publishnotice.html @@ -1,7 +1,7 @@
-
{{current_course.name}}
+
标题
diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 91aa58fcf..8dc08c788 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -24,7 +24,7 @@
{{discussion.subject}}
-
{{discussion.course_project_name}} - 班级讨论区{{discussion.created_on}}
+
{{discussion.syllabus_title}}·{{discussion.course_project_name}} - 班级讨论区{{discussion.created_on}}
diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index 247cd1fd0..3358da343 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -23,7 +23,7 @@
{{news.title}}
-
{{news.course_name}} - 课程通知{{news.created_on}}
+
{{discussion.syllabus_title}}·{{news.course_name}} - 课程通知{{news.created_on}}
diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index e5f73faa9..3898bee14 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -23,7 +23,7 @@
{{homework.name}}
-
{{homework.course_name}} - 普通作业编程作业分组作业{{homework.publish_time}}
+
{{discussion.syllabus_title}}·{{homework.course_name}} - 普通作业编程作业分组作业{{homework.publish_time}}
迟交扣分:{{homework.late_penalty}}分 匿评开启时间:{{homework.evaluation_start}}
diff --git a/public/assets/wechat/invite_code.html b/public/assets/wechat/invite_code.html index 3aaa00bbe..c6d3b425f 100644 --- a/public/assets/wechat/invite_code.html +++ b/public/assets/wechat/invite_code.html @@ -1,7 +1,7 @@
- +
邀请码:{{course.invite_code}}
diff --git a/public/assets/wechat/myresource.html b/public/assets/wechat/myresource.html index 1848dad60..df04a184f 100644 --- a/public/assets/wechat/myresource.html +++ b/public/assets/wechat/myresource.html @@ -13,7 +13,7 @@
{{r.filename}}发送
- 大小:{{r.attafile_size}}
+ 大小:{{r.attafile_size}}
更多
@@ -24,7 +24,7 @@
{{r.homework_name}}发送
-
+
更多
diff --git a/public/assets/wechat/review_class_member.html b/public/assets/wechat/review_class_member.html index e066c48f0..b1f0dacc5 100644 --- a/public/assets/wechat/review_class_member.html +++ b/public/assets/wechat/review_class_member.html @@ -2,7 +2,7 @@
-
{{current_course.name}}
+
{{current_review_member.realname == "" ? current_review_member.name : current_review_member.realname}}
角色
    @@ -29,7 +29,7 @@
-
{{current_course.name}}
+
{{tip_2}}
diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index cf44a3814..8e0b3933e 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -147,7 +147,7 @@ a.underline {text-decoration:underline;} .post-dynamic-author {width:50%; height:30px; line-height:30px; font-size:14px; color:#5b5b5b; vertical-align:middle;} .post-dynamic-time {height:30px; line-height:30px; vertical-align:middle;} .post-dynamic-title {font-size:15px;} -.post-dynamic-from {width:50%; font-size:13px;} +.post-dynamic-from {width:55%; font-size:13px;} .post-box-shadow {box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5);} .post-reply-author {width:50%; height:20px; line-height:20px; font-size:12px; color:#5d5d5d; vertical-align:middle;} .post-reply-time {height:20px; line-height:20px; vertical-align:middle;} From 7a5f21456d75dcf3cf4c7ec21d3bd9641cea4a21 Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 19 Sep 2016 11:24:44 +0800 Subject: [PATCH 05/42] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=90=8D=E5=AD=97=E4=B8=BA=E7=A9=BA=E6=97=B6=EF=BC=8C=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E6=96=87=E5=AD=97=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/edit_userinfo.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/public/assets/wechat/edit_userinfo.html b/public/assets/wechat/edit_userinfo.html index f4178fee4..3e4bf51f2 100644 --- a/public/assets/wechat/edit_userinfo.html +++ b/public/assets/wechat/edit_userinfo.html @@ -12,6 +12,7 @@
姓名
+
姓名不能为空
性别 @@ -28,10 +29,10 @@
邮箱 -
- 电子邮箱地址不能为空 - 电子邮箱地址不合法 -
+
+
+ 电子邮箱地址不能为空 + 电子邮箱地址不合法
提示 From 3624d9d4ca95863bdb2774ee84572370aa4b07d4 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Mon, 19 Sep 2016 13:22:29 +0800 Subject: [PATCH 06/42] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=88=86=E7=8F=AD=E7=9B=B8=E5=85=B3=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 | 27 +++++++- app/api/mobile/entities/course.rb | 3 + app/api/mobile/entities/user.rb | 4 ++ app/services/courses_service.rb | 2 +- public/assets/wechat/class.html | 3 +- public/assets/wechat/join_classgroup.html | 10 +-- .../assets/wechat/select_my_coursegroup.html | 25 +++++++ .../javascripts/wechat/controllers/class.js | 8 ++- .../wechat/controllers/join_class.js | 6 +- .../wechat/controllers/join_classgroup.js | 63 ++++++++++++++---- .../controllers/select_my_coursegroup.js | 66 +++++++++++++++++++ public/javascripts/wechat/others/routes.js | 1 + 12 files changed, 195 insertions(+), 23 deletions(-) create mode 100644 public/assets/wechat/select_my_coursegroup.html create mode 100644 public/javascripts/wechat/controllers/select_my_coursegroup.js diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index f0e4c867d..dd5525fae 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -757,12 +757,13 @@ module Mobile desc '获取分班列表' params do + requires :id, type: Integer requires :token, type:String end - get ':course_id/course_groups' do + get 'course_groups/:id' do begin authenticate! - course = Course.find(params[:course_id]) + course = Course.find(params[:id]) groups = [] groups = course.course_groups if course.course_groups present :data,groups @@ -772,6 +773,28 @@ module Mobile end end + desc "加入分班" + params do + requires :id, type: Integer + requires :token, type: String + requires :course_group_id, type: Integer + end + post 'join_coursegroup' do + begin + authenticate! + member = Member.where(:course_id => params[:id], :user_id => current_user.id).first + + raise "你还不是该班级的学生!" unless member + + member.course_group_id = params[:course_group_id].to_i + member.save + present :status,0 + rescue Exception=>e + present :message,e.message + present :status,-1 + end + end + end end end diff --git a/app/api/mobile/entities/course.rb b/app/api/mobile/entities/course.rb index 30a5a6cc9..9bf1cc1f6 100644 --- a/app/api/mobile/entities/course.rb +++ b/app/api/mobile/entities/course.rb @@ -19,6 +19,8 @@ module Mobile (format_time(c[field]) if (c.is_a?(Hash) && c.key?(field))) || (format_time(c.send(field)) if c.respond_to?(field)) elsif field == :member_count ::Course===c ? c.members.count : 0 + elsif field == :syllabus_title + c.syllabus.nil? ? "":c.syllabus.title else (c[field] if (c.is_a?(Hash) && c.key?(field))) || (c.send(field) if c.respond_to?(field)) end @@ -38,6 +40,7 @@ module Mobile course_expose :lft course_expose :location course_expose :name + course_expose :syllabus_title course_expose :open_student # course_expose :password course_expose :rgt diff --git a/app/api/mobile/entities/user.rb b/app/api/mobile/entities/user.rb index 30a2a7edd..09ef6a599 100644 --- a/app/api/mobile/entities/user.rb +++ b/app/api/mobile/entities/user.rb @@ -36,6 +36,8 @@ module Mobile u.lastname when :mail u.mail + when :is_me + defined? u.is_me ? u.is_me : 0 end end end @@ -77,6 +79,8 @@ module Mobile user_expose :name + user_expose :is_me + end end diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 182d1150f..2c0506d1e 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -115,7 +115,7 @@ class CoursesService role_name: m.roles.first.name, name: m.user.show_name, roles_id: role_ids.include?(7) ? 7 : (role_ids.include?(9) ? 9 : 10 ), - :brief_introduction => m.user.user_extensions.brief_introduction,:realname=>m.user.realname} + :brief_introduction => m.user.user_extensions.brief_introduction,:realname=>m.user.realname,:is_me => current_user.id == m.user.id ? 1:0 } # end end diff --git a/public/assets/wechat/class.html b/public/assets/wechat/class.html index 836575b90..30c9120c3 100644 --- a/public/assets/wechat/class.html +++ b/public/assets/wechat/class.html @@ -25,7 +25,7 @@
-
+
diff --git a/public/assets/wechat/select_my_coursegroup.html b/public/assets/wechat/select_my_coursegroup.html new file mode 100644 index 000000000..c16b276e4 --- /dev/null +++ b/public/assets/wechat/select_my_coursegroup.html @@ -0,0 +1,25 @@ +
+
+
+
我的信息
+
{{current_edit_member.user.show_name}}
+
角色
+
学生
+
选择分班
+
    +
  • +
  • +
  • +
+ +
+ 取消 + 确定 +
+
+ +
{{tip_1}}
+
{{tip_2}}
+ + +
diff --git a/public/javascripts/wechat/controllers/class.js b/public/javascripts/wechat/controllers/class.js index ea394a1ff..ca4ad6d76 100644 --- a/public/javascripts/wechat/controllers/class.js +++ b/public/javascripts/wechat/controllers/class.js @@ -247,7 +247,6 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location resetMenu(vm.course.current_user_is_teacher,vm.currentTab); } - vm.onSetting = function(user){ rms.save('current_edit_member', user); rms.save("course",vm.course); @@ -255,6 +254,13 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location $location.path("/edit_class_member").search({id: courseid,user_id: user.id}); }; + vm.onSetting_1 = function(user){ + rms.save('current_edit_member', user); + rms.save("course",vm.course); + rms.save("tab_num",vm.currentTab); + $location.path("/select_my_coursegroup").search({id: courseid}); + }; + vm.review = function(user){ rms.save('current_review_member', user); rms.save('current_course', vm.course); diff --git a/public/javascripts/wechat/controllers/join_class.js b/public/javascripts/wechat/controllers/join_class.js index 8f7647b12..709072562 100644 --- a/public/javascripts/wechat/controllers/join_class.js +++ b/public/javascripts/wechat/controllers/join_class.js @@ -67,7 +67,11 @@ app.controller('JoinClassController', ['$scope', '$http', 'auth', 'config', 'ale } }); } else { - vm.alertService.showMessage('提示', response.data.message); + vm.alertService.showMessage('提示', response.data.message,function(){ + if(response.data.go_coursegroup_flag == 1) { + $location.path("/join_classgroup").search({id: response.data.course_id}); + } + }); } }); }; diff --git a/public/javascripts/wechat/controllers/join_classgroup.js b/public/javascripts/wechat/controllers/join_classgroup.js index 504643817..a661ba6fc 100644 --- a/public/javascripts/wechat/controllers/join_classgroup.js +++ b/public/javascripts/wechat/controllers/join_classgroup.js @@ -5,14 +5,28 @@ app.controller('JoinClassGroupController', ['$scope', '$http', 'auth', 'config', var course_id = $routeParams.id; vm.alertService = alertService.create(); + vm.selectid = 0; $http.get(config.apiUrl+ 'courses/'+course_id+"?token="+auth.token()).then( function(response) { console.log(response.data); if (response.data.status == 0){ vm.current_course = response.data.data; - console.log("courses"); + console.log("courses="); console.log(response.data.data); + if(vm.current_course){ + $http.get(config.apiUrl + 'courses/course_groups/'+course_id+'?token='+auth.token()).then( + function(response) { + console.log("groups="); + console.log(response); + if(response.data.status == 0) { + vm.groups = response.data.data; + } + else{ + vm.groups = []; + } + }); + } } else{ vm.alertService.showMessage('提示', response.data.message); @@ -23,17 +37,42 @@ app.controller('JoinClassGroupController', ['$scope', '$http', 'auth', 'config', } ); - if(vm.current_course){ - $http.get(config.apiUrl + 'courses/course_groups?token='+auth.token()+'&course_id='+course_id).then( - function(response) { - if(response.data.status == 0) { - vm.groups = response.data.groups; - } - else{ - vm.groups = []; - } - }); - } + vm.selectGroup = function(id){ + vm.selectid = id; + }; + vm.cancel = function(){ + + }; + + vm.confirm = function(){ + if(vm.selectid == 0){ + rms.save('syllabuses',[]); + $location.path("/class_list"); + return; + } + + //加入分班 + $http.post(config.apiUrl+'courses/join_coursegroup', { + token: auth.token(), + id: course_id, + course_group_id:vm.selectid + }).then(function(response){ + console.log(response); + if(response.data.status == 0){ + vm.alertService.showMessage('提示', "加入分班成功!",function(){ + rms.save('syllabuses',[]); + $location.path("/class_list"); + + }); + } else { + vm.alertService.showMessage('提示', response.data.message,function(){ + rms.save('syllabuses',[]); + $location.path("/class_list"); + }); + } + }); + }; + }] ); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/select_my_coursegroup.js b/public/javascripts/wechat/controllers/select_my_coursegroup.js new file mode 100644 index 000000000..2c338d33f --- /dev/null +++ b/public/javascripts/wechat/controllers/select_my_coursegroup.js @@ -0,0 +1,66 @@ + + +app.controller('SelectMyCourseGroupController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms','common', function($scope, $http, auth, config, alertService, $location,$routeParams, rms,common){ +// common.checkLogin(); + + var vm = $scope; + + vm.current_review_member = rms.get('current_review_member'); + + vm.alertService = alertService.create(); + + vm.tip_1 = ""; + vm.tip_2 = ""; + + var course_id = $routeParams.id; + if(!vm.current_course){ + $http.get(config.apiUrl+ 'courses/'+course_id+"?token="+auth.token()).then( + function(response) { + console.log(response.data); + if (response.data.status == 0){ + vm.current_course = response.data.data; + console.log("courses"); + console.log(response.data.data); + } + else{ + vm.alertService.showMessage('提示', response.data.message); + } + if(!vm.current_course){ + vm.tip_1 = "该班级不存在或已被删除"; + } + + } + ); + } + + if(!vm.current_edit_member){ + $http.post(config.apiUrl+'courses/get_member_info', { + token: auth.token(), + id: course_id, + user_id:user_id + }).then(function(response){ + if(response.data.status!=0){ + vm.alertService.showMessage('提示', response.data.message,function(){ + $location.path("/class").search({id: course_id,tag:1}); + }); + } else { + console.log(response); + course_id = response.data.course_id; + vm.current_edit_member = response.data.member_info; + vm.current_roles_id = vm.current_edit_member.roles_id; + + for(var i in vm.current_roles_id){ + if(vm.current_roles_id[i] == 10){ + vm.student = true; + return; + } + } + + if(!vm.student){ + vm.tip_2 = "您不是该班级的学生!"; + } + } + }); + } + +}] ); \ No newline at end of file diff --git a/public/javascripts/wechat/others/routes.js b/public/javascripts/wechat/others/routes.js index 845995ec6..7b5434ddd 100644 --- a/public/javascripts/wechat/others/routes.js +++ b/public/javascripts/wechat/others/routes.js @@ -41,6 +41,7 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', func .when('/join_class', makeRoute('join_class.html', 'JoinClassController')) .when('/join_classgroup', makeRoute('join_classgroup.html', 'JoinClassGroupController')) .when('/review_class_member', makeRoute('review_class_member.html', 'ReviewClassMemberController')) + .when('/select_my_coursegroup', makeRoute('select_my_coursegroup.html', 'SelectMyCourseGroupController')) .when('/class_publishnotice', makeRoute('class_publishnotice.html', 'ClassPublishNoticeController')) .when('/class_publishissue', makeRoute('class_publishissue.html', 'ClassPublishIssueController')) .when('/project_list', makeRoute('project_list.html', 'ProjectListController')) From 5b613964103a1742137c41221f9d81db41a1011b Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Mon, 19 Sep 2016 13:53:15 +0800 Subject: [PATCH 07/42] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/attachment.rb | 3 +++ app/api/mobile/entities/course.rb | 3 --- app/api/mobile/entities/exercise.rb | 3 +++ app/api/mobile/entities/homework.rb | 4 ++++ app/api/mobile/entities/message.rb | 5 +++++ app/api/mobile/entities/news.rb | 6 ++++++ app/api/mobile/entities/whomework.rb | 3 +++ 7 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/api/mobile/entities/attachment.rb b/app/api/mobile/entities/attachment.rb index 8200c04b2..0eda2d1c0 100644 --- a/app/api/mobile/entities/attachment.rb +++ b/app/api/mobile/entities/attachment.rb @@ -23,6 +23,8 @@ module Mobile (number_to_human_size(f.filesize)).gsub("ytes", "").to_s when :coursename f.course.nil? ? "" : f.course.name + when :syllabus_title + f.course.nil? ? "" : f.course.syllabus.nil? ? "" : f.course.syllabus.title when :course_id f.course.nil? ? 0 : f.course.id @@ -40,6 +42,7 @@ module Mobile attachment_expose :file_dir attachment_expose :attafile_size attachment_expose :coursename #所属班级名 + attachment_expose :syllabus_title #所属班级名 attachment_expose :course_id #所属班级名 expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options| current_user = options[:user] diff --git a/app/api/mobile/entities/course.rb b/app/api/mobile/entities/course.rb index 9bf1cc1f6..30a5a6cc9 100644 --- a/app/api/mobile/entities/course.rb +++ b/app/api/mobile/entities/course.rb @@ -19,8 +19,6 @@ module Mobile (format_time(c[field]) if (c.is_a?(Hash) && c.key?(field))) || (format_time(c.send(field)) if c.respond_to?(field)) elsif field == :member_count ::Course===c ? c.members.count : 0 - elsif field == :syllabus_title - c.syllabus.nil? ? "":c.syllabus.title else (c[field] if (c.is_a?(Hash) && c.key?(field))) || (c.send(field) if c.respond_to?(field)) end @@ -40,7 +38,6 @@ module Mobile course_expose :lft course_expose :location course_expose :name - course_expose :syllabus_title course_expose :open_student # course_expose :password course_expose :rgt diff --git a/app/api/mobile/entities/exercise.rb b/app/api/mobile/entities/exercise.rb index ce6a2fb39..821380b47 100644 --- a/app/api/mobile/entities/exercise.rb +++ b/app/api/mobile/entities/exercise.rb @@ -19,6 +19,8 @@ module Mobile case field when :coursename f.course.nil? ? "" : f.course.name + when :syllabus_title + f.course.nil? ? "" : f.course.syllabus.nil? ? "" : f.course.syllabus.title end end end @@ -27,6 +29,7 @@ module Mobile expose :exercise_name expose :exercise_description exercise_expose :coursename #所属班级名 + exercise_expose :syllabus_title expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options| current_user = options[:user] diff --git a/app/api/mobile/entities/homework.rb b/app/api/mobile/entities/homework.rb index a5b981c6d..d149681e4 100644 --- a/app/api/mobile/entities/homework.rb +++ b/app/api/mobile/entities/homework.rb @@ -39,6 +39,8 @@ module Mobile val when :coursename f.course.nil? ? "" : f.course.name + when :syllabus_title + f.course.nil? ? "" : f.course.syllabus.nil? ? "" : f.course.syllabus.title end end end @@ -49,6 +51,8 @@ module Mobile #课程名称 homework_expose :course_name + homework_expose :syllabus_title + homework_expose :course_id #作业发布者 expose :author,using: Mobile::Entities::User do |f, opt| diff --git a/app/api/mobile/entities/message.rb b/app/api/mobile/entities/message.rb index 07c560a1f..189b52851 100644 --- a/app/api/mobile/entities/message.rb +++ b/app/api/mobile/entities/message.rb @@ -22,6 +22,10 @@ module Mobile else u.project.name end + when :syllabus_title + if u.board.project_id == -1 + u.course.syllabus.nil? ? "" : u.course.syllabus.title + end when :lasted_comment time_from_now u.created_on when :praise_count @@ -50,6 +54,7 @@ module Mobile message_expose :act_type message_expose :act_id message_expose :course_project_name + message_expose :syllabus_title message_expose :board_id message_expose :subject message_expose :title diff --git a/app/api/mobile/entities/news.rb b/app/api/mobile/entities/news.rb index d8c4dcab3..4515791cd 100644 --- a/app/api/mobile/entities/news.rb +++ b/app/api/mobile/entities/news.rb @@ -26,6 +26,11 @@ module Mobile f.id when :comment_count f.comments.count + when :syllabus_title + unless f.course_id == nil + course = get_course(f.course_id) + course.syllabus.nil? ? "" : course.syllabus.title + end end end elsif f.is_a?(::Comment) @@ -89,6 +94,7 @@ module Mobile news_expose :praise_count #课程名字 news_expose :course_name + news_expose :syllabus_title news_expose :lasted_comment #评论 diff --git a/app/api/mobile/entities/whomework.rb b/app/api/mobile/entities/whomework.rb index 9d141552a..b19d34f05 100644 --- a/app/api/mobile/entities/whomework.rb +++ b/app/api/mobile/entities/whomework.rb @@ -30,6 +30,8 @@ module Mobile wh.journals_for_messages.count when :course_name wh.course.name + when :syllabus_title + wh.course.syllabus.nil? ? "" : wh.course.syllabus.title when :act_type 'HomeworkCommon' when :act_id @@ -65,6 +67,7 @@ module Mobile whomework_expose :act_type whomework_expose :act_id whomework_expose :course_name + whomework_expose :syllabus_title whomework_expose :created_at whomework_expose :absence_penalty whomework_expose :evaluation_start From 126c18f8333f4afd3fbb60cd53140f6c24927283 Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 19 Sep 2016 14:00:52 +0800 Subject: [PATCH 08/42] =?UTF-8?q?=E6=88=91=E7=9A=84=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=9D=A5=E6=BA=90=E5=AE=BD=E5=BA=A6=E8=B0=83?= =?UTF-8?q?=E6=95=B4=EF=BC=9B=E7=8F=AD=E7=BA=A7=E5=8A=A8=E6=80=81=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E9=9D=A2=E6=98=BE=E7=A4=BA=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/course_notice.html | 2 +- public/assets/wechat/homework_detail.html | 2 +- public/stylesheets/weui/weixin.css | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index 3358da343..a0c242d72 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -23,7 +23,7 @@
{{news.title}}
-
{{discussion.syllabus_title}}·{{news.course_name}} - 课程通知{{news.created_on}}
+
{{news.syllabus_title}}·{{news.course_name}} - 课程通知{{news.created_on}}
diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index 3898bee14..908cff977 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -23,7 +23,7 @@
{{homework.name}}
-
{{discussion.syllabus_title}}·{{homework.course_name}} - 普通作业编程作业分组作业{{homework.publish_time}}
+
{{homework.syllabus_title}}·{{homework.course_name}} - 普通作业编程作业分组作业{{homework.publish_time}}
迟交扣分:{{homework.late_penalty}}分 匿评开启时间:{{homework.evaluation_start}}
diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index 8e0b3933e..d2d92a361 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -203,7 +203,7 @@ a.underline {text-decoration:underline;} .img-circle {border-radius:50% !important;} .member-banner {height:24px; line-height:24px; text-align:center; vertical-align:middle; background-color:#dfdfdf;} .resource-width {width:76%;} -.courseware-from-width {max-width:57%;} +.courseware-from-width {max-width:50%;} .other-from-width {max-width:80%;} .course-name-width {width:68%;} From 9c214ef57b9756683a1e2f8f8daec86d5414e669 Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 19 Sep 2016 14:07:32 +0800 Subject: [PATCH 09/42] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E8=B5=84=E6=96=99?= =?UTF-8?q?=E6=96=87=E5=AD=97=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/edit_userinfo.html | 6 +++--- public/stylesheets/weui/weixin.css | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/public/assets/wechat/edit_userinfo.html b/public/assets/wechat/edit_userinfo.html index 3e4bf51f2..b0a00bba2 100644 --- a/public/assets/wechat/edit_userinfo.html +++ b/public/assets/wechat/edit_userinfo.html @@ -12,7 +12,7 @@
姓名
-
姓名不能为空
+
姓名不能为空
性别 @@ -31,8 +31,8 @@
- 电子邮箱地址不能为空 - 电子邮箱地址不合法 + 电子邮箱地址不能为空 + 电子邮箱地址不合法
提示 diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index d2d92a361..aa4cff972 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -43,6 +43,7 @@ blockquote {border:1px solid #d4d4d4; padding: 0.6em; margin: 5px 0.4em 5px 1.4e .mr25 {margin-right:25px;} .ml55 {margin-left:55px;} .mr55 {margin-right:55px;} +.ml65 {margin-left:65px;} .c-red {color:#e81a1a;} .c-blue {color:#269ac9;} .c-grey {color:#9a9a9a !important;} From ba4a1c64d9e18ebc8609f73615dc8a899fe359d2 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 19 Sep 2016 17:14:14 +0800 Subject: [PATCH 10/42] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E7=9A=84=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 58 ++++++++----------- app/controllers/student_work_controller.rb | 15 ++--- app/controllers/users_controller.rb | 13 ++--- app/controllers/words_controller.rb | 11 ++-- app/helpers/application_helper.rb | 6 +- app/helpers/homework_common_helper.rb | 6 +- app/views/courses/_course_activity.html.erb | 2 +- .../_user_homework_search_list.html.erb | 2 +- app/views/courses/homework_search.js.erb | 4 +- .../homework_common/_alert_anonyoms.html.erb | 2 +- .../_alert_open_student_works.html.erb | 2 +- .../_homework_index_list.html.erb | 2 +- .../_set_evalutation_att.html.erb | 2 +- .../alert_forbidden_anonymous_comment.js.erb | 2 +- app/views/homework_common/edit.html.erb | 15 ++--- .../homework_common/open_student_works.js.erb | 9 ++- .../homework_common/score_rule_set.js.erb | 2 +- .../set_evaluation_attr.js.erb | 5 +- .../start_anonymous_comment.js.erb | 12 ++-- .../start_evaluation_set.js.erb | 2 +- .../stop_anonymous_comment.js.erb | 10 ++-- .../organizations/_org_activities.html.erb | 2 +- .../_alert_forbidden_anonymous.html.erb | 2 +- .../student_work/_relate_project.html.erb | 2 +- .../student_work/_set_score_rule.html.erb | 2 +- .../student_work/cancel_relate_project.js.erb | 11 ++-- .../forbidden_anonymous_comment.js.erb | 9 ++- app/views/student_work/set_score_rule.js.erb | 5 +- .../student_work/student_work_project.js.erb | 11 ++-- app/views/users/_course_homework.html.erb | 47 +++++++++------ app/views/users/_news_replies.html.erb | 4 +- app/views/users/_reply_banner.html.erb | 8 +-- app/views/users/_reply_to.html.erb | 3 +- app/views/users/_user_activities.html.erb | 2 +- app/views/users/_user_homework_list.html.erb | 11 +--- app/views/users/_user_homeworks_old.html.erb | 47 --------------- app/views/users/all_journals.js.erb | 2 +- app/views/words/destroy.js.erb | 9 ++- app/views/words/leave_homework_message.js.erb | 13 ++--- app/views/words/reply_to_homework.js.erb | 7 +-- public/javascripts/application.js | 5 +- 41 files changed, 149 insertions(+), 235 deletions(-) delete mode 100644 app/views/users/_user_homeworks_old.html.erb diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index b8c6a4a0a..b5d55df28 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -58,10 +58,9 @@ class HomeworkCommonController < ApplicationController def edit @user = User.current - @is_in_course = params[:is_in_course] + @hw_status = params[:hw_status].to_i @is_manage = params[:is_manage] - @course_activity = params[:course_activity].to_i - if @is_in_course.to_i == 1 || @course_activity == 1 + if @hw_status != 1 @left_nav_type = 3 respond_to do |format| format.html{render :layout => 'base_courses'} @@ -160,18 +159,17 @@ class HomeworkCommonController < ApplicationController create_works_list @homework end + @hw_status = params[:hw_status].to_i if params[:is_manage] == "1" redirect_to manage_or_receive_homeworks_user_path(User.current.id) elsif params[:is_manage] == "2" redirect_to my_homeworks_user_path(User.current.id) - elsif params[:is_in_course] == "1" - redirect_to homework_common_index_path(:course => @course.id) - elsif params[:is_in_course] == "0" - redirect_to user_homeworks_user_path(User.current.id) - elsif params[:is_in_course] == "-1" && params[:course_activity] == "0" + elsif @hw_status == 1 redirect_to user_path(User.current.id) - elsif params[:is_in_course] == "-1" && params[:course_activity] == "1" + elsif @hw_status == 2 redirect_to course_path(@course.id) + else + redirect_to homework_common_index_path(:course => @course.id) end end end @@ -181,14 +179,13 @@ class HomeworkCommonController < ApplicationController if @homework.destroy respond_to do |format| format.html { - if params[:is_in_course] == "1" - redirect_to homework_common_index_path(:course => @course.id) - elsif params[:is_in_course] == "0" - redirect_to user_homeworks_user_path(User.current.id) - elsif params[:is_in_course] == "-1" && params[:course_activity] == "0" - redirect_to user_path(User.current.id) - elsif params[:is_in_course] == "-1" && params[:course_activity] == "1" - redirect_to course_path(@course.id) + @hw_status = params[:hw_status].to_i + if @hw_status == 1 + redirect_to user_path(User.current.id) + elsif @hw_status == 2 + redirect_to course_path(@course.id) + else + redirect_to homework_common_index_path(:course => @course.id) end } end @@ -246,8 +243,7 @@ class HomeworkCommonController < ApplicationController @statue = 3 end @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i end #关闭匿评 @@ -265,8 +261,7 @@ class HomeworkCommonController < ApplicationController send_message_anonymous_comment(@homework, m_status = 3) Mailer.send_mail_anonymous_comment_close(@homework).deliver @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i respond_to do |format| format.js end @@ -294,8 +289,7 @@ class HomeworkCommonController < ApplicationController end @percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100) @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i respond_to do |format| format.js end @@ -307,8 +301,7 @@ class HomeworkCommonController < ApplicationController else @user_activity_id = -1 end - @is_in_course = params[:is_in_course] if params[:is_in_course] - @course_activity = params[:course_activity] if params[:course_Activity] + @hw_status = params[:hw_status].to_i respond_to do |format| format.js end @@ -321,8 +314,7 @@ class HomeworkCommonController < ApplicationController @homework.update_column('is_open', 0) end @user_activity_id = params[:user_activity_id] - @is_in_course = params[:is_in_course] if params[:is_in_course] - @course_activity = params[:course_activity] if params[:course_Activity] + @hw_status = params[:hw_status].to_i end def alert_open_student_works @@ -331,8 +323,7 @@ class HomeworkCommonController < ApplicationController else @user_activity_id = -1 end - @is_in_course = params[:is_in_course] if params[:is_in_course] - @course_activity = params[:course_activity] if params[:course_Activity] + @hw_status = params[:hw_status].to_i respond_to do |format| format.js end @@ -363,8 +354,7 @@ class HomeworkCommonController < ApplicationController else @user_activity_id = -1 end - @is_in_course = params[:is_in_course] - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i end #设置匿评参数 @@ -381,8 +371,7 @@ class HomeworkCommonController < ApplicationController @homework_detail_manual.evaluation_num = params[:evaluation_num] @homework_detail_manual.save @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i end end @@ -393,8 +382,7 @@ class HomeworkCommonController < ApplicationController else @user_activity_id = -1 end - @is_in_course = params[:is_in_course] - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i end private diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index f6a97e66c..b259737a1 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -1012,8 +1012,7 @@ class StudentWorkController < ApplicationController redirect_to student_work_index_url(:homework => @homework.id) else @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i respond_to do |format| format.js end @@ -1035,8 +1034,7 @@ class StudentWorkController < ApplicationController student_work.save end @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i end def revise_attachment @@ -1058,8 +1056,7 @@ class StudentWorkController < ApplicationController def new_student_work_project @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i respond_to do |format| format.js end @@ -1078,8 +1075,7 @@ class StudentWorkController < ApplicationController @project.is_leader = 1 if @project.save @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i respond_to do |format| format.js end @@ -1129,8 +1125,7 @@ class StudentWorkController < ApplicationController relate_pro = StudentWorkProject.where("user_id = #{User.current.id} and homework_common_id = #{@homework.id}").first if relate_pro.destroy @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i respond_to do |format| format.js end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index bdbaf1738..87dc127a0 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -115,8 +115,7 @@ class UsersController < ApplicationController else @user_activity_id = -1 end - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i when 'JournalsForMessage' @reply = JournalsForMessage.find params[:reply_id] @user_activity_id = params[:user_activity_id] @@ -1123,11 +1122,8 @@ class UsersController < ApplicationController quotes_homework = HomeworkCommon.find params[:quotes].to_i quotes_homework.update_column(:quotes, quotes_homework.quotes+1) end - if params[:is_in_course] == "1" - redirect_to homework_common_index_path(:course => homework.course_id) - else - redirect_to user_homeworks_user_path(User.current.id) - end + + redirect_to homework_common_index_path(:course => homework.course_id) end end else @@ -3573,8 +3569,7 @@ class UsersController < ApplicationController obj = HomeworkCommon.where('id = ?', params[:id].to_i).first @type = 'HomeworkCommon' @journals = obj.journals_for_messages.reorder("created_on desc") - @is_in_course = params[:is_in_course].to_i if params[:is_in_course] - @course_activity = params[:course_activity].to_i if params[:course_activity] + @hw_status = params[:hw_status].to_i if params[:hw_status] @is_teacher = User.current.allowed_to?(:as_teacher,obj.course) @user_activity_id = params[:user_activity_id].to_i if params[:user_activity_id] end diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 499272706..f1bfc7a31 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -110,8 +110,7 @@ class WordsController < ApplicationController else @user_activity_id = -1 end - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i elsif @journal_destroyed.jour_type == 'Syllabus' @syllabus = Syllabus.find @journal_destroyed.jour_id @count = @syllabus.journals_for_messages.count @@ -308,9 +307,8 @@ class WordsController < ApplicationController update_org_activity(@homework_common.class,@homework_common.id) respond_to do |format| format.js{ - @user_activity_id = params[:user_activity_id] - @is_in_course = params[:is_in_course] - @course_activity = params[:course_activity] + @user_activity_id = params[:user_activity_id].to_i + @hw_status = params[:hw_status].to_i @homework_common_id = params[:homework_common_id] } end @@ -344,8 +342,7 @@ class WordsController < ApplicationController respond_to do |format| format.js{ @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i } end else diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d3b28fb20..d9a694eaa 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2689,15 +2689,15 @@ module ApplicationHelper end #获取匿评相关连接代码 - def homework_anonymous_comment (homework, is_in_course, user_activity_id = -1, course_activity = -1) + def homework_anonymous_comment (homework, hw_status, user_activity_id = -1) if homework.homework_detail_manual.comment_status == 0 ||Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") link = link_to "启动匿评","javascript:void(0)", :class => "postOptionLink", :title => "作业截止日期之前不可以启动匿评" elsif homework.student_works.has_committed.count >= 2 && homework.homework_detail_manual#作业份数大于2 case homework.homework_detail_manual.comment_status when 1 - link = link_to '启动匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?is_in_course=" + is_in_course.to_s + "&user_activity_id=" + user_activity_id.to_s + "&course_activity=" + course_activity.to_s, id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'postOptionLink' + link = link_to '启动匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?hw_status=" + hw_status.to_s + "&user_activity_id=" + user_activity_id.to_s, id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'postOptionLink' when 2 - link = link_to '关闭匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?is_in_course=" + is_in_course.to_s + "&user_activity_id=" + user_activity_id.to_s + "&course_activity=" + course_activity.to_s, id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'postOptionLink' + link = link_to '关闭匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?hw_status=" + hw_status.to_s + "&user_activity_id=" + user_activity_id.to_s, id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'postOptionLink' when 3 # link = link_to "匿评结束","javascript:void(0)", :class => "postOptionLink", :title => "匿评结束" end diff --git a/app/helpers/homework_common_helper.rb b/app/helpers/homework_common_helper.rb index 2d3c72c20..d79a7a432 100644 --- a/app/helpers/homework_common_helper.rb +++ b/app/helpers/homework_common_helper.rb @@ -57,12 +57,12 @@ module HomeworkCommonHelper end #根据传入作业确定跳转到开启匿评还是关闭匿评功能 - def alert_anonyoms_path homework,homework_detail_manual,user_activity_id,is_in_course,course_activity + def alert_anonyoms_path homework,homework_detail_manual,user_activity_id,hw_status link = "" if homework_detail_manual.comment_status == 1 - link = start_anonymous_comment_homework_common_url homework.id,:user_activity_id=>user_activity_id,:is_in_course=>is_in_course,:course_activity=>course_activity + link = start_anonymous_comment_homework_common_url homework.id,:user_activity_id=>user_activity_id,:hw_status=>hw_status elsif homework_detail_manual.comment_status == 2 - link = stop_anonymous_comment_homework_common_url homework.id,:user_activity_id=>user_activity_id,:is_in_course=>is_in_course,:course_activity=>course_activity + link = stop_anonymous_comment_homework_common_url homework.id,:user_activity_id=>user_activity_id,:hw_status=>hw_status end link end diff --git a/app/views/courses/_course_activity.html.erb b/app/views/courses/_course_activity.html.erb index c71e5ade4..a7f99f2b0 100644 --- a/app/views/courses/_course_activity.html.erb +++ b/app/views/courses/_course_activity.html.erb @@ -60,7 +60,7 @@ <% act = activity.course_act %> <% case activity.course_act_type.to_s %> <% when 'HomeworkCommon' %> - <%= render :partial => 'users/course_homework', :locals => {:activity => act, :user_activity_id => activity.id, :course_activity => 1} %> + <%= render :partial => 'users/course_homework', :locals => {:activity => act, :user_activity_id => activity.id, :hw_status => 2} %> <% when 'News' %> <%= render :partial => 'users/course_news', :locals => {:activity => act, :user_activity_id => activity.id} %> <% when 'Message' %> diff --git a/app/views/courses/_user_homework_search_list.html.erb b/app/views/courses/_user_homework_search_list.html.erb index 750e7537c..ecc0d1d7e 100644 --- a/app/views/courses/_user_homework_search_list.html.erb +++ b/app/views/courses/_user_homework_search_list.html.erb @@ -26,7 +26,7 @@ } } - <%= render :partial => 'users/user_homework_detail', :locals => {:homework_common => homework_common,:is_in_course => is_in_course} %> + <%= render :partial => 'users/course_homework', :locals => {:activity => homework_common,:user_activity_id => homework_common.id, :hw_status => 3} %> <% end%> <% if homework_commons.count == 10%> <%= link_to "点击展开更多",homework_search_course_path(course_id,:page => page,:search=>search),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%> diff --git a/app/views/courses/homework_search.js.erb b/app/views/courses/homework_search.js.erb index 3c644ad9e..5e2f81f01 100644 --- a/app/views/courses/homework_search.js.erb +++ b/app/views/courses/homework_search.js.erb @@ -1,5 +1,5 @@ <% if @page == 0 %> - $("#user_homework_list").replaceWith("<%= escape_javascript( render :partial => 'courses/user_homework_search_list',:locals => {:homework_commons => @homeworks, :page => @page, :is_in_course => 1,:course_id => @course.id,:search=>@search} )%>"); + $("#user_homework_list").replaceWith("<%= escape_javascript( render :partial => 'courses/user_homework_search_list',:locals => {:homework_commons => @homeworks, :page => @page, :course_id => @course.id,:search=>@search} )%>"); <% else %> - $("#user_show_more_homework").replaceWith("<%= escape_javascript( render :partial => 'courses/user_homework_search_list',:locals => {:homework_commons => @homeworks, :page => @page, :is_in_course => 1,:course_id => @course.id,:search=>@search} )%>"); + $("#user_show_more_homework").replaceWith("<%= escape_javascript( render :partial => 'courses/user_homework_search_list',:locals => {:homework_commons => @homeworks, :page => @page, :course_id => @course.id,:search=>@search} )%>"); <% end %> \ No newline at end of file diff --git a/app/views/homework_common/_alert_anonyoms.html.erb b/app/views/homework_common/_alert_anonyoms.html.erb index 79840cb35..8834d6746 100644 --- a/app/views/homework_common/_alert_anonyoms.html.erb +++ b/app/views/homework_common/_alert_anonyoms.html.erb @@ -32,7 +32,7 @@

<% end %>
- + 确  定 diff --git a/app/views/homework_common/_alert_open_student_works.html.erb b/app/views/homework_common/_alert_open_student_works.html.erb index 73c7f0b47..4eda8e458 100644 --- a/app/views/homework_common/_alert_open_student_works.html.erb +++ b/app/views/homework_common/_alert_open_student_works.html.erb @@ -22,7 +22,7 @@

<% end %>
- + 确  定 diff --git a/app/views/homework_common/_homework_index_list.html.erb b/app/views/homework_common/_homework_index_list.html.erb index 9b11017e8..dcbe8d411 100644 --- a/app/views/homework_common/_homework_index_list.html.erb +++ b/app/views/homework_common/_homework_index_list.html.erb @@ -1,4 +1,4 @@ -<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => homework_commons,:page => 0,:is_in_course => 1,:course_id => course_id} %> +<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => homework_commons,:page => 0,:course_id => course_id} %>
    diff --git a/app/views/homework_common/_set_evalutation_att.html.erb b/app/views/homework_common/_set_evalutation_att.html.erb index bc4e8e733..eff138305 100644 --- a/app/views/homework_common/_set_evalutation_att.html.erb +++ b/app/views/homework_common/_set_evalutation_att.html.erb @@ -1,5 +1,5 @@
    - <%= form_for('new_form',:url => {:controller => 'homework_common',:action => 'set_evaluation_attr',:homework => @homework.id,:user_activity_id=>user_activity_id,:is_in_course=>is_in_course,:course_activity=>course_activity},:method => "post",:remote => true) do |f|%> + <%= form_for('new_form',:url => {:controller => 'homework_common',:action => 'set_evaluation_attr',:homework => @homework.id,:user_activity_id=>user_activity_id,:hw_status=>hw_status},:method => "post",:remote => true) do |f|%> 匿评设置
    diff --git a/app/views/homework_common/alert_forbidden_anonymous_comment.js.erb b/app/views/homework_common/alert_forbidden_anonymous_comment.js.erb index 1e81df9e7..354f217e2 100644 --- a/app/views/homework_common/alert_forbidden_anonymous_comment.js.erb +++ b/app/views/homework_common/alert_forbidden_anonymous_comment.js.erb @@ -1,4 +1,4 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/alert_forbidden_anonymous', :locals => {:user_activity_id => @user_activity_id,:is_in_course => @is_in_course,:course_activity => @course_activity}) %>'); +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/alert_forbidden_anonymous', :locals => {:user_activity_id => @user_activity_id,:hw_status => @hw_status}) %>'); showModal('ajax-modal', '500px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before("" + diff --git a/app/views/homework_common/edit.html.erb b/app/views/homework_common/edit.html.erb index 4a3de027b..ec5ecc31c 100644 --- a/app/views/homework_common/edit.html.erb +++ b/app/views/homework_common/edit.html.erb @@ -1,5 +1,5 @@ -
    +
    编辑作业
    @@ -56,8 +54,7 @@ <% end %> <%= form_for @homework do |f| %> - - +
    <%= render :partial => 'users/user_homework_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %> diff --git a/app/views/homework_common/open_student_works.js.erb b/app/views/homework_common/open_student_works.js.erb index e171e65d1..2dd4a88a4 100644 --- a/app/views/homework_common/open_student_works.js.erb +++ b/app/views/homework_common/open_student_works.js.erb @@ -1,7 +1,6 @@ -<% if @user_activity_id.to_i == -1 %> -$("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => "users/user_homework_detail",:locals => {:homework_common => @homework, :is_in_course => @is_in_course})%>"); -sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>"); -<% else %> -$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity=>@course_activity}) %>"); +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>"); +<% if @user_activity_id != @homework.id %> sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); +<% else %> +sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>"); <% end %> \ No newline at end of file diff --git a/app/views/homework_common/score_rule_set.js.erb b/app/views/homework_common/score_rule_set.js.erb index f83b51b55..2ea1fe4a5 100644 --- a/app/views/homework_common/score_rule_set.js.erb +++ b/app/views/homework_common/score_rule_set.js.erb @@ -1,4 +1,4 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/set_score_rule',:locals => {:homework => @homework, :student_path => false, :user_activity_id => @user_activity_id,:is_in_course => @is_in_course,:course_activity =>@course_activity,:remote=>true}) %>'); +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/set_score_rule',:locals => {:homework => @homework, :student_path => false, :user_activity_id => @user_activity_id,:hw_status => @hw_status,:remote=>true}) %>'); showModal('ajax-modal', '350px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before("" + diff --git a/app/views/homework_common/set_evaluation_attr.js.erb b/app/views/homework_common/set_evaluation_attr.js.erb index 987abd351..42bc842bc 100644 --- a/app/views/homework_common/set_evaluation_attr.js.erb +++ b/app/views/homework_common/set_evaluation_attr.js.erb @@ -1,8 +1,7 @@ clickCanel(); -<% if @user_activity_id != -1 %> -$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity=>@courae_activity}) %>"); +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>"); +<% if @user_activity_id != @homework.id %> sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); <% else %> -$("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework,:is_in_course => @is_in_course}) %>"); sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>"); <% end %> \ No newline at end of file diff --git a/app/views/homework_common/start_anonymous_comment.js.erb b/app/views/homework_common/start_anonymous_comment.js.erb index 91a68011e..94db99dd8 100644 --- a/app/views/homework_common/start_anonymous_comment.js.erb +++ b/app/views/homework_common/start_anonymous_comment.js.erb @@ -1,13 +1,11 @@ <% if @statue == 1%> alert('启动成功'); - <% if @user_activity_id == -1 %> - $("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => "users/user_homework_detail",:locals => {:homework_common => @homework, :is_in_course => @is_in_course})%>"); - $("#evaluation_start_time_<%=@homework.id %>").html("匿评开启时间:<%=format_time(Time.now) %>"); - sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>"); - <% else %> - $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity=>@course_activity}) %>"); - $("#evaluation_start_time_<%=@user_activity_id %>").html("匿评开启时间:<%=format_time(Time.now) %>"); + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>"); + $("#evaluation_start_time_<%=@user_activity_id %>").html("匿评开启时间:<%=format_time(Time.now) %>"); + <% if @user_activity_id != @homework.id %> sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); + <% else %> + sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>"); <% end %> /*$("#<%#= @homework.id %>_start_anonymous_comment").replaceWith('<%#= escape_javascript(link_to "关闭匿评", alert_anonymous_comment_homework_common_path(@homework), remote: true, id:"#{@homework.id}_stop_anonymous_comment",:class => "postOptionLink")%>');*/ <% elsif @statue == 2 %> diff --git a/app/views/homework_common/start_evaluation_set.js.erb b/app/views/homework_common/start_evaluation_set.js.erb index 6ed74d0f0..3ece646dc 100644 --- a/app/views/homework_common/start_evaluation_set.js.erb +++ b/app/views/homework_common/start_evaluation_set.js.erb @@ -1,4 +1,4 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'homework_common/set_evalutation_att',:locals => {:user_activity_id => @user_activity_id,:is_in_course => @is_in_course,:course_activity =>@course_activity,:remote=>true}) %>'); +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'homework_common/set_evalutation_att',:locals => {:user_activity_id => @user_activity_id,:hw_status => @hw_status,:remote=>true}) %>'); var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: 0, showOn: 'button', buttonImageOnly: true, buttonImage: '/images/public_icon.png', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true}; showModal('ajax-modal', '350px'); $('#ajax-modal').siblings().remove(); diff --git a/app/views/homework_common/stop_anonymous_comment.js.erb b/app/views/homework_common/stop_anonymous_comment.js.erb index 874374476..c540c323d 100644 --- a/app/views/homework_common/stop_anonymous_comment.js.erb +++ b/app/views/homework_common/stop_anonymous_comment.js.erb @@ -1,12 +1,10 @@ alert('关闭成功'); -<% if @user_activity_id == -1 %> -$("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => "users/user_homework_detail",:locals => {:homework_common => @homework, :is_in_course => @is_in_course})%>"); +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>"); $("#evaluation_end_time_<%=@homework.id %>").html("匿评关闭时间:<%=format_time(Time.now) %>"); -sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>"); +<% if @user_activity_id != @homework.id %> +sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); <% else %> -$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity=>@course_activity}) %>"); -$("#evaluation_end_time_<%=@user_activity_id %>").html("匿评关闭时间:<%=format_time(Time.now) %>"); -sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", 'UserActivity'); +sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>"); <% end %> /* $("#<%#= @homework.id %>_stop_anonymous_comment").replaceWith('');*/ diff --git a/app/views/organizations/_org_activities.html.erb b/app/views/organizations/_org_activities.html.erb index 4a78ec3c0..ca70add10 100644 --- a/app/views/organizations/_org_activities.html.erb +++ b/app/views/organizations/_org_activities.html.erb @@ -63,7 +63,7 @@ <% if act.container_type == 'Course' %> <% case act.org_act_type.to_s %> <% when 'HomeworkCommon' %> - <%= render :partial => 'users/course_homework', :locals => {:activity => HomeworkCommon.find(act.org_act_id),:user_activity_id =>act.id,:course_activity => 0} %> + <%= render :partial => 'users/course_homework', :locals => {:activity => HomeworkCommon.find(act.org_act_id),:user_activity_id =>act.id, :hw_status => 4} %> <% when 'News' %> <%= render :partial => 'users/course_news', :locals => {:activity => News.find(act.org_act_id),:user_activity_id =>act.id} %> <% when 'Message'%> diff --git a/app/views/student_work/_alert_forbidden_anonymous.html.erb b/app/views/student_work/_alert_forbidden_anonymous.html.erb index 55f21048f..d1cdd8d57 100644 --- a/app/views/student_work/_alert_forbidden_anonymous.html.erb +++ b/app/views/student_work/_alert_forbidden_anonymous.html.erb @@ -5,7 +5,7 @@ 禁用匿评后学生将不能对作品进行互评,且匿评不能再开启,是否确定禁用匿评?

    - + 确  定 diff --git a/app/views/student_work/_relate_project.html.erb b/app/views/student_work/_relate_project.html.erb index 9a1fcead5..24eac58ef 100644 --- a/app/views/student_work/_relate_project.html.erb +++ b/app/views/student_work/_relate_project.html.erb @@ -1,7 +1,7 @@
    关联项目 - <%=form_tag url_for(:controller=>'student_work',:action=>'student_work_project',:homework=>@homework.id,:user_activity_id=>@user_activity_id,:is_in_course=>@is_in_course,:course_activity =>@course_activity),:id =>'student_work_relate_project',:class=>'resourcesSearchBox',:remote => true do %> + <%=form_tag url_for(:controller=>'student_work',:action=>'student_work_project',:homework=>@homework.id,:user_activity_id=>@user_activity_id,:hw_status =>@hw_status),:id =>'student_work_relate_project',:class=>'resourcesSearchBox',:remote => true do %>
    diff --git a/app/views/student_work/_set_score_rule.html.erb b/app/views/student_work/_set_score_rule.html.erb index ce6f12eb8..d9ce9f6b2 100644 --- a/app/views/student_work/_set_score_rule.html.erb +++ b/app/views/student_work/_set_score_rule.html.erb @@ -3,7 +3,7 @@ <% render :partial => 'student_work/set_score_rule_detail', :locals => {:homework => homework, :f => f}%> <% end%> <% else %> - <%= form_for('new_form',:url => {:controller => 'student_work',:action => 'set_score_rule',:homework => homework.id,:user_activity_id=>user_activity_id,:is_in_course=>is_in_course,:course_activity=>course_activity},:method => "post",:remote => true) do |f|%> + <%= form_for('new_form',:url => {:controller => 'student_work',:action => 'set_score_rule',:homework => homework.id,:user_activity_id=>user_activity_id,:hw_status=>hw_status},:method => "post",:remote => true) do |f|%> <% render :partial => 'student_work/set_score_rule_detail', :locals => {:homework => homework, :f => f}%> <% end%> <% end %> \ No newline at end of file diff --git a/app/views/student_work/cancel_relate_project.js.erb b/app/views/student_work/cancel_relate_project.js.erb index f5caf2e8f..2dd4a88a4 100644 --- a/app/views/student_work/cancel_relate_project.js.erb +++ b/app/views/student_work/cancel_relate_project.js.erb @@ -1,7 +1,6 @@ -<% if @user_activity_id != -1 %> -$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity => @course_activity}) %>"); -sd_create_editor_from_data(<%= @user_activity_id%>,"","100%"); -<% else%> -$("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework,:is_in_course => @is_in_course}) %>"); -sd_create_editor_from_data(<%= @homework.id%>,"","100%"); +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>"); +<% if @user_activity_id != @homework.id %> +sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); +<% else %> +sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>"); <% end %> \ No newline at end of file diff --git a/app/views/student_work/forbidden_anonymous_comment.js.erb b/app/views/student_work/forbidden_anonymous_comment.js.erb index d869cba58..2dd4a88a4 100644 --- a/app/views/student_work/forbidden_anonymous_comment.js.erb +++ b/app/views/student_work/forbidden_anonymous_comment.js.erb @@ -1,7 +1,6 @@ -<% if @user_activity_id == -1 %> -$("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => "users/user_homework_detail",:locals => {:homework_common => @homework, :is_in_course => @is_in_course})%>"); -sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>"); -<% else %> -$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity=>@course_activity}) %>"); +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>"); +<% if @user_activity_id != @homework.id %> sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); +<% else %> +sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>"); <% end %> \ No newline at end of file diff --git a/app/views/student_work/set_score_rule.js.erb b/app/views/student_work/set_score_rule.js.erb index fa1308873..b50f61e36 100644 --- a/app/views/student_work/set_score_rule.js.erb +++ b/app/views/student_work/set_score_rule.js.erb @@ -1,8 +1,7 @@ clickCanel(); -<% if @user_activity_id != -1 %> - $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity=>@courae_activity}) %>"); +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>"); +<% if @user_activity_id != @homework.id %> sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); <% else %> - $("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework,:is_in_course => @is_in_course}) %>"); sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>"); <% end %> diff --git a/app/views/student_work/student_work_project.js.erb b/app/views/student_work/student_work_project.js.erb index 217a68422..5739f07a7 100644 --- a/app/views/student_work/student_work_project.js.erb +++ b/app/views/student_work/student_work_project.js.erb @@ -1,8 +1,7 @@ hideModal("#popbox02"); -<% if @user_activity_id != -1 %> - $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity => @course_activity}) %>"); - sd_create_editor_from_data(<%= @user_activity_id%>,"","100%"); -<% else%> - $("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework,:is_in_course => @is_in_course}) %>"); - sd_create_editor_from_data(<%= @homework.id%>,"","100%"); +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>"); +<% if @user_activity_id != @homework.id %> +sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); +<% else %> +sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>"); <% 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 cf5f5881b..7e8c1a6aa 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -11,12 +11,20 @@ TO <%=link_to activity.course.syllabus.title, syllabus_path(activity.course.syllabus_id), :class => 'newsBlue ml15', :target => '_blank' %> - <%= link_to activity.course.name.to_s+" | 班级作业", homework_common_index_path(:course => activity.course.id, :host=> Setting.host_course), :class => "newsBlue"%> + <% if hw_status == 3 || hw_status == 5 %> + <%= link_to activity.course.name, course_path(activity.course_id), :class => "newsBlue"%> + <% else %> + <%= link_to activity.course.name.to_s+" | 班级作业", homework_common_index_path(:course => activity.course.id, :host=> Setting.host_course), :class => "newsBlue"%> + <% end %>
    - <%=get_hw_status(activity).html_safe %>
    @@ -31,12 +39,12 @@ <% works = cur_user_works_for_homework activity %> <% if works.nil? && projects.nil? %>
    - <%=link_to "关联项目",new_student_work_project_student_work_index_path(:homework => activity.id,:is_in_course=>-1,:user_activity_id=>user_activity_id,:course_activity=>course_activity),remote: true,:class=> 'c_blue', :title=> '请各组长关联作业项目' %> - <%#= relate_project(activity,is_teacher,-1,user_activity_id,course_activity) %> + <%=link_to "关联项目",new_student_work_project_student_work_index_path(:homework => activity.id,:hw_status=>hw_status,:user_activity_id=>user_activity_id),remote: true,:class=> 'c_blue', :title=> '请各组长关联作业项目' %> + <%#= relate_project(activity,is_teacher,-1,user_activity_id) %>
    <% elsif works.nil? %>
    - <%=link_to "取消关联",cancel_relate_project_student_work_index_path(:homework => activity.id,:is_in_course=>-1,:user_activity_id=>user_activity_id,:course_activity=>course_activity), :confirm => "您确定要取消关联吗?", remote: true,:class => "c_blue", :title=> '取消关联项目' %> + <%=link_to "取消关联",cancel_relate_project_student_work_index_path(:homework => activity.id,:hw_status=>hw_status,:user_activity_id=>user_activity_id), :confirm => "您确定要取消关联吗?", remote: true,:class => "c_blue", :title=> '取消关联项目' %>
    <% end %> <% end %> @@ -76,6 +84,11 @@ <% elsif activity.homework_detail_manual && activity.homework_detail_manual.comment_status >= 2 && activity.anonymous_comment == 0%>
    匿评截止时间:<%= activity.homework_detail_manual.evaluation_end.to_s %> 23:59
    <% end %> + <% if activity.homework_detail_manual.comment_status == 0 && !activity.publish_time.nil? %> +
    + <%= l(:label_publish_time)%>:<%= activity.publish_time%> 00:00 +
    + <% end %>
    <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %> @@ -227,35 +240,35 @@
    • - <%= link_to l(:button_edit),edit_homework_common_path(activity,:is_in_course => -1,:course_activity=>course_activity), :class => "postOptionLink"%> + <%= link_to l(:button_edit),edit_homework_common_path(activity, :hw_status => hw_status), :class => "postOptionLink"%>
    • - <%= link_to(l(:label_bid_respond_delete), homework_common_path(activity,:is_in_course => -1,:course_activity=>course_activity),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %> + <%= link_to(l(:label_bid_respond_delete), homework_common_path(activity, :hw_status => hw_status),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
    • - <%= link_to("评分设置", score_rule_set_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity),:class => "postOptionLink", :remote => true) %> + <%= link_to("评分设置", score_rule_set_homework_common_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status),:class => "postOptionLink", :remote => true) %>
    • <% if activity.anonymous_comment == 0 %>
    • - <%= link_to("匿评设置", start_evaluation_set_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity),:class => "postOptionLink", :remote => true) if activity.homework_detail_manual.comment_status == 1%> + <%= link_to("匿评设置", start_evaluation_set_homework_common_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status),:class => "postOptionLink", :remote => true) if activity.homework_detail_manual.comment_status == 1%>
    • - <%= homework_anonymous_comment activity,-1,user_activity_id,course_activity %> + <%= homework_anonymous_comment activity,hw_status,user_activity_id %>
    • <% end %> <% if activity.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%>
    • - <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink", + <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id),:class => "postOptionLink", :title => "匿评是同学之间的双盲互评过程:每个同学将评阅系统分配给他/她的若干个作品", :remote => true)%>
    • <% end %> <% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %>
    • - <%= link_to("公开作品", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> + <%= link_to("公开作品", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status),:class => "postOptionLink", :remote => true)%>
    • <% elsif activity.is_open == 1 %>
    • - <%= link_to("取消公开", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> + <%= link_to("取消公开", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status),:class => "postOptionLink", :remote => true)%>
    • <% end %>
    @@ -269,12 +282,12 @@ <% count=activity.journals_for_messages.count %>
    - <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity} %> + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :hw_status => hw_status} %> <% comments = activity.journals_for_messages.reorder("created_on desc").limit(3) %> <% if count > 0 %>
    - <%=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, :activity_id => activity.id} %> + <%=render :partial => 'users/news_replies', :locals => {:comments => comments, :type => 'HomeworkCommon', :hw_status => hw_status, :is_teacher => is_teacher, :user_activity_id => user_activity_id, :activity_id => activity.id} %>
    <% end %> @@ -285,7 +298,7 @@
    <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_homework_message', :id => activity.id},:method => "post", :remote => true) do |f|%> <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %> - <%= hidden_field_tag 'course_activity',params[:course_activity],:value =>course_activity %> + <%= hidden_field_tag 'hw_status',params[:hw_status],:value =>hw_status %>
    diff --git a/app/views/users/_news_replies.html.erb b/app/views/users/_news_replies.html.erb index 138efd16e..0b5464946 100644 --- a/app/views/users/_news_replies.html.erb +++ b/app/views/users/_news_replies.html.erb @@ -36,14 +36,14 @@ <%= 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}, + {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => 'HomeworkCommon', :hw_status => hw_status, :user_activity_id => user_activity_id}, :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}, + <%= link_to('删除', {:controller => 'words', :action => 'destroy', :object_id => comment, :user_id => comment.user,:hw_status => hw_status, :user_activity_id => user_activity_id}, :id => "delete_reply_#{activity_id}_#{comment.id}",:remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "fr mr20 undis", :title => l(:button_delete)) %> <% end %> <% elsif type == 'News' %> diff --git a/app/views/users/_reply_banner.html.erb b/app/views/users/_reply_banner.html.erb index 4f2094899..7246ffd03 100644 --- a/app/views/users/_reply_banner.html.erb +++ b/app/views/users/_reply_banner.html.erb @@ -10,12 +10,8 @@
    <%#= format_date(activity.updated_on) %>
    <%if count>3 %>
    - <% if activity.class.to_s == 'HomeworkCommon' && is_in_course == -1 %> - - 展开更多 - - <% elsif activity.class.to_s == 'HomeworkCommon' %> - + <% if activity.class.to_s == 'HomeworkCommon' %> + 展开更多 <% elsif activity.class.to_s == 'Message' %> diff --git a/app/views/users/_reply_to.html.erb b/app/views/users/_reply_to.html.erb index 8752de30b..b6689851b 100644 --- a/app/views/users/_reply_to.html.erb +++ b/app/views/users/_reply_to.html.erb @@ -5,9 +5,8 @@
    <% if @type == 'HomeworkCommon' %> <%= form_for('new_form',:url => {:controller => 'words', :action => 'reply_to_homework', :id => reply.id},:method => "post", :remote => true) do |f| %> - > + > > - >
    diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index 5c6f07bb1..4770bf408 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -51,7 +51,7 @@ <% hidden_courses = Setting.find_by_name("hidden_courses") %> <% unvisiable = hidden_courses && hidden_courses.value == "1"%> <% if !unvisiable %> - <%= render :partial => 'course_homework', :locals => {:activity => act,:user_activity_id =>user_activity.id,:course_activity => 0} %> + <%= render :partial => 'course_homework', :locals => {:activity => act,:user_activity_id =>user_activity.id,:hw_status => 1} %> <% end %> <%# end %> <% when 'News' %> diff --git a/app/views/users/_user_homework_list.html.erb b/app/views/users/_user_homework_list.html.erb index f7669047c..5f37f54ac 100644 --- a/app/views/users/_user_homework_list.html.erb +++ b/app/views/users/_user_homework_list.html.erb @@ -26,15 +26,10 @@ } } - <%= render :partial => 'users/user_homework_detail', :locals => {:homework_common => homework_common,:is_in_course => is_in_course} %> + <%= render :partial => 'users/course_homework', :locals => {:activity => homework_common, :user_activity_id =>homework_common.id, :hw_status => 3} %> <% end%> <% if homework_commons.count == 10%> - <% if is_in_course == 1%> - - <%#= link_to "点击展开更多",homework_common_index_path(:course => course_id,:page => page,:is_in_course => is_in_course),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%> - <% else%> - - <%= link_to "点击展开更多",student_homeworks_user_path(User.current.id,:page => page,:is_in_course => is_in_course),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%> - <% end%> + + <%#= link_to "点击展开更多",homework_common_index_path(:course => course_id,:page => page),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%> <% end%>
    diff --git a/app/views/users/_user_homeworks_old.html.erb b/app/views/users/_user_homeworks_old.html.erb deleted file mode 100644 index 59ec24ad3..000000000 --- a/app/views/users/_user_homeworks_old.html.erb +++ /dev/null @@ -1,47 +0,0 @@ - -
    -
    作业
    -
    -
    - -<% if @is_teacher%> - -
    - <% homework = HomeworkCommon.new %> - <% homework.homework_detail_manual = HomeworkDetailManual.new%> - <%= labelled_form_for homework,:url => user_new_homework_users_path,:method => "post" do |f| %> -
    - <%= render :partial => 'users/user_homework_form', :locals => { :homework => homework,:f => f,:edit_mode => false } %> -
    - <% end%> -
    -<% end%> - -<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homework_commons,:page => 0,:is_in_course => 0} %> diff --git a/app/views/users/all_journals.js.erb b/app/views/users/all_journals.js.erb index 5f60c754c..7aa8581d7 100644 --- a/app/views/users/all_journals.js.erb +++ b/app/views/users/all_journals.js.erb @@ -1,5 +1,5 @@ <% if params[:type] == 'HomeworkCommon' %> -$('#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, :activity_id => params[:id].to_i}) %>'); +$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/news_replies', :locals => {:comments => @journals, :type => @type, :hw_status =>@hw_status, :is_teacher => @is_teacher, :user_activity_id => @user_activity_id, :activity_id => params[:id].to_i}) %>'); <% elsif params[:type] == 'JournalsForMessage' %> $('#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' %> diff --git a/app/views/words/destroy.js.erb b/app/views/words/destroy.js.erb index 00be899cc..5dcdc6401 100644 --- a/app/views/words/destroy.js.erb +++ b/app/views/words/destroy.js.erb @@ -31,12 +31,11 @@ <% elsif @user && @jours_count%> $('#jour_count').html("<%= @jours_count %>"); <% elsif @homework%> - <% if @user_activity_id == -1 %> - $("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => "users/user_homework_detail",:locals => {:homework_common => @homework, :is_in_course => @is_in_course})%>"); - sd_create_editor_from_data(<%= @homework.id%>,"","100%"); + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>"); + <% if @user_activity_id != @homework.id %> + sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); <% else %> - $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity=>@course_activity}) %>"); - sd_create_editor_from_data(<%= @user_activity_id%>,"","100%"); + sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>"); <% end %> <% end %> var destroyedItem = $('#word_li_<%=@journal_destroyed.id%>') diff --git a/app/views/words/leave_homework_message.js.erb b/app/views/words/leave_homework_message.js.erb index acb16be50..61a8aca14 100644 --- a/app/views/words/leave_homework_message.js.erb +++ b/app/views/words/leave_homework_message.js.erb @@ -1,7 +1,6 @@ -<% if @user_activity_id %> - $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework_common,:user_activity_id =>@user_activity_id,:course_activity => @course_activity}) %>"); - sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); -<% elsif @homework_common_id && @is_in_course %> - $("#homework_common_<%= @homework_common_id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework_common,:is_in_course => @is_in_course}) %>"); - sd_create_editor_from_data(<%= @homework_common_id%>,"","100%", "HomeworkCommon"); -<% end %> +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework_common,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>"); +<% if @user_activity_id != @homework_common.id %> +sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); +<% else %> +sd_create_editor_from_data(<%= @homework_common.id%>,"","100%", "<%=@homework_common.class.to_s%>"); +<% end %> \ No newline at end of file diff --git a/app/views/words/reply_to_homework.js.erb b/app/views/words/reply_to_homework.js.erb index 7da72fa54..61a8aca14 100644 --- a/app/views/words/reply_to_homework.js.erb +++ b/app/views/words/reply_to_homework.js.erb @@ -1,7 +1,6 @@ -<% if @user_activity_id != -1 %> -$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework_common,:user_activity_id =>@user_activity_id,:course_activity => @course_activity}) %>"); +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework_common,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>"); +<% if @user_activity_id != @homework_common.id %> sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); <% else %> -$("#homework_common_<%= @homework_common.id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework_common,:is_in_course => @is_in_course}) %>"); -sd_create_editor_from_data(<%= @homework_common.id%>,"","100%", "HomeworkCommon"); +sd_create_editor_from_data(<%= @homework_common.id%>,"","100%", "<%=@homework_common.class.to_s%>"); <% end %> \ No newline at end of file diff --git a/public/javascripts/application.js b/public/javascripts/application.js index aeb9e645a..b74d8b71e 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1459,7 +1459,7 @@ function expand_blog_comment_reply(container, btnid, id, type, div_id, homepage) } } -function expand_reply_homework(container, btnid, id, type, div_id, is_in_course, course_activity, user_activity_id) { +function expand_reply_homework(container, btnid, id, type, div_id, hw_status, user_activity_id) { var target = $(container); var btn = $(btnid); if (btn.data('init') == '0') { @@ -1470,8 +1470,7 @@ function expand_reply_homework(container, btnid, id, type, div_id, is_in_course, type: type, id: id, div_id: div_id, - is_in_course: is_in_course, - course_activity: course_activity, + hw_status: hw_status, user_activity_id: user_activity_id }, function(data) { From 2856cd06d5c3511486b1ff661d021b7c5212e973 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 20 Sep 2016 14:42:36 +0800 Subject: [PATCH 11/42] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E7=82=B9=E5=87=BB=E5=8F=AF=E6=94=BE=E5=A4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/app.html | 1 + public/assets/wechat/blog_detail.html | 2 +- public/assets/wechat/course_discussion.html | 2 +- public/assets/wechat/course_notice.html | 2 +- public/assets/wechat/homework_detail.html | 2 +- public/assets/wechat/issue_detail.html | 2 +- public/assets/wechat/jour_message_detail.html | 2 +- public/assets/wechat/project_discussion.html | 2 +- .../wechat/directives/img_preview.js | 22 +++++++++++++++++++ 9 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 public/javascripts/wechat/directives/img_preview.js diff --git a/public/assets/wechat/app.html b/public/assets/wechat/app.html index 099384593..232f07494 100644 --- a/public/assets/wechat/app.html +++ b/public/assets/wechat/app.html @@ -41,6 +41,7 @@ + diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index 7aa629bb7..91a5fff59 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -25,7 +25,7 @@
    {{blog.title}}
    博客{{blog.created_at}}
    -
    +
    diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 8dc08c788..7a818bb79 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -25,7 +25,7 @@
    {{discussion.subject}}
    {{discussion.syllabus_title}}·{{discussion.course_project_name}} - 班级讨论区{{discussion.created_on}}
    -
    +
    diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index a0c242d72..c13a7b532 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -24,7 +24,7 @@
    {{news.title}}
    {{news.syllabus_title}}·{{news.course_name}} - 课程通知{{news.created_on}}
    -
    +
    diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index 908cff977..161c3be94 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -24,7 +24,7 @@
    {{homework.name}}
    {{homework.syllabus_title}}·{{homework.course_name}} - 普通作业编程作业分组作业{{homework.publish_time}}
    -
    +
    迟交扣分:{{homework.late_penalty}}分 匿评开启时间:{{homework.evaluation_start}}
    缺评扣分:{{homework.absence_penalty}}分/作品 diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index f4eed4bd9..278b545a5 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -26,7 +26,7 @@
    {{issue.subject}}
    {{issue.project_name}} - 项目问题{{issue.created_on}}
    -
    +
    状   态:{{issue.issue_status}} 优先级:{{issue.issue_priority}}
    指派给:{{issue.issue_assigned_to}} diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index a1db224a6..736ad419b 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -24,7 +24,7 @@
    留言{{message.created_on}}
    -
    +
    diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index dcb5a68a6..7fca33657 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -25,7 +25,7 @@
    {{discussion.subject}}
    {{discussion.course_project_name}} - 项目讨论区{{discussion.created_on}}
    -
    +
    diff --git a/public/javascripts/wechat/directives/img_preview.js b/public/javascripts/wechat/directives/img_preview.js new file mode 100644 index 000000000..08f33d381 --- /dev/null +++ b/public/javascripts/wechat/directives/img_preview.js @@ -0,0 +1,22 @@ +/** + * Created by ttang on 2016/9/20. + */ +app.directive('imgPreview',["$timeout",'wx',function(timer,wx){ + return{ + restrict: 'A', + scope: {}, + link: function(scope, element){ + timer(function(){ + var srcList = []; + $.each($(".post-all-content img"),function(i,item){ + if(item.src){ + srcList.push(item.src); + $(item).click(function(e){ + wx.previewImage(this.src,srcList); + }); + } + }); + }) + } + } +}]); \ No newline at end of file From 8b771a183c6dc6fb99ad02e0f0effbd1f60fcea6 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Tue, 20 Sep 2016 14:58:37 +0800 Subject: [PATCH 12/42] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=88=86=E7=8F=AD?= =?UTF-8?q?=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 | 124 +++++++++++++++- app/api/mobile/entities/course.rb | 1 + app/api/mobile/entities/course_group.rb | 19 +++ app/services/courses_service.rb | 4 +- .../_programing_work_show.html.erb | 2 +- public/assets/wechat/class.html | 4 +- public/assets/wechat/class_group.html | 20 +++ public/assets/wechat/edit_class_group.html | 14 ++ public/assets/wechat/edit_class_member.html | 16 ++- public/assets/wechat/edit_userinfo.html | 1 + public/assets/wechat/join_class.html | 2 - public/assets/wechat/join_classgroup.html | 10 +- .../assets/wechat/select_my_coursegroup.html | 17 ++- .../javascripts/wechat/controllers/class.js | 21 ++- .../wechat/controllers/class_group.js | 48 +++++++ .../wechat/controllers/edit_class.js | 2 +- .../wechat/controllers/edit_class_group.js | 136 ++++++++++++++++++ .../wechat/controllers/edit_class_member.js | 91 +++++++++++- .../wechat/controllers/join_classgroup.js | 17 +-- .../controllers/select_my_coursegroup.js | 53 ++++++- public/javascripts/wechat/others/routes.js | 2 + 21 files changed, 566 insertions(+), 38 deletions(-) create mode 100644 app/api/mobile/entities/course_group.rb create mode 100644 public/assets/wechat/class_group.html create mode 100644 public/assets/wechat/edit_class_group.html create mode 100644 public/javascripts/wechat/controllers/class_group.js create mode 100644 public/javascripts/wechat/controllers/edit_class_group.js diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index dd5525fae..c4b445af9 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -541,6 +541,7 @@ module Mobile present :course_id,params[:id] present :user_id,params[:user_id] present :member_info,my_member, with: Mobile::Entities::ProjectMember + present :course_group_id,my_member.course_group_id present :status, 0 else present :status, -1 @@ -779,7 +780,7 @@ module Mobile requires :token, type: String requires :course_group_id, type: Integer end - post 'join_coursegroup' do + post 'user_join_coursegroup' do begin authenticate! member = Member.where(:course_id => params[:id], :user_id => current_user.id).first @@ -795,6 +796,127 @@ module Mobile end end + desc "修改分班" + params do + requires :id, type: Integer + requires :token, type: String + requires :course_group_id, type: Integer + requires :user_id, type: Integer + end + post 'user_edit_coursegroup' do + begin + authenticate! + member = Member.where(:course_id => params[:id], :user_id => params[:user_id]).first + + raise "不是该班级的学生!" unless member + + member.course_group_id = params[:course_group_id].to_i + member.save + present :status,0 + rescue Exception=>e + present :message,e.message + present :status,-1 + end + end + + desc '获取分班列表带上学生' + params do + requires :id, type: Integer + requires :token, type:String + end + get 'course_groups_withstudent/:id' do + begin + authenticate! + course = Course.find(params[:id]) + groups = [] + groups = course.course_groups if course.course_groups + present :data,groups, with: Mobile::Entities::CourseGroup + present :status,0 + rescue + present :status,-1 + end + end + + desc "删除分班" + params do + requires :id, type: Integer + requires :token, type: String + requires :course_group_id, type: Integer + end + post 'delete_coursegroup' do + begin + authenticate! + c = Course.find("#{params[:id]}") + my_member = c.member_principals.where("users.id=#{current_user.id}").first + + roles_ids = [] + my_member.roles.each do |role| + roles_ids << role.id + end + + if my_member && (roles_ids.include?(3) || roles_ids.include?(7) || roles_ids.include?(9) ) + else + raise "您没有该权限!" + end + CourseGroup.delete(params[:course_group_id]) + present :status,0 + rescue Exception=>e + present :message,e.message + present :status,-1 + end + end + + + desc "编辑分班" + params do + requires :id, type: Integer + requires :token, type: String + end + post 'edit_coursegroup' do + begin + authenticate! + c = Course.find("#{params[:id]}") + my_member = c.member_principals.where("users.id=#{current_user.id}").first + + roles_ids = [] + my_member.roles.each do |role| + roles_ids << role.id + end + + if my_member && (roles_ids.include?(3) || roles_ids.include?(7) || roles_ids.include?(9) ) + else + raise "您没有该权限!" + end + + #增加分班和修改分班名 + modify_groups = params[:modify_groups] + modify_groups.each do |g| + group = CourseGroup.find(g.id) + group.name = g.id.to_s + Time.now.to_i.to_s #只能先另取个名了不然原有的两个互换的话修改不了 + group.save + end + + modify_groups.each do |g| + group = CourseGroup.find(g.id) + group.name = g.name + group.save + end + + #增加分班和修改分班名 + add_groups = params[:add_groups] + add_groups.each do |name| + group = CourseGroup.new + group.name = name + group.course_id = params[:id] + group.save + end + present :status,0 + rescue Exception=>e + present :message,e.message + present :status,-1 + end + end + end end end diff --git a/app/api/mobile/entities/course.rb b/app/api/mobile/entities/course.rb index 30a5a6cc9..1b696e40c 100644 --- a/app/api/mobile/entities/course.rb +++ b/app/api/mobile/entities/course.rb @@ -54,6 +54,7 @@ module Mobile course_expose :updated_at course_expose :course_student_num course_expose :member_count + course_expose :groupnum expose :can_setting, if: lambda { |instance, options| options[:user] } do |instance, options| current_user = options[:user] can_setting = false diff --git a/app/api/mobile/entities/course_group.rb b/app/api/mobile/entities/course_group.rb new file mode 100644 index 000000000..f5d05d44c --- /dev/null +++ b/app/api/mobile/entities/course_group.rb @@ -0,0 +1,19 @@ +module Mobile + module Entities + class CourseGroup < Grape::Entity + include Redmine::I18n + include ApplicationHelper + include ApiHelper + def self.course_group_expose(f) + expose f do |u,opt| + if u.is_a?(Hash) && u.key?(f) + u[f] + end + end + end + expose :id + expose :name + expose :users, using: Mobile::Entities::User + end + end +end diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 2c0506d1e..5d2957d4c 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -332,7 +332,9 @@ class CoursesService # unless (course.is_public == 1 || current_user.member_of_course?(course) || current_user.admin?) # raise '403' # end - {:course => course,:syllabus_title => course.syllabus.nil? ? "":course.syllabus.title ,:work_unit => work_unit, :img_url => url_to_avatar(course),:current_user_is_member => current_user.nil? ? false : current_user.member_of_course?(course),:current_user_is_teacher => current_user.nil? ? false : is_course_teacher(current_user,course),:course_student_num => course ? course.student.count.to_s : 0} + groupnum = 0 + groupnum = course.course_groups.length if course.course_groups + {:course => course,:syllabus_title => course.syllabus.nil? ? "":course.syllabus.title ,:work_unit => work_unit, :img_url => url_to_avatar(course),:current_user_is_member => current_user.nil? ? false : current_user.member_of_course?(course),:current_user_is_teacher => current_user.nil? ? false : is_course_teacher(current_user,course),:course_student_num => course ? course.student.count.to_s : 0,:groupnum => groupnum} end #创建课程 diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb index c4df9e715..bf4cf9e76 100644 --- a/app/views/student_work/_programing_work_show.html.erb +++ b/app/views/student_work/_programing_work_show.html.erb @@ -43,7 +43,7 @@ 第<%= work.student_work_tests.count - index%>次测试

    - <%= test.created_at.to_s(:db) %> + <%= format_time(test.created_at).to_s %>
    diff --git a/public/assets/wechat/class.html b/public/assets/wechat/class.html index 30c9120c3..f8947b029 100644 --- a/public/assets/wechat/class.html +++ b/public/assets/wechat/class.html @@ -256,13 +256,15 @@
    {{student.name}} - +
    +
    diff --git a/public/assets/wechat/class_group.html b/public/assets/wechat/class_group.html new file mode 100644 index 000000000..04cdf8025 --- /dev/null +++ b/public/assets/wechat/class_group.html @@ -0,0 +1,20 @@ +
    +
    +
    + +
    +
    {{group.name+"("+group.users.length+")"}}
    +
    + {{user.realname == "" ? user.name : user.realname}} +
    +
    +
    + +
    + 编辑 +
    + +
    {{tip_1}}
    + + +
    \ No newline at end of file diff --git a/public/assets/wechat/edit_class_group.html b/public/assets/wechat/edit_class_group.html new file mode 100644 index 000000000..3dda96d53 --- /dev/null +++ b/public/assets/wechat/edit_class_group.html @@ -0,0 +1,14 @@ +
    +
    + +
    分班管理
    +
    {{course.name}}
    + +
    分班名称删除
    + + 完成 + + + + +
    \ No newline at end of file diff --git a/public/assets/wechat/edit_class_member.html b/public/assets/wechat/edit_class_member.html index d06eba89b..1eb53c7bf 100644 --- a/public/assets/wechat/edit_class_member.html +++ b/public/assets/wechat/edit_class_member.html @@ -4,15 +4,25 @@
    成员管理
    {{current_edit_member.user.realname == "" ? current_edit_member.user.name : current_edit_member.user.realname}}
    角色变更
    -
      +
      -
      删除成员
      -
        +
        删除成员
        +
        +
        编辑分班
        +
          +
        • + +
          +
        • + +
          +
        +
        取消 确定 diff --git a/public/assets/wechat/edit_userinfo.html b/public/assets/wechat/edit_userinfo.html index f4178fee4..48d207d4c 100644 --- a/public/assets/wechat/edit_userinfo.html +++ b/public/assets/wechat/edit_userinfo.html @@ -30,6 +30,7 @@
        电子邮箱地址不能为空 + 电子邮箱地址不合法
        diff --git a/public/assets/wechat/join_class.html b/public/assets/wechat/join_class.html index 4c81ff2e4..ad43db3a7 100644 --- a/public/assets/wechat/join_class.html +++ b/public/assets/wechat/join_class.html @@ -25,7 +25,5 @@
    -
    {{tip_1}}
    -
    diff --git a/public/assets/wechat/join_classgroup.html b/public/assets/wechat/join_classgroup.html index 9a7705252..9a7e9fa2d 100644 --- a/public/assets/wechat/join_classgroup.html +++ b/public/assets/wechat/join_classgroup.html @@ -1,11 +1,11 @@
    -
    +
    欢迎加入班级
    {{current_course.name}}
    选择分班{{selectid}}
    +
    {{tip_1}}
    +
    \ No newline at end of file diff --git a/public/assets/wechat/select_my_coursegroup.html b/public/assets/wechat/select_my_coursegroup.html index c16b276e4..cc7a65753 100644 --- a/public/assets/wechat/select_my_coursegroup.html +++ b/public/assets/wechat/select_my_coursegroup.html @@ -2,24 +2,27 @@
    我的信息
    -
    {{current_edit_member.user.show_name}}
    +
    {{current_edit_member.user.realname == "" ? current_edit_member.user.name : current_edit_member.user.realname}}
    角色
    学生
    选择分班
      -
    • -
    • -
    • +
    • + +
      +
    • + +
    -
    {{tip_1}}
    -
    {{tip_2}}
    +
    {{tip_1}}
    +
    {{tip_2}}
    diff --git a/public/javascripts/wechat/controllers/class.js b/public/javascripts/wechat/controllers/class.js index ca4ad6d76..70c5d839d 100644 --- a/public/javascripts/wechat/controllers/class.js +++ b/public/javascripts/wechat/controllers/class.js @@ -258,7 +258,7 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location rms.save('current_edit_member', user); rms.save("course",vm.course); rms.save("tab_num",vm.currentTab); - $location.path("/select_my_coursegroup").search({id: courseid}); + $location.path("/select_my_coursegroup").search({id: courseid,user_id: user.id}); }; vm.review = function(user){ @@ -367,5 +367,24 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location }; + vm.goEditGroup = function(){ + if(!vm.isTeacher){ + return; + } + + rms.save('course_activities_page',vm.course_activities_page); + rms.save("course_activities",vm.course_activities); + rms.save('course_has_more', vm.course_has_more); + rms.save("tab_num",vm.currentTab); + rms.save("course",vm.course); + rms.save('current_course', vm.course); + + if(vm.course.groupnum == 0){ + $location.path("/edit_class_group").search({id: courseid}); + } + else{ + $location.path("/class_group").search({id: courseid}); + } + } }]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/class_group.js b/public/javascripts/wechat/controllers/class_group.js new file mode 100644 index 000000000..77de92332 --- /dev/null +++ b/public/javascripts/wechat/controllers/class_group.js @@ -0,0 +1,48 @@ +app.controller('ClassGroupController', ['$scope', 'config','$http', 'auth','$location','$routeParams','alertService','rms','common','$timeout', function($scope, config, $http, auth, $location, $routeParams,alertService,rms,common,$timeout){ +// common.checkLogin(); + + $scope.replaceUrl = function(url){ + return url; + }; + + var vm = $scope; + var courseid = $routeParams.id; + vm.alertService = alertService.create(); + + if(!vm.course){ + $http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then( + function(response) { + console.log(response.data); + if (response.data.status == 0){ + vm.course = response.data.data; + console.log("courses"); + console.log(response.data.data); + } + else{ + vm.alertService.showMessage('提示', response.data.message); + } + if(!vm.course){ + vm.tip_1 = "该班级不存在或已被删除"; + } + } + ); + } + + + $http.get(config.apiUrl + 'courses/course_groups_withstudent/'+courseid+'?token='+auth.token()).then( + function(response) { + console.log("groups="); + console.log(response); + if(response.data.status == 0) { + vm.groups = response.data.data; + } + else{ + vm.groups = []; + } + }); + + vm.goEditGroup = function(){ + $location.path("/edit_class_group").search({id: courseid}); + } + +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/edit_class.js b/public/javascripts/wechat/controllers/edit_class.js index d61c25353..6cb50da1a 100644 --- a/public/javascripts/wechat/controllers/edit_class.js +++ b/public/javascripts/wechat/controllers/edit_class.js @@ -63,7 +63,7 @@ app.controller('EditClassController', ['$scope', '$http', 'auth', 'config', 'ale vm.syllabus.courses.splice(index, 1); } - } + }; vm.newClass = function (frm, syllabus) { frm.$setSubmitted(); diff --git a/public/javascripts/wechat/controllers/edit_class_group.js b/public/javascripts/wechat/controllers/edit_class_group.js new file mode 100644 index 000000000..e80b35869 --- /dev/null +++ b/public/javascripts/wechat/controllers/edit_class_group.js @@ -0,0 +1,136 @@ + + +app.controller('EditClassGroupController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms','common', function($scope, $http, auth, config, alertService, $location,$routeParams, rms,common){ + var vm = $scope; + var courseid = $routeParams.id; + vm.alertService = alertService.create(); + vm.alertService_2 = alertService.create(); + + if(!vm.course){ + $http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then( + function(response) { + console.log(response.data); + if (response.data.status == 0){ + vm.course = response.data.data; + console.log("courses"); + console.log(response.data.data); + } + else{ + vm.alertService.showMessage('提示', response.data.message); + } + if(!vm.course){ + vm.tip_1 = "该班级不存在或已被删除"; + } + } + ); + } + + $http.get(config.apiUrl + 'courses/course_groups/'+courseid+'?token='+auth.token()).then( + function(response) { + console.log("groups="); + console.log(response); + if(response.data.status == 0) { + vm.groups = response.data.data; + for(var i in vm.groups){ + vm.groups[i].tmpname = vm.groups[i].course_group.name; + } + } + else{ + vm.groups = []; + } + }); + + vm.addGroup = function(){ + vm.groups.push({tmpname:""}); + }; + + vm.deleteGroup = function(index){ + var group = vm.groups[index]; + if(group.course_group){ + vm.alertService_2.showMessage('提示', '您确定要删除该分班吗?', function() { + $http.post(config.apiUrl+'courses/delete_coursegroup', { + token: auth.token(), + id: courseid, + course_group_id:group.course_group.id + }).then(function(response){ + console.log(response); + if(response.data.status == 0){ + vm.alertService.showMessage('提示', "删除成功!",function(){ + vm.groups.splice(index, 1); + }); + } else { + vm.alertService.showMessage('提示', response.data.message); + } + }); + }); + + } else { + vm.groups.splice(index, 1); + } + + }; + + vm.newGroup = function (frm, groups) { + frm.$setSubmitted(); + console.log(groups); + + if(!frm.$valid){ + console.log(frm.$error); + return; + } + + if(vm.groups.length == 0){ + $location.path("/class").search({id: courseid,tag:1}); + return; + } + //不能有相同名称的分班 + for(var i=0;i< vm.groups.length-1;i++) { + for (var j=i+1;j Date: Tue, 20 Sep 2016 15:00:22 +0800 Subject: [PATCH 13/42] . --- Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 1305320cf..cbeade2a3 100644 --- a/Gemfile +++ b/Gemfile @@ -50,10 +50,10 @@ gem 'elasticsearch-model' gem 'elasticsearch-rails' #rails 3.2.22.2 bug - # gem "test-unit", "~>3.0" + gem "test-unit", "~>3.0" ### profile - # gem 'oneapm_rpm' + gem 'oneapm_rpm' group :development do gem 'grape-swagger' From 4e292425793d544a3346522b1931b92ba0631e7f Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Tue, 20 Sep 2016 15:11:00 +0800 Subject: [PATCH 14/42] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/wechats_helper.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/wechats_helper.rb b/app/helpers/wechats_helper.rb index 5c6b3da8c..34c4dd9a1 100644 --- a/app/helpers/wechats_helper.rb +++ b/app/helpers/wechats_helper.rb @@ -3,9 +3,9 @@ module WechatsHelper def include_wechat_jsfile - if Rails.env.production? - javascript_include_tag '/javascripts/wechat/build/app.min.js' - else + # 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 = [] @@ -15,6 +15,6 @@ module WechatsHelper end end javascript_include_tag *paths - end + # end end end From 930acd382cce98f74ee882f2b24f12d41c37080b Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Tue, 20 Sep 2016 15:14:48 +0800 Subject: [PATCH 15/42] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/wechats_helper.rb | 2 +- public/javascripts/wechat/directives/img_preview.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/wechats_helper.rb b/app/helpers/wechats_helper.rb index 34c4dd9a1..e76ea08d6 100644 --- a/app/helpers/wechats_helper.rb +++ b/app/helpers/wechats_helper.rb @@ -4,7 +4,7 @@ module WechatsHelper def include_wechat_jsfile # if Rails.env.production? - # javascript_include_tag '/javascripts/wechat/build/app.min.js' + 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 diff --git a/public/javascripts/wechat/directives/img_preview.js b/public/javascripts/wechat/directives/img_preview.js index 08f33d381..ce973c69b 100644 --- a/public/javascripts/wechat/directives/img_preview.js +++ b/public/javascripts/wechat/directives/img_preview.js @@ -12,7 +12,7 @@ app.directive('imgPreview',["$timeout",'wx',function(timer,wx){ if(item.src){ srcList.push(item.src); $(item).click(function(e){ - wx.previewImage(this.src,srcList); + wx.previewImage({current:this.src,urls:srcList}); }); } }); From bda68495c979c5ca723f8d009ac509c9775f59f5 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Tue, 20 Sep 2016 15:19:06 +0800 Subject: [PATCH 16/42] . --- app/helpers/wechats_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/wechats_helper.rb b/app/helpers/wechats_helper.rb index e76ea08d6..5c6b3da8c 100644 --- a/app/helpers/wechats_helper.rb +++ b/app/helpers/wechats_helper.rb @@ -3,9 +3,9 @@ module WechatsHelper def include_wechat_jsfile - # if Rails.env.production? + if Rails.env.production? javascript_include_tag '/javascripts/wechat/build/app.min.js' - # else + else wechat_path = File.join(Rails.root, "public", "javascripts", "wechat") srcs = Rails.application.config.wechat_srcs paths = [] @@ -15,6 +15,6 @@ module WechatsHelper end end javascript_include_tag *paths - # end + end end end From d1c284c953caa69027dabe504ab9db5dd0ce2b80 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 21 Sep 2016 10:34:38 +0800 Subject: [PATCH 17/42] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 6 + app/controllers/student_work_controller.rb | 3 + app/controllers/words_controller.rb | 4 +- app/helpers/application_helper.rb | 24 +- .../exercise/student_exercise_list.html.erb | 2 +- .../homework_common/open_student_works.js.erb | 4 + .../set_evaluation_attr.js.erb | 4 + .../start_anonymous_comment.js.erb | 4 + .../stop_anonymous_comment.js.erb | 4 + .../_org_course_homework.html.erb | 6 +- .../_homework_post_brief.html.erb | 102 +++++++ .../student_work/_student_work_list.html.erb | 5 +- .../student_work/cancel_relate_project.js.erb | 4 + app/views/student_work/index.html.erb | 144 ++++------ app/views/student_work/set_score_rule.js.erb | 4 + .../student_work/student_work_project.js.erb | 4 + app/views/users/_course_homework.html.erb | 258 +----------------- app/views/users/_homework_base_info.html.erb | 178 ++++++++++++ app/views/users/_homework_opr.html.erb | 43 +++ app/views/users/_homework_post_reply.html.erb | 34 +++ .../users/_user_homework_detail.html.erb | 2 +- app/views/words/destroy.js.erb | 2 +- app/views/words/leave_homework_message.js.erb | 2 +- app/views/words/reply_to_homework.js.erb | 2 +- public/stylesheets/courses.css | 2 +- public/stylesheets/css/courses.css | 2 +- 26 files changed, 469 insertions(+), 380 deletions(-) create mode 100644 app/views/student_work/_homework_post_brief.html.erb create mode 100644 app/views/users/_homework_base_info.html.erb create mode 100644 app/views/users/_homework_opr.html.erb create mode 100644 app/views/users/_homework_post_reply.html.erb diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index b5d55df28..4511e5a1f 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -168,6 +168,8 @@ class HomeworkCommonController < ApplicationController redirect_to user_path(User.current.id) elsif @hw_status == 2 redirect_to course_path(@course.id) + elsif @hw_status == 5 + redirect_to student_work_index_url(:homework => @homework.id) else redirect_to homework_common_index_path(:course => @course.id) end @@ -244,6 +246,7 @@ class HomeworkCommonController < ApplicationController end @user_activity_id = params[:user_activity_id].to_i @hw_status = params[:hw_status].to_i + @is_teacher = User.current.admin? || User.current.allowed_to?(:as_teacher, @course) end #关闭匿评 @@ -262,6 +265,7 @@ class HomeworkCommonController < ApplicationController Mailer.send_mail_anonymous_comment_close(@homework).deliver @user_activity_id = params[:user_activity_id].to_i @hw_status = params[:hw_status].to_i + @is_teacher = User.current.admin? || User.current.allowed_to?(:as_teacher, @course) respond_to do |format| format.js end @@ -315,6 +319,7 @@ class HomeworkCommonController < ApplicationController end @user_activity_id = params[:user_activity_id] @hw_status = params[:hw_status].to_i + @is_teacher = User.current.admin? || User.current.allowed_to?(:as_teacher,@course) end def alert_open_student_works @@ -372,6 +377,7 @@ class HomeworkCommonController < ApplicationController @homework_detail_manual.save @user_activity_id = params[:user_activity_id].to_i @hw_status = params[:hw_status].to_i + @is_teacher = User.current.admin? || User.current.allowed_to?(:as_teacher,@course) end end diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index b259737a1..a0d981b22 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -521,6 +521,7 @@ class StudentWorkController < ApplicationController # 消息传过来的ID @message_student_work_id = params[:student_work_id] @left_nav_type = 3 + @tab = params[:tab].to_i respond_to do |format| format.js format.html @@ -1076,6 +1077,7 @@ class StudentWorkController < ApplicationController if @project.save @user_activity_id = params[:user_activity_id].to_i @hw_status = params[:hw_status].to_i + @is_teacher = User.current.allowed_to?(:as_teacher,@homework.course) || User.current.admin? respond_to do |format| format.js end @@ -1126,6 +1128,7 @@ class StudentWorkController < ApplicationController if relate_pro.destroy @user_activity_id = params[:user_activity_id].to_i @hw_status = params[:hw_status].to_i + @is_teacher = User.current.allowed_to?(:as_teacher,@homework.course) || User.current.admin? respond_to do |format| format.js end diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index f1bfc7a31..9c8954ed9 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -111,6 +111,7 @@ class WordsController < ApplicationController @user_activity_id = -1 end @hw_status = params[:hw_status].to_i + @is_teacher = User.current.allowed_to?(:as_teacher, @homework.course) || User.current.admin? elsif @journal_destroyed.jour_type == 'Syllabus' @syllabus = Syllabus.find @journal_destroyed.jour_id @count = @syllabus.journals_for_messages.count @@ -309,7 +310,7 @@ class WordsController < ApplicationController format.js{ @user_activity_id = params[:user_activity_id].to_i @hw_status = params[:hw_status].to_i - @homework_common_id = params[:homework_common_id] + @is_teacher = User.current.allowed_to?(:as_teacher, @homework_common.course) || User.current.admin? } end else @@ -343,6 +344,7 @@ class WordsController < ApplicationController format.js{ @user_activity_id = params[:user_activity_id].to_i @hw_status = params[:hw_status].to_i + @is_teacher = User.current.allowed_to?(:as_teacher, @homework_common.course) || User.current.admin? } end else diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d9a694eaa..8b5b594bd 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2745,7 +2745,7 @@ module ApplicationHelper count = homework.student_works.has_committed.count if User.current.member_of_course?(homework.course) if is_teacher #老师显示作品数量 - link_to "作品(#{count})", student_work_index_url_in_org(homework.id), :class => "c_blue" + link_to "作品(#{count})", student_work_index_url_in_org(homework.id, 2), :class => "c_blue" else #学生显示提交作品、修改作品等按钮 work = cur_user_works_for_homework homework project = cur_user_projects_for_homework homework @@ -2763,20 +2763,20 @@ module ApplicationHelper end else if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 && StudentWorksEvaluationDistribution.where("student_work_id = #{work.id}").count > 0 #匿评作业,且作业状态不是在开启匿评之前 - link_to "作品匿评", student_work_index_url_in_org(homework.id), :class => 'c_blue', :title => "开启匿评后不可修改作品" + link_to "作品匿评", student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "开启匿评后不可修改作品" elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3 - link_to "查看作品(#{count})",student_work_index_url_in_org(homework.id), :class => 'c_blue', :title => "匿评已结束" + link_to "查看作品(#{count})",student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "匿评已结束" elsif homework.homework_type == 2 && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")#编程作业不能修改作品 link_to "修改作品(#{count})", new_student_work_url_without_domain(homework.id),:class => 'c_blue' elsif Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") && work.user_id == User.current.id link_to "修改作品(#{count})", edit_student_work_url_without_domain(work.id),:class => 'c_blue' else - link_to "查看作品(#{count})", student_work_index_url_in_org(homework.id), :class => 'c_blue', :title => "作业截止后不可修改作品" + link_to "查看作品(#{count})", student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "作业截止后不可修改作品" end end end else - link_to "作品(#{count})",student_work_index_url_in_org(homework.id),:class => "c_blue" + link_to "作品(#{count})",student_work_index_url_in_org(homework.id, 2),:class => "c_blue" end end @@ -2799,15 +2799,15 @@ module ApplicationHelper end else if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 #匿评作业,且作业状态不是在开启匿评之前 - link_to "作品匿评", student_work_index_url_in_org(homework.id), :class => 'hw_btn_green2 fr mt5', :title => "开启匿评后不可修改作品", :target => '_blank' + link_to "作品匿评", student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green2 fr mt5', :title => "开启匿评后不可修改作品", :target => '_blank' elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3 - link_to "查看作品",student_work_index_url_in_org(homework.id), :class => 'hw_btn_green2 fr mt5', :title => "匿评已结束", :target => '_blank' + link_to "查看作品",student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green2 fr mt5', :title => "匿评已结束", :target => '_blank' elsif homework.homework_type == 2 && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")#编程作业不能修改作品 link_to "修改作品", new_student_work_url_without_domain(homework.id),:class => 'hw_btn_green2 fr mt5', :target => '_blank' elsif Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") && work.user_id == User.current.id link_to "修改作品", edit_student_work_url_without_domain(work.id),:class => 'hw_btn_green2 fr mt5', :target => '_blank' else - link_to "查看作品", student_work_index_url_in_org(homework.id), :class => 'hw_btn_green2 fr mt5', :title => "作业截止后不可修改作品", :target => '_blank' + link_to "查看作品", student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green2 fr mt5', :title => "作业截止后不可修改作品", :target => '_blank' end end end @@ -3136,13 +3136,13 @@ def homework_common_index_url_in_org(course_id) Setting.protocol + "://" + Setting.host_name + "/homework_common?course=" + course_id.to_s end -def student_work_index_url_in_org(homework_id, is_focus = '', show_work_id = '') +def student_work_index_url_in_org(homework_id, tab = 1, is_focus = '', show_work_id = '') if is_focus != '' - Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s + "&is_focus=" + is_focus.to_s + Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s + "&tab=" + tab.to_s + "&is_focus=" + is_focus.to_s elsif show_work_id != '' - Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s + "&show_work_id=" + show_work_id.to_s + Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s + "&tab=" + tab.to_s + "&show_work_id=" + show_work_id.to_s else - Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s + Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s + "&tab=" + tab.to_s end end diff --git a/app/views/exercise/student_exercise_list.html.erb b/app/views/exercise/student_exercise_list.html.erb index 1cbe058a1..443a9f5f1 100644 --- a/app/views/exercise/student_exercise_list.html.erb +++ b/app/views/exercise/student_exercise_list.html.erb @@ -84,7 +84,7 @@
    -
    +
    <% if @exercise.exercise_status == 1 %> diff --git a/app/views/homework_common/open_student_works.js.erb b/app/views/homework_common/open_student_works.js.erb index 2dd4a88a4..c65034689 100644 --- a/app/views/homework_common/open_student_works.js.erb +++ b/app/views/homework_common/open_student_works.js.erb @@ -1,4 +1,8 @@ +<% if @hw_status == 5 %> +$("#homework_post_brief").html("<%= escape_javascript(render :partial => 'student_work/homework_post_brief', :locals => {:homework => @homework, :is_teacher => @is_teacher}) %>"); +<% else %> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>"); +<% end %> <% if @user_activity_id != @homework.id %> sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); <% else %> diff --git a/app/views/homework_common/set_evaluation_attr.js.erb b/app/views/homework_common/set_evaluation_attr.js.erb index 42bc842bc..e084967c7 100644 --- a/app/views/homework_common/set_evaluation_attr.js.erb +++ b/app/views/homework_common/set_evaluation_attr.js.erb @@ -1,5 +1,9 @@ clickCanel(); +<% if @hw_status == 5 %> +$("#homework_post_brief").html("<%= escape_javascript(render :partial => 'student_work/homework_post_brief', :locals => {:homework => @homework, :is_teacher => @is_teacher}) %>"); +<% else %> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>"); +<% end %> <% if @user_activity_id != @homework.id %> sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); <% else %> diff --git a/app/views/homework_common/start_anonymous_comment.js.erb b/app/views/homework_common/start_anonymous_comment.js.erb index 94db99dd8..809ba5b05 100644 --- a/app/views/homework_common/start_anonymous_comment.js.erb +++ b/app/views/homework_common/start_anonymous_comment.js.erb @@ -1,6 +1,10 @@ <% if @statue == 1%> alert('启动成功'); + <% if @hw_status == 5 %> + $("#homework_post_brief").html("<%= escape_javascript(render :partial => 'student_work/homework_post_brief', :locals => {:homework => @homework, :is_teacher => @is_teacher}) %>"); + <% else %> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>"); + <% end %> $("#evaluation_start_time_<%=@user_activity_id %>").html("匿评开启时间:<%=format_time(Time.now) %>"); <% if @user_activity_id != @homework.id %> sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); diff --git a/app/views/homework_common/stop_anonymous_comment.js.erb b/app/views/homework_common/stop_anonymous_comment.js.erb index c540c323d..027f477a7 100644 --- a/app/views/homework_common/stop_anonymous_comment.js.erb +++ b/app/views/homework_common/stop_anonymous_comment.js.erb @@ -1,5 +1,9 @@ alert('关闭成功'); +<% if @hw_status == 5 %> +$("#homework_post_brief").html("<%= escape_javascript(render :partial => 'student_work/homework_post_brief', :locals => {:homework => @homework, :is_teacher => @is_teacher}) %>"); +<% else %> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>"); +<% end %> $("#evaluation_end_time_<%=@homework.id %>").html("匿评关闭时间:<%=format_time(Time.now) %>"); <% if @user_activity_id != @homework.id %> sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb index 510a743b1..ebbd5fa32 100644 --- a/app/views/organizations/_org_course_homework.html.erb +++ b/app/views/organizations/_org_course_homework.html.erb @@ -73,7 +73,7 @@ <% work = cur_user_works_for_homework activity %> <% if activity.end_time < Date.today && !is_teacher && !work.nil? && work.user == User.current %>
    - <%=link_to "追加附件", student_work_index_url_in_org(activity.id, 1), :class => 'c_blue', :title => "可追加作品修订附件" %> + <%=link_to "追加附件", student_work_index_url_in_org(activity.id, 2, 1), :class => 'c_blue', :title => "可追加作品修订附件" %>
    <% end %> <% if activity.homework_type == 2 && is_teacher%> @@ -161,9 +161,9 @@
    <% if User.current.member_of_course?(activity.course) || User.current.admin? || activity.is_open == 1 %> - <%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_url_in_org(activity.id, '', sw.id), :alt => "学生头像" %> + <%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_url_in_org(activity.id, 2, '', sw.id), :alt => "学生头像" %> <% else %> <%= image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40", :title => '该作业的作品暂未公开') %> diff --git a/app/views/student_work/_homework_post_brief.html.erb b/app/views/student_work/_homework_post_brief.html.erb new file mode 100644 index 000000000..b575c8788 --- /dev/null +++ b/app/views/student_work/_homework_post_brief.html.erb @@ -0,0 +1,102 @@ +
    +<%=link_to image_tag(url_to_avatar(homework.user),width:"50px", height: "50px"), user_activities_path(homework.user_id)%> +
    +
    +
    + <%= link_to homework.user.show_name, user_activities_path(homework.user_id), :class => "newsBlue mr15"%> + TO + <%=link_to homework.course.syllabus.title, syllabus_path(homework.course.syllabus_id), :class => 'newsBlue ml15', :target => '_blank' %> + + <%= link_to homework.course.name, course_path(homework.course_id), :class => "newsBlue"%> +
    + +<%=get_hw_status(homework).html_safe %> +
    +<% if homework.homework_type == 3 && homework.homework_detail_group.base_on_project == 1%> + 系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"linkBlue",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合! +<% elsif homework.homework_type == 3 && homework.homework_detail_group.base_on_project == 0%> + 系统提示:该作业要求各组长提交作品,提交作品时请添加组成员。谢谢配合! +<% end %> + +<% is_pro = homework.homework_type == 2 && is_teacher %> +<% is_base_group = homework.homework_type == 3 && homework.homework_detail_group.base_on_project == 1 && !is_teacher %> +
    + <%= render :partial => 'users/homework_opr', :locals => {:activity => homework, :is_teacher => is_teacher, :hw_status => 5, :user_activity_id => homework.id} %> + <% if is_pro || is_base_group %> +
    + <% end %> + <% if !homework.publish_time.nil? %> +
    + <%= l(:label_publish_time)%>:<%= homework.publish_time%> 00:00 +
    + <% end %> + <% if homework.homework_detail_manual && homework.homework_detail_manual.comment_status < 2 %> +
    提交截止时间:<%= homework.end_time.to_s %> 23:59
    + <% elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status >= 2 && homework.anonymous_comment == 0%> +
    匿评截止时间:<%= homework.homework_detail_manual.evaluation_end.to_s %> 23:59
    + <% end %> +
    +
    +
    +
    +
    +
    + <%= homework.description %> +
    +
    + <% if is_pro %> +
    测试集:<%=homework.homework_tests.count %>组 + + + + + + + <% homework.homework_tests.each_with_index do |test, i| %> + + + + + + <% end %> +
     测试集输入测试集输出
    <%=i+1 %><%=test.input %><%=test.output %>
    +
    + <% end %> +
    +
    + <% if homework.homework_detail_manual%> + <% if homework.homework_detail_manual.comment_status == 1%> + <% end_time = homework.end_time.to_time.to_i + 24*60*60 - 1 %> + <% if end_time >= Time.now.to_i %> +
    提交剩余时间: <%= (end_time - Time.now.to_i) / (24*60*60) %> 天 + <%= ((end_time - Time.now.to_i) % (24*60*60)) / (60*60)%> 小时 + <%= (((end_time - Time.now.to_i) % (24*60*60)) % (60*60)) / 60%>
    + <% else %> +
    提交已截止
    + <% end %> + <% elsif homework.homework_detail_manual.comment_status == 2%> + <% end_time = homework.homework_detail_manual.evaluation_end.to_time.to_i + 24*60*60 - 1 %> + <% if end_time >= Time.now.to_i %> +
    匿评剩余时间: <%= (end_time - Time.now.to_i) / (24*60*60)%> 天 + <%= ((end_time - Time.now.to_i) % (24*60*60)) / (60*60)%> 小时 + <%= (((end_time - Time.now.to_i) % (24*60*60)) % (60*60)) / 60%>
    + <% else %> +
    匿评已截止
    + <% end %> + <% end%> + <% end%> +
    +
    +
    +
    +
    +
    + <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => homework} %> +
    + +<%= render :partial => "users/homework_base_info", :locals =>{:activity => homework, :user_activity_id =>homework.id, :is_teacher => is_teacher, :hw_status => 5} %> +
    +
    \ No newline at end of file diff --git a/app/views/student_work/_student_work_list.html.erb b/app/views/student_work/_student_work_list.html.erb index 73f37602b..6bcb2bb5e 100644 --- a/app/views/student_work/_student_work_list.html.erb +++ b/app/views/student_work/_student_work_list.html.erb @@ -93,10 +93,7 @@ <% elsif @homework.homework_type == 1 %> $("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc"),:is_focus => @is_focus}) %>"); <% elsif @homework.homework_type == 3 %> - <% pro = @homework.student_work_projects.where(:user_id => User.current.id).first %> - <% if pro && pro.student_work_id == work.id %> - $("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc"),:is_focus => @is_focus}) %>"); - <% end %> + $("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc"),:is_focus => @is_focus}) %>"); <% end %> $('#score_<%= work.id%>').peSlider({range: 'min'}); <% end %> diff --git a/app/views/student_work/cancel_relate_project.js.erb b/app/views/student_work/cancel_relate_project.js.erb index 2dd4a88a4..c65034689 100644 --- a/app/views/student_work/cancel_relate_project.js.erb +++ b/app/views/student_work/cancel_relate_project.js.erb @@ -1,4 +1,8 @@ +<% if @hw_status == 5 %> +$("#homework_post_brief").html("<%= escape_javascript(render :partial => 'student_work/homework_post_brief', :locals => {:homework => @homework, :is_teacher => @is_teacher}) %>"); +<% else %> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>"); +<% end %> <% if @user_activity_id != @homework.id %> sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); <% else %> diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index 3ec6232db..8ab08b7e0 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -2,6 +2,7 @@ <%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %> <%= javascript_include_tag "resizeable_table" %> <%= stylesheet_link_tag "/assets/codemirror/codemirror" %> +<%= import_ke(enable_at: true, prettify: false, init_activity: true) %> <% end %> -
    - <% com_time = project.project_score.commit_time %> - <% forge_time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %> - <% if project.is_public || User.current.member_of?(project) || User.current.admin? %> - <%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius relatePImage"),project_path(project.id,:host=>Setting.host_name),:id=>"project_img_"+project.id.to_s+"_"+activity.id.to_s,:alt =>"项目头像", :target => '_blank' %> - - <% update_time = time_from_now !com_time.nil? && format_time(com_time) > format_time(forge_time) ? com_time : forge_time %> - - <% else %> - <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius relatePImage",:id=>"project_img_"+project.id.to_s+"_"+activity.id.to_s,:alt =>"项目头像",:title => "私有项目不可访问") %> - - - <% end %> -
    - 项目名称:<%=project.name %>
    - 创建者:<%=(User.find project.user_id).show_name %>(组长)
    - 更新时间:<%=time_from_now !com_time.nil? && format_time(com_time) > format_time(forge_time) ? com_time : forge_time %> -
    -
    - <% if i == 9 && projects.count > 10 %> -
    更多>> - <% end %> - <% if i > 9 && i == (projects.count - 1) %> - 收回<< - <% end %> - <% end %> -
    - <% end %> - <% end %> -
    - <% if is_teacher%> - <% comment_status = activity.homework_detail_manual.comment_status %> -
    -
      -
    • -
        -
      • - <%= link_to l(:button_edit),edit_homework_common_path(activity, :hw_status => hw_status), :class => "postOptionLink"%> -
      • -
      • - <%= link_to(l(:label_bid_respond_delete), homework_common_path(activity, :hw_status => hw_status),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %> -
      • -
      • - <%= link_to("评分设置", score_rule_set_homework_common_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status),:class => "postOptionLink", :remote => true) %> -
      • - <% if activity.anonymous_comment == 0 %> -
      • - <%= link_to("匿评设置", start_evaluation_set_homework_common_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status),:class => "postOptionLink", :remote => true) if activity.homework_detail_manual.comment_status == 1%> -
      • -
      • - <%= homework_anonymous_comment activity,hw_status,user_activity_id %> -
      • - <% end %> - <% if activity.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%> -
      • - <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id),:class => "postOptionLink", - :title => "匿评是同学之间的双盲互评过程:每个同学将评阅系统分配给他/她的若干个作品", :remote => true)%> -
      • - <% end %> - <% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %> -
      • - <%= link_to("公开作品", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status),:class => "postOptionLink", :remote => true)%> -
      • - <% elsif activity.is_open == 1 %> -
      • - <%= link_to("取消公开", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status),:class => "postOptionLink", :remote => true)%> -
      • - <% end %> -
      -
    • -
    -
    - <% end%> + <%= render :partial => "users/homework_base_info", :locals =>{:activity => activity, :user_activity_id =>user_activity_id, :is_teacher => is_teacher, :hw_status => hw_status} %>
    - <% count=activity.journals_for_messages.count %> -
    - <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :hw_status => hw_status} %> - - <% comments = activity.journals_for_messages.reorder("created_on desc").limit(3) %> - <% if count > 0 %> -
    - <%=render :partial => 'users/news_replies', :locals => {:comments => comments, :type => 'HomeworkCommon', :hw_status => hw_status, :is_teacher => is_teacher, :user_activity_id => user_activity_id, :activity_id => activity.id} %> -
    - <% end %> - -
    -
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
    -
    - <% if User.current.logged? %> -
    - <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_homework_message', :id => activity.id},:method => "post", :remote => true) do |f|%> - <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %> - <%= hidden_field_tag 'hw_status',params[:hw_status],:value =>hw_status %> -
    - - -
    -

    - <% end%> -
    - <% else %> - <%= render :partial => "users/show_unlogged" %> - <% end %> -
    -
    -
    -
    -
    + <%= render :partial => 'users/homework_post_reply', :locals => {:activity => activity, :user_activity_id => user_activity_id, :hw_status => hw_status, :is_teacher => is_teacher} %>
    + +
    + <% com_time = project.project_score.commit_time %> + <% forge_time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %> + <% if project.is_public || User.current.member_of?(project) || User.current.admin? %> + <%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius relatePImage"),project_path(project.id,:host=>Setting.host_name),:id=>"project_img_"+project.id.to_s+"_"+activity.id.to_s,:alt =>"项目头像", :target => '_blank' %> + + <% update_time = time_from_now !com_time.nil? && format_time(com_time) > format_time(forge_time) ? com_time : forge_time %> + + <% else %> + <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius relatePImage",:id=>"project_img_"+project.id.to_s+"_"+activity.id.to_s,:alt =>"项目头像",:title => "私有项目不可访问") %> + + + <% end %> +
    + 项目名称:<%=project.name %>
    + 创建者:<%=(User.find project.user_id).show_name %>(组长)
    + 更新时间:<%=time_from_now !com_time.nil? && format_time(com_time) > format_time(forge_time) ? com_time : forge_time %> +
    +
    + <% if i == 9 && projects.count > 10 %> + 更多>> + <% end %> + <% if i > 9 && i == (projects.count - 1) %> + 收回<< + <% end %> + <% end %> +
    + <% end %> +<% end %> +
    + +<% if is_teacher%> + <% comment_status = activity.homework_detail_manual.comment_status %> +
    +
      +
    • +
        +
      • + <%= link_to l(:button_edit),edit_homework_common_path(activity, :hw_status => hw_status), :class => "postOptionLink"%> +
      • +
      • + <%= link_to(l(:label_bid_respond_delete), homework_common_path(activity, :hw_status => hw_status),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %> +
      • +
      • + <%= link_to("评分设置", score_rule_set_homework_common_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status),:class => "postOptionLink", :remote => true) %> +
      • + <% if activity.anonymous_comment == 0 %> +
      • + <%= link_to("匿评设置", start_evaluation_set_homework_common_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status),:class => "postOptionLink", :remote => true) if activity.homework_detail_manual.comment_status == 1%> +
      • +
      • + <%= homework_anonymous_comment activity,hw_status,user_activity_id %> +
      • + <% end %> + <% if activity.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%> +
      • + <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id),:class => "postOptionLink", + :title => "匿评是同学之间的双盲互评过程:每个同学将评阅系统分配给他/她的若干个作品", :remote => true)%> +
      • + <% end %> + <% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %> +
      • + <%= link_to("公开作品", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status),:class => "postOptionLink", :remote => true)%> +
      • + <% elsif activity.is_open == 1 %> +
      • + <%= link_to("取消公开", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status),:class => "postOptionLink", :remote => true)%> +
      • + <% end %> +
      +
    • +
    +
    +<% end%> \ No newline at end of file diff --git a/app/views/users/_homework_opr.html.erb b/app/views/users/_homework_opr.html.erb new file mode 100644 index 000000000..53d16b15d --- /dev/null +++ b/app/views/users/_homework_opr.html.erb @@ -0,0 +1,43 @@ +<% if activity.homework_type == 3 && !is_teacher && activity.homework_detail_group.base_on_project == 1 && User.current.member_of_course?(activity.course)%> + <% projects = cur_user_projects_for_homework activity %> + <% works = cur_user_works_for_homework activity %> + <% if works.nil? && projects.nil? %> +
    + <%=link_to "关联项目",new_student_work_project_student_work_index_path(:homework => activity.id,:hw_status=>hw_status,:user_activity_id=>user_activity_id),remote: true,:class=> 'c_blue', :title=> '请各组长关联作业项目' %> +
    + <% elsif works.nil? %> +
    + <%=link_to "取消关联",cancel_relate_project_student_work_index_path(:homework => activity.id,:hw_status=>hw_status,:user_activity_id=>user_activity_id), :confirm => "您确定要取消关联吗?", remote: true,:class => "c_blue", :title=> '取消关联项目' %> +
    + <% end %> +<% end %> +
    + <%= user_for_homework_common activity,is_teacher %> +
    +<% work = cur_user_works_for_homework activity %> +<% if activity.end_time < Date.today && !is_teacher && !work.nil? && work.user == User.current %> +
    + <%=link_to "追加附件", student_work_index_url_in_org(activity.id, 2, 1), :class => 'c_blue', :title => "可追加作品修订附件" %> +
    +<% end %> +<% if activity.homework_type == 2 && is_teacher%> +
    + <%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: activity.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %> +
    + <% if activity.homework_detail_manual.comment_status != 0 %> +
    + <%= link_to "代码查重", work_canrepeat_student_work_index_path(homework: activity.id, course_id: activity.course.id), class: 'c_blue test-program-btn',:remote => true %> +
    + <% end %> +<% end %> +<% if activity.homework_type == 2%> +
    + 语言: + <%= activity.language_name%> +
    +<% end %> +<% if activity.homework_type == 3 && activity.homework_detail_group%> +
    + 分组人数:<%=activity.homework_detail_group.min_num %>-<%=activity.homework_detail_group.max_num %> 人 +
    +<% end %> \ No newline at end of file diff --git a/app/views/users/_homework_post_reply.html.erb b/app/views/users/_homework_post_reply.html.erb new file mode 100644 index 000000000..0037e35ac --- /dev/null +++ b/app/views/users/_homework_post_reply.html.erb @@ -0,0 +1,34 @@ +<% count=activity.journals_for_messages.count %> +
    + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :hw_status => hw_status} %> + + <% comments = activity.journals_for_messages.reorder("created_on desc").limit(3) %> + <% if count > 0 %> +
    + <%=render :partial => 'users/news_replies', :locals => {:comments => comments, :type => 'HomeworkCommon', :hw_status => hw_status, :is_teacher => is_teacher, :user_activity_id => user_activity_id, :activity_id => activity.id} %> +
    + <% end %> + +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
    +
    + <% if User.current.logged? %> +
    + <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_homework_message', :id => activity.id},:method => "post", :remote => true) do |f|%> + <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %> + <%= hidden_field_tag 'hw_status',params[:hw_status],:value =>hw_status %> +
    + + +
    +

    + <% end%> +
    + <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %> +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index 6f1fb7843..3351ae3f2 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -50,7 +50,7 @@ <% work = cur_user_works_for_homework homework_common %> <% if !is_teacher && !work.nil? && homework_common.end_time < Date.today && work.user == User.current %>
    - <%=link_to "追加附件", student_work_index_url_in_org(homework_common.id, 1), :class => 'c_blue', :title => "可追加作品修订附件" %> + <%=link_to "追加附件", student_work_index_url_in_org(homework_common.id, 2, 1), :class => 'c_blue', :title => "可追加作品修订附件" %>
    <% end %> <% if homework_common.homework_type == 2 && is_teacher%> diff --git a/app/views/words/destroy.js.erb b/app/views/words/destroy.js.erb index 5dcdc6401..ab41b1ae6 100644 --- a/app/views/words/destroy.js.erb +++ b/app/views/words/destroy.js.erb @@ -31,7 +31,7 @@ <% elsif @user && @jours_count%> $('#jour_count').html("<%= @jours_count %>"); <% elsif @homework%> - $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>"); + $("#homework_post_reply_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/homework_post_reply', :locals => {:activity => @homework, :user_activity_id => @user_activity_id, :hw_status => @hw_status, :is_teacher => @is_teacher}) %>"); <% if @user_activity_id != @homework.id %> sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); <% else %> diff --git a/app/views/words/leave_homework_message.js.erb b/app/views/words/leave_homework_message.js.erb index 61a8aca14..f6a89323f 100644 --- a/app/views/words/leave_homework_message.js.erb +++ b/app/views/words/leave_homework_message.js.erb @@ -1,4 +1,4 @@ -$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework_common,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>"); +$("#homework_post_reply_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/homework_post_reply', :locals => {:activity => @homework_common, :user_activity_id => @user_activity_id, :hw_status => @hw_status, :is_teacher => @is_teacher}) %>"); <% if @user_activity_id != @homework_common.id %> sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); <% else %> diff --git a/app/views/words/reply_to_homework.js.erb b/app/views/words/reply_to_homework.js.erb index 61a8aca14..f6a89323f 100644 --- a/app/views/words/reply_to_homework.js.erb +++ b/app/views/words/reply_to_homework.js.erb @@ -1,4 +1,4 @@ -$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework_common,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>"); +$("#homework_post_reply_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/homework_post_reply', :locals => {:activity => @homework_common, :user_activity_id => @user_activity_id, :hw_status => @hw_status, :is_teacher => @is_teacher}) %>"); <% if @user_activity_id != @homework_common.id %> sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); <% else %> diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 8f6c56a4b..a2117bdf3 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -130,7 +130,7 @@ a.hworkSearchIcon:hover {background:url(../images/nav_icon.png) -49px -1px no-re /*作业信息*/ .mt-2 {margin-top:-2px;} -.homeworkInfo {background:#F6F6F6; padding:10px; margin-bottom:10px;} +.homeworkInfo {background:#F6F6F6; padding:10px;} .homeworkDetail {line-height:18px; font-size:12px; color:#484848; overflow:hidden;} .homeworkDetail p,.homeworkDetail div,.homeworkDetail em, .homeworkDetail span{text-align: justify; text-justify:inter-ideograph; word-break: normal !important; word-wrap: break-word !important; line-height: 18px !important;} .max_h54 {max-height:54px; } diff --git a/public/stylesheets/css/courses.css b/public/stylesheets/css/courses.css index 1841e0348..eccbcc9b1 100644 --- a/public/stylesheets/css/courses.css +++ b/public/stylesheets/css/courses.css @@ -249,7 +249,7 @@ a.hworkSearchIcon:hover {background:url(../images/nav_icon.png) -49px -1px no-re .StudentName{display: table-cell;width: 115px;vertical-align: middle;text-align: left;height: 40px;} /*作业信息*/ -.homeworkInfo {background:#F6F6F6; padding:10px; margin-bottom:10px;} +.homeworkInfo {background:#F6F6F6; padding:10px;} .homeworkDetail {line-height:18px; font-size:12px; color:#484848; overflow:hidden;} .homeworkDetail p,.homeworkDetail div,.homeworkDetail em, .homeworkDetail span{text-align: justify; text-justify:inter-ideograph; word-break: normal !important; word-wrap: break-word !important; line-height: 18px !important;} .homeworkState {padding:3px 5px; background-color:#28be6c; border-radius:3px; float:left; margin-left:15px; color:#ffffff;} From ab72bf5f088a279b26f7674a3b379cb2631fe696 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 22 Sep 2016 09:48:37 +0800 Subject: [PATCH 18/42] =?UTF-8?q?=E5=88=86=E7=8F=AD=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/class_group.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/assets/wechat/class_group.html b/public/assets/wechat/class_group.html index 04cdf8025..e5a1b8f47 100644 --- a/public/assets/wechat/class_group.html +++ b/public/assets/wechat/class_group.html @@ -3,7 +3,7 @@
    -
    {{group.name+"("+group.users.length+")"}}
    +
    {{group.name+"("+group.users.length+")"}}
    {{user.realname == "" ? user.name : user.realname}}
    From 1798b8a086d13e968a788833bd965d0f8dab7abb Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Thu, 22 Sep 2016 09:56:46 +0800 Subject: [PATCH 19/42] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E7=8F=AD=E7=BA=A7logob?= =?UTF-8?q?ug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/courses_service.rb | 2 +- public/assets/wechat/edit_class_group.html | 2 +- public/assets/wechat/join_classgroup.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 5d2957d4c..b97fa1a64 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -334,7 +334,7 @@ class CoursesService # end groupnum = 0 groupnum = course.course_groups.length if course.course_groups - {:course => course,:syllabus_title => course.syllabus.nil? ? "":course.syllabus.title ,:work_unit => work_unit, :img_url => url_to_avatar(course),:current_user_is_member => current_user.nil? ? false : current_user.member_of_course?(course),:current_user_is_teacher => current_user.nil? ? false : is_course_teacher(current_user,course),:course_student_num => course ? course.student.count.to_s : 0,:groupnum => groupnum} + {:course => course,:syllabus_title => course.syllabus.nil? ? "":course.syllabus.title ,:work_unit => work_unit, :img_url => "/images/"+url_to_avatar(course),:current_user_is_member => current_user.nil? ? false : current_user.member_of_course?(course),:current_user_is_teacher => current_user.nil? ? false : is_course_teacher(current_user,course),:course_student_num => course ? course.student.count.to_s : 0,:groupnum => groupnum} end #创建课程 diff --git a/public/assets/wechat/edit_class_group.html b/public/assets/wechat/edit_class_group.html index 3dda96d53..4c1c612a6 100644 --- a/public/assets/wechat/edit_class_group.html +++ b/public/assets/wechat/edit_class_group.html @@ -2,7 +2,7 @@
    分班管理
    -
    {{course.name}}
    +
    {{course.name}}
    分班名称删除
    diff --git a/public/assets/wechat/join_classgroup.html b/public/assets/wechat/join_classgroup.html index 9a7e9fa2d..631ec4969 100644 --- a/public/assets/wechat/join_classgroup.html +++ b/public/assets/wechat/join_classgroup.html @@ -2,7 +2,7 @@
    欢迎加入班级
    -
    {{current_course.name}}
    +
    {{current_course.name}}
    选择分班{{selectid}}
    • From 72190a3639ca915e94404b8561a92e1c5dee3859 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Thu, 22 Sep 2016 10:47:02 +0800 Subject: [PATCH 20/42] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/join_classgroup.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/assets/wechat/join_classgroup.html b/public/assets/wechat/join_classgroup.html index 631ec4969..dce42ee42 100644 --- a/public/assets/wechat/join_classgroup.html +++ b/public/assets/wechat/join_classgroup.html @@ -3,7 +3,7 @@
      欢迎加入班级
      {{current_course.name}}
      -
      选择分班{{selectid}}
      +
      选择分班
      • From 11132d345914c00d59b32ea2d1521e0bc69d6ba9 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Thu, 22 Sep 2016 10:49:53 +0800 Subject: [PATCH 21/42] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E7=8F=AD=E7=BA=A7=E6=97=B6=E9=80=89=E6=8B=A9=E5=88=86=E7=8F=AD?= =?UTF-8?q?=E5=90=8E=E8=B7=B3=E5=85=A5=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/controllers/join_classgroup.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/public/javascripts/wechat/controllers/join_classgroup.js b/public/javascripts/wechat/controllers/join_classgroup.js index 4812ca767..a63744e3c 100644 --- a/public/javascripts/wechat/controllers/join_classgroup.js +++ b/public/javascripts/wechat/controllers/join_classgroup.js @@ -43,7 +43,8 @@ app.controller('JoinClassGroupController', ['$scope', '$http', 'auth', 'config', vm.cancel = function(){ - $location.path("/class").search({id: course_id,tag:1}); + rms.save('syllabuses',[]); + $location.path("/class_list"); }; vm.confirm = function(){ @@ -66,10 +67,12 @@ app.controller('JoinClassGroupController', ['$scope', '$http', 'auth', 'config', console.log(response); if(response.data.status == 0){ vm.alertService.showMessage('提示', "选择分班成功!",function(){ + rms.save('syllabuses',[]); $location.path("/class_list"); }); } else { vm.alertService.showMessage('提示', response.data.message,function(){ + rms.save('syllabuses',[]); $location.path("/class_list"); }); } From 0b1a22d9aa382ce7479d5f2750ebaf6af9d6b1b3 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 22 Sep 2016 13:56:57 +0800 Subject: [PATCH 22/42] =?UTF-8?q?=E5=88=86=E7=8F=AD=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/class_group.html | 2 +- public/assets/wechat/edit_class_member.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/assets/wechat/class_group.html b/public/assets/wechat/class_group.html index e5a1b8f47..b097db9c6 100644 --- a/public/assets/wechat/class_group.html +++ b/public/assets/wechat/class_group.html @@ -3,7 +3,7 @@
        -
        {{group.name+"("+group.users.length+")"}}
        +
        {{group.name+"("+group.users.length+")"}}
        {{user.realname == "" ? user.name : user.realname}}
        diff --git a/public/assets/wechat/edit_class_member.html b/public/assets/wechat/edit_class_member.html index 1eb53c7bf..5530671f7 100644 --- a/public/assets/wechat/edit_class_member.html +++ b/public/assets/wechat/edit_class_member.html @@ -18,7 +18,7 @@
      • -
      • +
      From a169ad087bd9e7fd0bf985f570203813768a17e8 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Thu, 22 Sep 2016 14:03:59 +0800 Subject: [PATCH 23/42] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E5=88=86=E7=8F=AD?= =?UTF-8?q?=E6=97=B6=E9=80=89=E6=8B=A9=E6=9A=82=E6=97=A0=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=8F=AD=E7=BA=A7=E5=88=97=E8=A1=A8=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/controllers/join_classgroup.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public/javascripts/wechat/controllers/join_classgroup.js b/public/javascripts/wechat/controllers/join_classgroup.js index a63744e3c..ed7692494 100644 --- a/public/javascripts/wechat/controllers/join_classgroup.js +++ b/public/javascripts/wechat/controllers/join_classgroup.js @@ -54,6 +54,7 @@ app.controller('JoinClassGroupController', ['$scope', '$http', 'auth', 'config', } if(vm.selectid == 0){ + rms.save('syllabuses',[]); $location.path("/class_list"); return; } From dac9502f1fbdc47e6a720f4857ca8cb28beec38e Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 22 Sep 2016 14:25:09 +0800 Subject: [PATCH 24/42] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93=E6=9D=A5?= =?UTF-8?q?=E6=BA=90title=E6=98=BE=E7=A4=BA=E5=B8=A6html=E4=BB=A3=E7=A0=81?= =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_resources_list.html.erb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index d7f0dee7f..0190e60dc 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -267,4 +267,9 @@ } } + + $(".resource-list-from").each(function(){ + var titleContent = $(this).text(); + $(this).attr("title",titleContent); + }); From 0716d4fa3863add1070fa7df6ebcff798bb41a9c Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Thu, 22 Sep 2016 14:29:00 +0800 Subject: [PATCH 25/42] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/edit_class_group.html | 2 +- public/assets/wechat/join_classgroup.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/assets/wechat/edit_class_group.html b/public/assets/wechat/edit_class_group.html index 4c1c612a6..6f08d1b53 100644 --- a/public/assets/wechat/edit_class_group.html +++ b/public/assets/wechat/edit_class_group.html @@ -2,7 +2,7 @@
      分班管理
      -
      {{course.name}}
      +
      {{course.name}}
      分班名称删除
      diff --git a/public/assets/wechat/join_classgroup.html b/public/assets/wechat/join_classgroup.html index dce42ee42..e4d92fbf8 100644 --- a/public/assets/wechat/join_classgroup.html +++ b/public/assets/wechat/join_classgroup.html @@ -2,7 +2,7 @@
      欢迎加入班级
      -
      {{current_course.name}}
      +
      {{current_course.name}}
      选择分班
      • From b965e270e24301ce85605fa80db827d2c8232c18 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 22 Sep 2016 15:27:16 +0800 Subject: [PATCH 26/42] =?UTF-8?q?=E5=88=86=E7=8F=AD=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=A2=9E=E5=8A=A0=E8=AF=BE=E7=A8=8B=E5=90=8D?= =?UTF-8?q?=EF=BC=8C=E8=AF=BE=E7=A8=8B=E5=90=8D=E4=B8=8E=E7=8F=AD=E7=BA=A7?= =?UTF-8?q?=E5=90=8D=E4=B9=8B=E9=97=B4=E7=82=B9=E5=8F=B7=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=EF=BC=8C=E5=9B=BE=E6=A0=87=E5=9C=86=E5=BD=A2?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/class.html | 2 +- public/assets/wechat/class_publishissue.html | 2 +- public/assets/wechat/class_publishnotice.html | 2 +- public/assets/wechat/edit_class_group.html | 2 +- public/assets/wechat/invite_code.html | 2 +- public/assets/wechat/join_classgroup.html | 4 ++-- public/assets/wechat/review_class_member.html | 4 ++-- public/assets/wechat/select_my_coursegroup.html | 4 ++-- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/public/assets/wechat/class.html b/public/assets/wechat/class.html index 6678456b6..789ef7018 100644 --- a/public/assets/wechat/class.html +++ b/public/assets/wechat/class.html @@ -1,6 +1,6 @@
        -
        邀请码
        +
        邀请码
        diff --git a/public/assets/wechat/class_publishissue.html b/public/assets/wechat/class_publishissue.html index 5a65beabf..cf030d7c5 100644 --- a/public/assets/wechat/class_publishissue.html +++ b/public/assets/wechat/class_publishissue.html @@ -1,7 +1,7 @@
        -
        +
        标题
        diff --git a/public/assets/wechat/class_publishnotice.html b/public/assets/wechat/class_publishnotice.html index e56c762a6..21b1deeb7 100644 --- a/public/assets/wechat/class_publishnotice.html +++ b/public/assets/wechat/class_publishnotice.html @@ -1,7 +1,7 @@
        -
        +
        标题
        diff --git a/public/assets/wechat/edit_class_group.html b/public/assets/wechat/edit_class_group.html index 4c1c612a6..d3683358e 100644 --- a/public/assets/wechat/edit_class_group.html +++ b/public/assets/wechat/edit_class_group.html @@ -2,7 +2,7 @@
        分班管理
        -
        {{course.name}}
        +
        {{course.syllabus_title}}·{{course.name}}
        分班名称删除
        diff --git a/public/assets/wechat/invite_code.html b/public/assets/wechat/invite_code.html index c6d3b425f..ae30e335e 100644 --- a/public/assets/wechat/invite_code.html +++ b/public/assets/wechat/invite_code.html @@ -1,7 +1,7 @@
        - +
        邀请码:{{course.invite_code}}
        diff --git a/public/assets/wechat/join_classgroup.html b/public/assets/wechat/join_classgroup.html index dce42ee42..4b14b0153 100644 --- a/public/assets/wechat/join_classgroup.html +++ b/public/assets/wechat/join_classgroup.html @@ -2,13 +2,13 @@
        欢迎加入班级
        -
        {{current_course.name}}
        +
        {{course.syllabus_title}}·{{current_course.name}}
        选择分班
        • -
        • +
        diff --git a/public/assets/wechat/review_class_member.html b/public/assets/wechat/review_class_member.html index b1f0dacc5..ee0138965 100644 --- a/public/assets/wechat/review_class_member.html +++ b/public/assets/wechat/review_class_member.html @@ -2,7 +2,7 @@
        -
        +
        {{current_review_member.realname == "" ? current_review_member.name : current_review_member.realname}}
        角色
          @@ -29,7 +29,7 @@
        -
        +
        {{tip_2}}
        diff --git a/public/assets/wechat/select_my_coursegroup.html b/public/assets/wechat/select_my_coursegroup.html index cc7a65753..5bd563554 100644 --- a/public/assets/wechat/select_my_coursegroup.html +++ b/public/assets/wechat/select_my_coursegroup.html @@ -2,7 +2,7 @@
        我的信息
        -
        {{current_edit_member.user.realname == "" ? current_edit_member.user.name : current_edit_member.user.realname}}
        +
        {{current_edit_member.user.realname == "" ? current_edit_member.user.name : current_edit_member.user.realname}}
        角色
        学生
        选择分班
        @@ -10,7 +10,7 @@
      • -
      • +
      From 0431d28fd132b3a036400cb514e852679d45de01 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 22 Sep 2016 15:35:43 +0800 Subject: [PATCH 27/42] =?UTF-8?q?=E5=88=86=E7=8F=AD=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/edit_class_member.html | 2 +- public/assets/wechat/join_classgroup.html | 2 +- public/assets/wechat/select_my_coursegroup.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/assets/wechat/edit_class_member.html b/public/assets/wechat/edit_class_member.html index 5530671f7..cbbd96ba3 100644 --- a/public/assets/wechat/edit_class_member.html +++ b/public/assets/wechat/edit_class_member.html @@ -15,7 +15,7 @@
    编辑分班
      -
    • +
    • diff --git a/public/assets/wechat/join_classgroup.html b/public/assets/wechat/join_classgroup.html index 91a1184d7..a63217288 100644 --- a/public/assets/wechat/join_classgroup.html +++ b/public/assets/wechat/join_classgroup.html @@ -5,7 +5,7 @@
      {{course.syllabus_title}}·{{current_course.name}}
      选择分班
        -
      • +
      • diff --git a/public/assets/wechat/select_my_coursegroup.html b/public/assets/wechat/select_my_coursegroup.html index 5bd563554..54c4c8c80 100644 --- a/public/assets/wechat/select_my_coursegroup.html +++ b/public/assets/wechat/select_my_coursegroup.html @@ -7,7 +7,7 @@
        学生
        选择分班
          -
        • +
        • From 61c2f8fdd6ca686c067f5ea20f775c784a0098f8 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Thu, 22 Sep 2016 16:17:23 +0800 Subject: [PATCH 28/42] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=88=86=E7=8F=AD=E5=90=8D=E7=A7=B0=E8=BF=87=E9=95=BF=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/edit_class_group.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/assets/wechat/edit_class_group.html b/public/assets/wechat/edit_class_group.html index 756670b2a..f13f02100 100644 --- a/public/assets/wechat/edit_class_group.html +++ b/public/assets/wechat/edit_class_group.html @@ -4,7 +4,7 @@
          分班管理
          {{course.syllabus_title}}·{{course.name}}
          -
          分班名称删除
          +
          分班名称删除
          完成 From caf5602389ece0a5526cff1c990782724727be9c Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 23 Sep 2016 09:22:47 +0800 Subject: [PATCH 29/42] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=A4=A7=E7=BA=B2?= =?UTF-8?q?=E6=95=99=E5=B8=88=E5=9B=A2=E9=98=9F=E7=9A=84=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javascripts/syllabus_member.js.coffee | 3 + .../stylesheets/syllabus_member.css.scss | 3 + app/controllers/syllabus_member_controller.rb | 64 +++++++++++++++++++ app/controllers/syllabuses_controller.rb | 10 ++- app/helpers/syllabus_member_helper.rb | 17 +++++ app/helpers/syllabuses_helper.rb | 14 ++++ app/models/principal.rb | 10 +++ app/models/syllabus.rb | 1 + app/models/syllabus_member.rb | 5 ++ app/models/user.rb | 1 + .../layouts/_syllabus_teacher_list.html.erb | 10 +-- app/views/layouts/base_syllabus.html.erb | 13 ++-- app/views/syllabus_member/create.js.erb | 4 ++ app/views/syllabus_member/destroy.js.erb | 2 + .../syl_member_autocomplete.js.erb | 19 ++++++ app/views/syllabus_member/update_rank.js.erb | 2 + .../syllabuses/_syllabus_course_list.html.erb | 14 ++-- .../syllabuses/_syllabus_member_list.html.erb | 55 ++++++++++++++++ app/views/syllabuses/members.html.erb | 51 +++++++++++++++ app/views/syllabuses/show.html.erb | 3 + .../syllabuses/syllabus_courselist.html.erb | 3 + config/locales/projects/zh.yml | 2 +- config/routes.rb | 11 ++++ .../20160921062340_create_syllabus_members.rb | 23 +++++++ db/schema.rb | 46 ++++++++----- public/stylesheets/syllabus.css | 17 +++++ .../syllabus_member_controller_spec.rb | 5 ++ spec/factories/syllabus_members.rb | 9 +++ spec/models/syllabus_member_spec.rb | 5 ++ 29 files changed, 384 insertions(+), 38 deletions(-) create mode 100644 app/assets/javascripts/syllabus_member.js.coffee create mode 100644 app/assets/stylesheets/syllabus_member.css.scss create mode 100644 app/controllers/syllabus_member_controller.rb create mode 100644 app/helpers/syllabus_member_helper.rb create mode 100644 app/models/syllabus_member.rb create mode 100644 app/views/syllabus_member/create.js.erb create mode 100644 app/views/syllabus_member/destroy.js.erb create mode 100644 app/views/syllabus_member/syl_member_autocomplete.js.erb create mode 100644 app/views/syllabus_member/update_rank.js.erb create mode 100644 app/views/syllabuses/_syllabus_member_list.html.erb create mode 100644 app/views/syllabuses/members.html.erb create mode 100644 db/migrate/20160921062340_create_syllabus_members.rb create mode 100644 spec/controllers/syllabus_member_controller_spec.rb create mode 100644 spec/factories/syllabus_members.rb create mode 100644 spec/models/syllabus_member_spec.rb diff --git a/app/assets/javascripts/syllabus_member.js.coffee b/app/assets/javascripts/syllabus_member.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/syllabus_member.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/syllabus_member.css.scss b/app/assets/stylesheets/syllabus_member.css.scss new file mode 100644 index 000000000..579bf153b --- /dev/null +++ b/app/assets/stylesheets/syllabus_member.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the SyllabusMember controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/syllabus_member_controller.rb b/app/controllers/syllabus_member_controller.rb new file mode 100644 index 000000000..ac686c0a2 --- /dev/null +++ b/app/controllers/syllabus_member_controller.rb @@ -0,0 +1,64 @@ +class SyllabusMemberController < ApplicationController + + def syl_member_autocomplete + @syllabus = Syllabus.find(params[:syllabus]) + @flag = params[:flag] || false + respond_to do |format| + format.js + end + end + + def create + @syllabus = Syllabus.find(params[:syllabus]) + if params[:membership].nil? + @fail_hint = l(:label_blank_user_lists_for_org) + else + member_ids = params[:membership][:user_ids] + last_rank = @syllabus.syllabus_members.order("rank asc").last.rank + user_ids = @syllabus.syllabus_members.map{|sy| sy.user_id} + member_ids.each_with_index do |user_id, i| + unless user_ids.include?(user_id.to_i) + member = SyllabusMember.create(:user_id => user_id, :rank => last_rank + 1 + i) + @syllabus.syllabus_members << member + end + end + @members = @syllabus.syllabus_members.order("rank asc") + end + respond_to do |format| + format.js + end + end + + def destroy + member = SyllabusMember.find(params[:id]) + @syllabus = member.syllabus + after_syl_members = @syllabus.syllabus_members.where("rank > #{member.rank}") + after_syl_members.update_all("rank = rank - 1") + member.destroy + @members = @syllabus.syllabus_members.order("rank asc") + respond_to do |format| + format.js + end + end + + def update_rank + member = SyllabusMember.find(params[:id]) + @syllabus = member.syllabus + members = @syllabus.syllabus_members + if params[:opr] == 'up' && member.rank > 2 + before_mem = members.where("rank = #{member.rank - 1}").first + if before_mem && member.update_attribute('rank', member.rank - 1) + before_mem.update_attribute('rank', before_mem.rank + 1) + end + elsif params[:opr] == 'down' && member.rank > 1 && member.rank < members.count + after_mem = members.where("rank = #{member.rank + 1}").first + if after_mem && member.update_attribute('rank', member.rank + 1) + after_mem.update_attribute('rank', after_mem.rank - 1) + end + end + @members = @syllabus.syllabus_members.order("rank asc") + respond_to do |format| + format.js + end + end +end diff --git a/app/controllers/syllabuses_controller.rb b/app/controllers/syllabuses_controller.rb index e77b19511..94f05409c 100644 --- a/app/controllers/syllabuses_controller.rb +++ b/app/controllers/syllabuses_controller.rb @@ -6,7 +6,7 @@ class SyllabusesController < ApplicationController include CoursesHelper before_filter :is_logged, :only => [:index, :show, :edit, :new, :update, :destroy, :delete_syllabus] - before_filter :find_syllabus, :only => [:show, :edit, :update, :destroy, :syllabus_courselist, :edit_syllabus_eng_name, :edit_syllabus_title, :update_base_info, :delete_syllabus, :delete_des] + before_filter :find_syllabus, :only => [:show, :edit, :update, :destroy, :syllabus_courselist, :edit_syllabus_eng_name, :edit_syllabus_title, :update_base_info, :delete_syllabus, :delete_des, :members] def index user = User.current @syllabuses = user.syllabuses @@ -170,6 +170,14 @@ class SyllabusesController < ApplicationController end end + def members + @members = @syllabus.syllabus_members.includes(:user => {:user_extensions => [], :courses => []}).order("rank asc") + respond_to do |format| + format.js + format.html{render :layout => 'base_syllabus'} + end + end + private def find_syllabus @syllabus = Syllabus.find params[:id] diff --git a/app/helpers/syllabus_member_helper.rb b/app/helpers/syllabus_member_helper.rb new file mode 100644 index 000000000..491928d74 --- /dev/null +++ b/app/helpers/syllabus_member_helper.rb @@ -0,0 +1,17 @@ +module SyllabusMemberHelper + include ApplicationHelper + + def find_user_not_in_current_syllabus_by_name syllabus + if params[:q] && params[:q].lstrip.rstrip != "" + scope = Principal.active.sorted.not_member_of_syllabus(syllabus).like(params[:q]) + else + scope = [] + end + principals = paginateHelper scope,10 + s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :id => 'principals', :class => 'sy_new_tchlist') + links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options| + link_to text, host_with_protocol + "/syllabus_member/syl_member_autocomplete?" + parameters.merge(:q => params[:q],:flag => true,:syllabus=> syllabus, :format => 'js').to_query, :remote => true + } + s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "syllabus_member_pagination_links" ) + end +end diff --git a/app/helpers/syllabuses_helper.rb b/app/helpers/syllabuses_helper.rb index 7e815950b..b9e3d09c1 100644 --- a/app/helpers/syllabuses_helper.rb +++ b/app/helpers/syllabuses_helper.rb @@ -4,6 +4,20 @@ module SyllabusesHelper Syllabus.tagged_with(tag_name).order('updated_at desc') end + def find_user_not_in_current_syllabus_by_name syllabus + if params[:q] && params[:q].lstrip.rstrip != "" + scope = Principal.active.sorted.not_member_of_syllabus(syllabus).like(params[:q]) + else + scope = [] + end + principals = paginateHelper scope,10 + s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :id => 'principals', :class => 'sy_new_tchlist') + links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options| + link_to text, host_with_protocol + "/syllabus_member/syl_member_autocomplete?" + parameters.merge(:q => params[:q],:flag => true,:syllabus=> syllabus, :format => 'js').to_query, :remote => true + } + s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "syllabus_member_pagination_links" ) + end + def teacher_count syllabus count = 0 courses = syllabus.courses diff --git a/app/models/principal.rb b/app/models/principal.rb index e65816e83..7c2b24587 100644 --- a/app/models/principal.rb +++ b/app/models/principal.rb @@ -97,6 +97,16 @@ class Principal < ActiveRecord::Base end } + scope :not_member_of_syllabus, lambda {|syllabus| + syllabuses = [syllabus] unless syllabus.is_a?(Array) + if syllabuses.empty? + where("1=0") + else + ids = syllabuses.map(&:id) + where("#{Principal.table_name}.id NOT IN (SELECT DISTINCT user_id FROM #{SyllabusMember.table_name} WHERE syllabus_id IN (?))", ids) + end + } + scope :sorted, lambda { order(*Principal.fields_for_order_statement)} scope :applied_members, lambda {|project| diff --git a/app/models/syllabus.rb b/app/models/syllabus.rb index 29b675d25..0c23c1b13 100644 --- a/app/models/syllabus.rb +++ b/app/models/syllabus.rb @@ -9,6 +9,7 @@ class Syllabus < ActiveRecord::Base belongs_to :user has_many :courses has_many :journals_for_messages, :as => :jour, :dependent => :destroy + has_many :syllabus_members, :dependent => :destroy attr_accessible :description, :user_id, :title, :eng_name, :syllabus_type, :credit, :hours, :theory_hours, :practice_hours, :applicable_major, :pre_course safe_attributes 'title','user', 'description', 'eng_name', 'syllabus_type', 'credit', 'hours', 'theory_hours', 'practice_hours', 'credit', 'applicable_major', 'pre_course' diff --git a/app/models/syllabus_member.rb b/app/models/syllabus_member.rb new file mode 100644 index 000000000..40d3dacbe --- /dev/null +++ b/app/models/syllabus_member.rb @@ -0,0 +1,5 @@ +class SyllabusMember < ActiveRecord::Base + belongs_to :syllabus + belongs_to :user + attr_accessible :rank, :user_id, :syllabus_id +end diff --git a/app/models/user.rb b/app/models/user.rb index f2b2b6824..c1a830809 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -91,6 +91,7 @@ class User < Principal has_many :homework_attaches, :through => :homework_users has_many :homework_evaluations has_many :syllabuses, :dependent => :destroy + has_many :syllabus_members, :dependent => :destroy #问卷相关关关系 has_many :poll_users, :dependent => :destroy has_many :poll_votes, :dependent => :destroy diff --git a/app/views/layouts/_syllabus_teacher_list.html.erb b/app/views/layouts/_syllabus_teacher_list.html.erb index 344036ccf..c6d6fd59a 100644 --- a/app/views/layouts/_syllabus_teacher_list.html.erb +++ b/app/views/layouts/_syllabus_teacher_list.html.erb @@ -1,10 +1,12 @@

          教师团队 - 增加教师 + <% if User.current == @syllabus.user || User.current.admin? %> + 增加教师 + <% end %>

            - <% teacher = syllabus.user %> - <%# teachers.each do |teacher| %> + <% members.each do |member| %> + <% teacher = member.user %>
          • <%= link_to image_tag(url_to_avatar(teacher), :width => "60", :height => "60", :class => "sy_teachers_img fl mr15"), user_path(teacher), :target => "_blank", :alt => "用户头像" %>
            @@ -17,5 +19,5 @@
          • - <%# end %> + <% end %>
          \ No newline at end of file diff --git a/app/views/layouts/base_syllabus.html.erb b/app/views/layouts/base_syllabus.html.erb index 445af2a8b..3153741e0 100644 --- a/app/views/layouts/base_syllabus.html.erb +++ b/app/views/layouts/base_syllabus.html.erb @@ -60,11 +60,12 @@ <%= yield %>
          + <% members = @syllabus.syllabus_members.order("rank asc") %>
          <%= render :partial => 'layouts/syllabus_base_info', :locals => {:syllabus => @syllabus} %>
          -
          - <%= render :partial => 'layouts/syllabus_teacher_list', :locals => {:syllabus => @syllabus} %> +
          + <%= render :partial => 'layouts/syllabus_teacher_list', :locals => {:syllabus => @syllabus, :members => members} %>
          @@ -123,16 +124,18 @@ } function g(o){return document.getElementById(o);} function HoverLi(n){ - for(var i=1;i<=2;i++){ + //for(var i=1;i<=2;i++){ //g('sy_tab_nav_'+i).className='sy_tab_nomal'; //g('sy_tab_con_'+i).className='undis'; - } + //} //g('sy_tab_con_'+n).className='dis'; //g('sy_tab_nav_'+n).className='sy_tab_hover'; if(n == 1) { window.location.href = '<%=syllabus_path(@syllabus) %>'; - } else { + } else if(n == 2) { window.location.href = '<%=syllabus_courselist_syllabus_path(@syllabus) %>'; + } else if(n == 3) { + window.location.href = '<%=members_syllabus_path(@syllabus) %>'; } } //侧导航栏配置设置 diff --git a/app/views/syllabus_member/create.js.erb b/app/views/syllabus_member/create.js.erb new file mode 100644 index 000000000..d63db3288 --- /dev/null +++ b/app/views/syllabus_member/create.js.erb @@ -0,0 +1,4 @@ +$("#syllabus_member_list").replaceWith("<%= escape_javascript(render :partial => 'syllabuses/syllabus_member_list') %>"); +$("#syllabus_teacher_list").html("<%= escape_javascript(render :partial => 'layouts/syllabus_teacher_list', :locals => {:syllabus => @syllabus, :members => @members}) %>"); +$("#principal_search").val(""); +$("#principals_for_new_member").html(""); \ No newline at end of file diff --git a/app/views/syllabus_member/destroy.js.erb b/app/views/syllabus_member/destroy.js.erb new file mode 100644 index 000000000..8b1621741 --- /dev/null +++ b/app/views/syllabus_member/destroy.js.erb @@ -0,0 +1,2 @@ +$("#syllabus_member_list").replaceWith("<%= escape_javascript(render :partial => 'syllabuses/syllabus_member_list') %>"); +$("#syllabus_teacher_list").html("<%= escape_javascript(render :partial => 'layouts/syllabus_teacher_list', :locals => {:syllabus => @syllabus, :members => @members}) %>"); \ No newline at end of file diff --git a/app/views/syllabus_member/syl_member_autocomplete.js.erb b/app/views/syllabus_member/syl_member_autocomplete.js.erb new file mode 100644 index 000000000..f6160697d --- /dev/null +++ b/app/views/syllabus_member/syl_member_autocomplete.js.erb @@ -0,0 +1,19 @@ +<% if @syllabus %> +var checked = $("#principals_for_new_member input:checked").size(); +if(checked > 0) +{ + alert('翻页或搜索后将丢失当前选择的用户数据!'); +} +$('#principals_for_new_member').html('<%= escape_javascript(find_user_not_in_current_syllabus_by_name(@syllabus)) %>'); + +<% end %> +var collection = $("#principals_for_new_member").children("#principals").children("label"); +collection.css("text-overflow", "ellipsis"); +collection.css("white-space", "nowrap"); +collection.css("width", "200px"); +collection.css("overflow", "hidden"); +for(i = 0; i < collection.length; i++) { //增加悬浮显示 + var label = collection[i]; + var text = $(label).text(); + $(label).attr("title", text); +} \ No newline at end of file diff --git a/app/views/syllabus_member/update_rank.js.erb b/app/views/syllabus_member/update_rank.js.erb new file mode 100644 index 000000000..8b1621741 --- /dev/null +++ b/app/views/syllabus_member/update_rank.js.erb @@ -0,0 +1,2 @@ +$("#syllabus_member_list").replaceWith("<%= escape_javascript(render :partial => 'syllabuses/syllabus_member_list') %>"); +$("#syllabus_teacher_list").html("<%= escape_javascript(render :partial => 'layouts/syllabus_teacher_list', :locals => {:syllabus => @syllabus, :members => @members}) %>"); \ No newline at end of file diff --git a/app/views/syllabuses/_syllabus_course_list.html.erb b/app/views/syllabuses/_syllabus_course_list.html.erb index e90e274dc..8bbbd3cf9 100644 --- a/app/views/syllabuses/_syllabus_course_list.html.erb +++ b/app/views/syllabuses/_syllabus_course_list.html.erb @@ -9,7 +9,7 @@ <% if @type.to_i == 2 %> <%= link_to "", {:controller => 'syllabuses', :action => 'syllabus_courselist', :id =>@syllabus, :type => @type, :sort => @c_sort, :order => 2 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} mt15 fl", :remote => true %> <% end %> - <% if @syllabus.user == User.current %> + <% if @syllabus.syllabus_members.map{|sm| sm.user_id}.include?(User.current.id) %> <%= link_to "新建班级", new_course_path(:host=> Setting.host_course, :syllabus_id => @syllabus.id), :class => "sy_btn_green fr mt10 mr15", :target => '_blank'%> <% end %>
          @@ -21,13 +21,13 @@ <% if course.is_public == 0 && !User.current.member_of_course?(course) && !User.current.admin? %>

          <%= link_to @syllabus.title, syllabus_path(@syllabus.id), :style => 'color:#000', :target => '_blank' %> -  ·  + · <%=course.name %>(<%=current_time_and_term_short(course) %>)

          <% else %>

          <%= link_to @syllabus.title, syllabus_path(@syllabus.id), :style => 'color:#000', :target => '_blank' %> -  ·  + · <%= link_to course.name+"("+current_time_and_term_short(course)+")", course_path(course.id,:host=>Setting.host_course), :style => 'color:#000',:id => "show_course_#{course.id}", :target => '_blank', :title => (course.is_public? ? "公开班级:":"私有班级:")+course.name+"("+current_time_and_term(course)+")"%>

          @@ -88,12 +88,6 @@ \ No newline at end of file diff --git a/app/views/syllabuses/_syllabus_member_list.html.erb b/app/views/syllabuses/_syllabus_member_list.html.erb new file mode 100644 index 000000000..4ee3b9c28 --- /dev/null +++ b/app/views/syllabuses/_syllabus_member_list.html.erb @@ -0,0 +1,55 @@ +<% is_admin = User.current == @syllabus.user || User.current.admin? %> + + + + + + + + + <% if is_admin %> + + <% end %> + + + + <% @members.each_with_index do |member, i| %> + <% user = member.user %> + + + + + <% courses = user.courses.not_deleted %> + + + <% if is_admin %> + + <% end %> + + <% end %> + +
          序号姓名身份创建班级数参与班级数操作
          <%= member.rank %> + <% if member.rank == 1 %> +
          <%= user.show_name %>创建者
          + <% else %> + <%= user.show_name %> + <% end %> +
          + <% if user.user_extensions && user.user_extensions.identity %> + <%= get_user_roll user %> + <% end%> + <%= courses.where("tea_id = #{user.id}").count %><%= courses.where("tea_id != #{user.id}").count %> + <% if i == 0 %> +   + <% elsif i == 1 %> + <%= link_to('删除', {:controller => 'syllabus_member', :action => 'destroy', :id => member.id, :syllabus => @syllabus.id},:remote => true, :method => 'delete', :class => "fr sy_btn_grey mr5", :title => l(:button_delete)) %> + <%= link_to('下移', {:controller => 'syllabus_member', :action => 'update_rank', :id => member.id, :syllabus => @syllabus.id, :opr => 'down'},:remote => true, :method => 'post', :class => "fr sy_btn_blue mr5", :title => '下移') %> + <% elsif i == @members.count - 1 %> + <%= link_to('删除', {:controller => 'syllabus_member', :action => 'destroy', :id => member.id, :syllabus => @syllabus.id},:remote => true, :method => 'delete', :class => "fr sy_btn_grey mr5", :title => l(:button_delete)) %> + <%= link_to('上移', {:controller => 'syllabus_member', :action => 'update_rank', :id => member.id, :syllabus => @syllabus.id, :opr => 'up'},:remote => true, :method => 'post', :class => "fr sy_btn_blue mr5", :title => '上移') %> + <% else %> + <%= link_to('删除', {:controller => 'syllabus_member', :action => 'destroy', :id => member.id, :syllabus => @syllabus.id},:remote => true, :method => 'delete', :class => "fr sy_btn_grey mr5", :title => l(:button_delete)) %> + <%= link_to('下移', {:controller => 'syllabus_member', :action => 'update_rank', :id => member.id, :syllabus => @syllabus.id, :opr => 'down'},:remote => true, :method => 'post', :class => "fr sy_btn_blue mr5", :title => '下移') %> + <%= link_to('上移', {:controller => 'syllabus_member', :action => 'update_rank', :id => member.id, :syllabus => @syllabus.id, :opr => 'up'},:remote => true, :method => 'post', :class => "fr sy_btn_blue mr5", :title => '上移') %> + <% end %> +
          \ No newline at end of file diff --git a/app/views/syllabuses/members.html.erb b/app/views/syllabuses/members.html.erb new file mode 100644 index 000000000..fd4041b20 --- /dev/null +++ b/app/views/syllabuses/members.html.erb @@ -0,0 +1,51 @@ + + +
          +
          + <%= render :partial => 'syllabus_member_list' %> + 添加成员 +
          + +
          + + \ No newline at end of file diff --git a/app/views/syllabuses/show.html.erb b/app/views/syllabuses/show.html.erb index 17d03b8c5..03eb3f90a 100644 --- a/app/views/syllabuses/show.html.erb +++ b/app/views/syllabuses/show.html.erb @@ -14,6 +14,9 @@
        • 班级列表
        • +
        • + 教师团队 +
        <% if @syllabus.des_status == 0 && User.current == @syllabus.user %> diff --git a/app/views/syllabuses/syllabus_courselist.html.erb b/app/views/syllabuses/syllabus_courselist.html.erb index ecb8ed7b8..123d1e332 100644 --- a/app/views/syllabuses/syllabus_courselist.html.erb +++ b/app/views/syllabuses/syllabus_courselist.html.erb @@ -5,6 +5,9 @@
      • 班级列表
      • +
      • + 教师团队 +
      diff --git a/config/locales/projects/zh.yml b/config/locales/projects/zh.yml index 792ff35fd..4040edcc8 100644 --- a/config/locales/projects/zh.yml +++ b/config/locales/projects/zh.yml @@ -369,7 +369,7 @@ zh: label_input_email: 请输入邮箱地址 label_invite_trustie_user: "邀请Trustie注册用户" - label_invite_trustie_user_tips: "支持姓名、邮箱、登录名搜索!" + label_invite_trustie_user_tips: "支持姓名、邮箱、登录名搜索" label_user_role_null: 用户和角色不能留空! label_invite_project: 邀请您加入项目 label_mail_invite_success: 您已成功加入项目! diff --git a/config/routes.rb b/config/routes.rb index afe30d4de..d3700bb73 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1140,6 +1140,7 @@ RedmineApp::Application.routes.draw do post 'update_base_info' get 'delete_syllabus' get 'delete_des' + get 'members' end collection do @@ -1147,6 +1148,16 @@ RedmineApp::Application.routes.draw do end end + resources :syllabus_member do + member do + post 'update_rank' + end + + collection do + get 'syl_member_autocomplete' + end + end + # add by nwb # 课程路由设置 resources :courses do diff --git a/db/migrate/20160921062340_create_syllabus_members.rb b/db/migrate/20160921062340_create_syllabus_members.rb new file mode 100644 index 000000000..c2e76ee3f --- /dev/null +++ b/db/migrate/20160921062340_create_syllabus_members.rb @@ -0,0 +1,23 @@ +class CreateSyllabusMembers < ActiveRecord::Migration + def change + create_table :syllabus_members do |t| + t.integer :rank + t.references :syllabus + t.references :user + + t.timestamps + end + add_index :syllabus_members, :syllabus_id + add_index :syllabus_members, :user_id + add_index :syllabus_members, :rank + + count = Syllabus.all.count / 30 + 2 + transaction do + for i in 1 ... count do i + Syllabus.page(i).per(30).each do |syllabus| + SyllabusMember.create(:user_id => syllabus.user_id, :syllabus_id => syllabus.id, :rank => 1) + end + end + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 443e8c426..d8a60c93f 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 => 20160907080621) do +ActiveRecord::Schema.define(:version => 20160921062340) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -56,10 +56,10 @@ ActiveRecord::Schema.define(:version => 20160907080621) do t.integer "user_id" t.integer "applied_id" t.string "applied_type" - t.integer "viewed" - t.integer "status" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.integer "viewed", :default => 0 + t.integer "status", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "name" t.integer "applied_user_id" t.integer "role" @@ -157,13 +157,13 @@ ActiveRecord::Schema.define(:version => 20160907080621) do create_table "attachments", :force => true do |t| t.integer "container_id" t.string "container_type", :limit => 30 - t.string "filename", :default => "", :null => false - t.string "disk_filename", :default => "", :null => false - t.integer "filesize", :default => 0, :null => false + t.string "filename", :default => "", :null => false + t.string "disk_filename", :default => "", :null => false + t.integer "filesize", :default => 0, :null => false t.string "content_type", :default => "" - t.string "digest", :limit => 40, :default => "", :null => false - t.integer "downloads", :default => 0, :null => false - t.integer "author_id", :default => 0, :null => false + t.string "digest", :limit => 40, :default => "", :null => false + t.integer "downloads", :default => 0, :null => false + t.integer "author_id", :default => 0, :null => false t.datetime "created_on" t.string "description" t.string "disk_directory" @@ -173,7 +173,6 @@ ActiveRecord::Schema.define(:version => 20160907080621) do t.integer "quotes" t.integer "is_publish", :default => 1 t.date "publish_time" - t.boolean "init_file", :default => false end add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id" @@ -311,16 +310,14 @@ ActiveRecord::Schema.define(:version => 20160907080621) do add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids" create_table "changesets", :force => true do |t| - t.integer "repository_id", :null => false - t.string "revision", :null => false + t.integer "repository_id", :null => false + t.string "revision", :null => false t.string "committer" - t.datetime "committed_on", :null => false + t.datetime "committed_on", :null => false t.text "comments" t.date "commit_date" t.string "scmid" t.integer "user_id" - t.integer "project_id" - t.integer "type", :default => 0 end add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on" @@ -1881,6 +1878,9 @@ ActiveRecord::Schema.define(:version => 20160907080621) do t.datetime "updated_at", :null => false end + add_index "student_works_scores", ["student_work_id"], :name => "student_work_id" + add_index "student_works_scores", ["user_id"], :name => "user_id" + create_table "students_for_courses", :force => true do |t| t.integer "student_id" t.integer "course_id" @@ -1923,6 +1923,18 @@ ActiveRecord::Schema.define(:version => 20160907080621) do t.datetime "updated_at", :null => false end + create_table "syllabus_members", :force => true do |t| + t.integer "rank" + t.integer "syllabus_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "syllabus_members", ["rank"], :name => "index_syllabus_members_on_rank" + add_index "syllabus_members", ["syllabus_id"], :name => "index_syllabus_members_on_syllabus_id" + add_index "syllabus_members", ["user_id"], :name => "index_syllabus_members_on_user_id" + create_table "syllabuses", :force => true do |t| t.string "title" t.text "description" diff --git a/public/stylesheets/syllabus.css b/public/stylesheets/syllabus.css index 9aac34eae..1a04c73a5 100644 --- a/public/stylesheets/syllabus.css +++ b/public/stylesheets/syllabus.css @@ -617,3 +617,20 @@ a:hover.sy_class_ltitle{ color:#333;} /* 我的作业 */ .hw_classname{ width:180px; overflow:hidden; display:block;overflow:hidden;white-space: nowrap; text-overflow:ellipsis;} .hw_tab_top{ height: 50px; line-height: 50px; padding-left: 15px; border-bottom:1px solid #ddd; border-left:3px solid #3b94d6; } + +/*20160918教师团队*/ +.sy_new_tablebox{ padding:15px; padding-bottom:none;} +.sy_new_table{ width:100%; background:#fff; border:1px solid #e5e5e5; padding-bottom:30px;} +.sy_new_table thead tr{ height:40px; line-height:40px;} +.sy_new_table thead tr th{ border-bottom:1px solid #e5e5e5;} +.sy_new_table tbody tr:hover{ background:#f5f5f5;} +.sy_new_table tbody tr td{ height:40px; line-height:40px; border-bottom:1px dashed #e5e5e5; font-weight:normal; color:#888; text-align: center} +.sy_new_table tbody tr:last-child{ height:40px;} +.sy_new_tchlist li{ height:30px; line-height:30px;} +.sy_new_search{-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;border-radius:3px; border:1px solid #d3d3d3; background:#fff; padding-left:5px; color:#888; height:32px; width:370px;box-shadow: inset 0px 0px 3px #dcdcdc; } +.sy_new_tchbox{ background:#f5f5f5; padding:15px; margin:15px; margin-top:0px;} +.sy_new_orange{font-size: 12px;padding: 0 5px;border-radius: 3px;line-height: 14px;color: #ff4a1b;border: 1px solid #ff4a1b;} +.sy_new_namebox{ width:180px; overflow:hidden;} +.sy_new_name{ display:block;max-width:120px; overflow:hidden;white-space: nowrap; text-overflow:ellipsis;} +.sy_new_long_name{ display:block;width:180px; overflow:hidden;white-space: nowrap; text-overflow:ellipsis;} +.mt12{ margin-top:12px;} diff --git a/spec/controllers/syllabus_member_controller_spec.rb b/spec/controllers/syllabus_member_controller_spec.rb new file mode 100644 index 000000000..b56654f55 --- /dev/null +++ b/spec/controllers/syllabus_member_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe SyllabusMemberController, :type => :controller do + +end diff --git a/spec/factories/syllabus_members.rb b/spec/factories/syllabus_members.rb new file mode 100644 index 000000000..ab1bd6701 --- /dev/null +++ b/spec/factories/syllabus_members.rb @@ -0,0 +1,9 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :syllabus_member do + rank 1 + syllabus nil + user nil + end +end diff --git a/spec/models/syllabus_member_spec.rb b/spec/models/syllabus_member_spec.rb new file mode 100644 index 000000000..464c1e965 --- /dev/null +++ b/spec/models/syllabus_member_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe SyllabusMember, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 46c3e6e8f6ed947aae7ce4065718135b5af79c93 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 23 Sep 2016 14:16:28 +0800 Subject: [PATCH 30/42] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/activity.rb | 26 ++++++++++++++++++++++++++ app/api/mobile/entities/whomework.rb | 19 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index b36b8039b..b2581c319 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -109,6 +109,28 @@ module Mobile "项目" end end + when :homework_commit_count + if ac.act_type == "HomeworkCommon" + ac.act.student_works.has_committed.count + end + when :last_commit_info + if ac.act_type == "HomeworkCommon" + if ac.act.student_works.has_committed.count > 0 + lc = ac.act.student_works.has_committed.reorder("commit_time desc").first + {:lasttime=>time_from_now(lc.commit_time), :lastname=>lc.user.show_name} + end + end + when :last_score_info + if ac.act_type == "HomeworkCommon" + if ac.act.student_works.has_committed.count > 0 + sw_id = "("+ac.act.student_works.map{|sw| sw.id}.join(",")+")" + student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id} and score is not null").reorder("created_at desc") + unless student_work_scores.empty? + last_score = student_work_scores.first + {:lasttime=>time_from_now(last_score.created_at), :lastname=>last_score.user.show_name} + end + end + end end end end @@ -153,6 +175,10 @@ module Mobile act_expose :course_project_name #课程/项目名字 act_expose :syllabus_title #课程名字 act_expose :activity_type_name #课程问答区/项目缺陷等 + act_expose :homework_commit_count #作品提交数 + act_expose :last_commit_info #最近提交信息 + act_expose :last_score_info #最近评阅信息 + expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| if instance.act_type == "HomeworkCommon" || instance.act_type == "News" || instance.act_type == "Message" || instance.act_type == "BlogComment" || instance.act_type == "JournalsForMessage" || instance.act_type == "Issue" has_praise = false diff --git a/app/api/mobile/entities/whomework.rb b/app/api/mobile/entities/whomework.rb index b19d34f05..1fbc52eea 100644 --- a/app/api/mobile/entities/whomework.rb +++ b/app/api/mobile/entities/whomework.rb @@ -38,6 +38,22 @@ module Mobile wh.id when :title wh.name + when :homework_commit_count + wh.student_works.has_committed.count + when :last_commit_info + if wh.student_works.has_committed.count > 0 + lc = wh.student_works.has_committed.reorder("commit_time desc").first + {:lasttime=>time_from_now(lc.commit_time), :lastname=>lc.user.show_name} + end + when :last_score_info + if wh.student_works.has_committed.count > 0 + sw_id = "("+wh.student_works.map{|sw| sw.id}.join(",")+")" + student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id} and score is not null").reorder("created_at desc") + unless student_work_scores.empty? + last_score = student_work_scores.first + {:lasttime=>time_from_now(last_score.created_at), :lastname=>last_score.user.show_name} + end + end end end end @@ -74,6 +90,9 @@ module Mobile whomework_expose :evaluation_end whomework_expose :praise_count whomework_expose :comment_count + whomework_expose :homework_commit_count #作品提交数 + whomework_expose :last_commit_info #最近提交信息 + whomework_expose :last_score_info #最近评阅信息 expose :all_children, using: Mobile::Entities::Jours do |f, opt| #f[:journals_for_messages] if f.is_a?(Hash) && f.key?(:journals_for_messages) if f.is_a?(::HomeworkCommon) From 56a55eb911e44bdf2437446a94ea9ef156643e79 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 23 Sep 2016 14:41:09 +0800 Subject: [PATCH 31/42] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=92=8C=E8=AF=A6=E6=83=85=E6=B7=BB=E5=8A=A0=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E4=BD=9C=E5=93=81=E6=95=B0=E5=8F=8A=E6=8F=90=E4=BA=A4=E5=8A=A8?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 10 ++++++++++ public/assets/wechat/homework_detail.html | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 09490b766..6c42ef098 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -37,6 +37,11 @@
      迟交扣分:{{act.homework_common_detail.late_penalty}}分 匿评开启时间:{{act.homework_common_detail.evaluation_start}}
      缺评扣分:{{act.homework_common_detail.absence_penalty}}分/作品 匿评关闭时间:{{act.homework_common_detail.evaluation_end}} +
      作品提交数: 10
      +
      + #1个月前 胡莎莎 评阅了作品
      + #2个月前 胡莎莎 提交了作品 +
      @@ -402,6 +407,11 @@
      迟交扣分:{{act.homework_common_detail.late_penalty}}分 匿评开启时间:{{act.homework_common_detail.evaluation_start}}
      缺评扣分:{{act.homework_common_detail.absence_penalty}}分/作品 匿评关闭时间:{{act.homework_common_detail.evaluation_end}} +
      作品提交数: 10
      +
      + #1个月前 胡莎莎 评阅了作品
      + #2个月前 胡莎莎 提交了作品 +
    diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index 161c3be94..1806f9eb7 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -30,6 +30,11 @@ 缺评扣分:{{homework.absence_penalty}}分/作品 匿评关闭时间:{{homework.evaluation_end}}
    +
    作品提交数: 10
    +
    + #1个月前 胡莎莎 评阅了作品
    + #2个月前 胡莎莎 提交了作品 +
    From 70042fe91fa016cf91f501fdd9416ed124af7aeb Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 23 Sep 2016 16:44:49 +0800 Subject: [PATCH 32/42] =?UTF-8?q?=E5=B8=96=E5=AD=90=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/messages_controller.rb | 56 +++++++++---------- app/helpers/application_helper.rb | 7 ++- app/models/blog_comment.rb | 2 + app/models/comment.rb | 2 + app/models/contest.rb | 1 + app/models/homework_common.rb | 2 + app/models/issue.rb | 1 + app/models/journal.rb | 2 + app/models/journals_for_message.rb | 2 + app/models/memo.rb | 2 + app/models/message.rb | 1 + app/models/news.rb | 3 + app/models/org_document_comment.rb | 2 + app/models/praise_tread_cache.rb | 3 +- app/models/syllabus.rb | 2 + app/views/messages/_course_show.html.erb | 6 +- .../messages/_org_subfield_show.html.erb | 6 +- app/views/messages/_project_show.html.erb | 6 +- app/views/praise_tread/_praise.html.erb | 4 +- 19 files changed, 68 insertions(+), 42 deletions(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 37383712f..5731244c3 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -38,47 +38,45 @@ class MessagesController < ApplicationController # Show a topic and its replies def show @isReply = true - page = params[:page] - # Find the page of the requested reply - if params[:r] && page.nil? - offset = @topic.children.count(:conditions => ["#{Message.table_name}.id < ?", params[:r].to_i]) - page = 1 + offset / REPLIES_PER_PAGE - end + # page = params[:page] + # # Find the page of the requested reply + # if params[:r] && page.nil? + # offset = @topic.children.count(:conditions => ["#{Message.table_name}.id < ?", params[:r].to_i]) + # page = 1 + offset / REPLIES_PER_PAGE + # end all_comments = [] - @reply_count = get_all_children(all_comments, @topic).count + @replies = get_all_children(all_comments, @topic) + @reply_count = @replies.count @reply = Message.new(:subject => "RE: #{@message.subject}") if @course - messages_replies = @topic.children. - includes(:author, :attachments, {:board => :project}). - reorder("#{Message.table_name}.created_on DESC"). + #@replies = @topic.children. + #includes(:author, :attachments, :praise_tread_cache, {:board => :project}). + #reorder("#{Message.table_name}.created_on DESC"). #limit(@reply_pages.per_page). #offset(@reply_pages.offset). - all - @replies = paginateHelper messages_replies,10 - @reply = Message.new(:subject => "RE: #{@message.subject}") + #all + #@replies = paginateHelper messages_replies,10 @left_nav_type = 2 render :action => "show", :layout => "base_courses"#by young elsif @project - @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page - @replies = @topic.children. - includes(:author, :attachments, {:board => :project}). - reorder("#{Message.table_name}.created_on DESC"). - limit(@reply_pages.per_page). - offset(@reply_pages.offset). - all + #@reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page + # @replies = @topic.children. + # includes(:author, :attachments, {:board => :project}). + # reorder("#{Message.table_name}.created_on DESC"). + # limit(@reply_pages.per_page). + # offset(@reply_pages.offset). + # all - @reply = Message.new(:subject => "RE: #{@message.subject}") render :action => "show", :layout => "base_projects"#by young else - @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page - @replies = @topic.children. - includes(:author, :attachments, {:board => :project}). - reorder("#{Message.table_name}.created_on DESC"). - limit(@reply_pages.per_page). - offset(@reply_pages.offset). - all + # @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page + # @replies = @topic.children. + # includes(:author, :attachments, {:board => :project}). + # reorder("#{Message.table_name}.created_on DESC"). + # limit(@reply_pages.per_page). + # offset(@reply_pages.offset). + # all - @reply = Message.new(:subject => "RE: #{@message.subject}") @organization = @org_subfield.organization render :action => "show", :layout => "base_org"#by young end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8b5b594bd..511266ba1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3246,7 +3246,12 @@ end #获取所有子节点 def get_all_children result, jour - if (jour.kind_of? JournalsForMessage) || (jour.kind_of? Message) || (jour.kind_of? BlogComment) || (jour.kind_of? OrgDocumentComment) + if jour.kind_of? JournalsForMessage + jour.children.includes(:author, :praise_tread_cache).each do |jour_child| + result << jour_child + get_all_children result, jour_child + end + elsif (jour.kind_of? Message) || (jour.kind_of? BlogComment) || (jour.kind_of? OrgDocumentComment) jour.children.each do |jour_child| result << jour_child get_all_children result, jour_child diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index 8959e9c29..6290840a3 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -12,6 +12,8 @@ class BlogComment < ActiveRecord::Base belongs_to :last_reply, :class_name => 'BlogComment', :foreign_key => 'last_comment_id' # 虚拟关联 has_many :user_acts, :class_name => 'UserAcivity',:as =>:act + has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + has_one :praise_tread_cache, as: :object, dependent: :destroy acts_as_watchable validates_presence_of :title, :content diff --git a/app/models/comment.rb b/app/models/comment.rb index 633c9a825..27a917b93 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -27,6 +27,8 @@ class Comment < ActiveRecord::Base has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy #end + has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + has_one :praise_tread_cache, as: :object, dependent: :destroy acts_as_event :datetime => :updated_on, :description => :comments, :type => 'news', diff --git a/app/models/contest.rb b/app/models/contest.rb index 650e363a8..4fbd5441e 100644 --- a/app/models/contest.rb +++ b/app/models/contest.rb @@ -13,6 +13,7 @@ class Contest < ActiveRecord::Base has_many :join_in_competitions, foreign_key: 'competition_id', :dependent => :destroy has_many :join_in_contests, class_name: 'JoinInCompetition', foreign_key: 'competition_id', :dependent => :destroy has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + has_one :praise_tread_cache, as: :object, dependent: :destroy has_many :contestnotifications, :dependent => :destroy, :include => :author diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 7a082cecf..dfff273a0 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -19,6 +19,8 @@ class HomeworkCommon < ActiveRecord::Base has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表 has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :apply_homeworks, :dependent => :destroy + has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + has_one :praise_tread_cache, as: :object, dependent: :destroy has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy #用户活动 # 课程动态 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy diff --git a/app/models/issue.rb b/app/models/issue.rb index 222a4f4e2..9c3c8d168 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -53,6 +53,7 @@ class Issue < ActiveRecord::Base has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy # end has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + has_one :praise_tread_cache, as: :object, dependent: :destroy # ForgeMessage虚拟关联(多态) has_many :forge_messages, :class_name => 'ForgeMessage',:as =>:forge_message ,:dependent => :destroy diff --git a/app/models/journal.rb b/app/models/journal.rb index f22015f47..f14484a31 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -35,6 +35,8 @@ class Journal < ActiveRecord::Base # 被ForgeMessage虚拟关联 has_many :forge_messages, :class_name => 'ForgeMessage',:as =>:forge_message ,:dependent => :destroy has_many :at_messages, as: :at_message, dependent: :destroy + has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + has_one :praise_tread_cache, as: :object, dependent: :destroy acts_as_attachable attr_accessor :indice acts_as_tree :counter_cache => :comments_count, :order => "#{Journal.table_name}.created_on ASC" diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 68cb9da15..30d8120ef 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -68,6 +68,8 @@ class JournalsForMessage < ActiveRecord::Base has_many :user_feedback_messages, :class_name => 'UserFeedbackMessage', :as =>:journals_for_message, :dependent => :destroy has_many :at_messages, as: :at_message, dependent: :destroy + has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + has_one :praise_tread_cache, as: :object, dependent: :destroy validates :notes, presence: true, if: :is_homework_jour? after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, diff --git a/app/models/memo.rb b/app/models/memo.rb index ee9f4c8db..793d534d4 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -48,6 +48,8 @@ class Memo < ActiveRecord::Base acts_as_attachable has_many :user_score_details, :class_name => 'UserScoreDetails',:as => :score_changeable_obj has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + has_one :praise_tread_cache, as: :object, dependent: :destroy + # 消息 has_many :memo_messages, :class_name =>'MemoMessage', :dependent => :destroy # end diff --git a/app/models/message.rb b/app/models/message.rb index 14add0d02..3192907fe 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -26,6 +26,7 @@ class Message < ActiveRecord::Base belongs_to :board,:touch => true belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + has_one :praise_tread_cache, as: :object, dependent: :destroy # has_many :org_subfield_messages, :dependent => :destroy # has_many :org_subfields, :through => :org_subfield_messages diff --git a/app/models/news.rb b/app/models/news.rb index 58bbc40ac..0a893e34e 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -40,6 +40,9 @@ class News < ActiveRecord::Base has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy #end + has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + has_one :praise_tread_cache, as: :object, dependent: :destroy + #转发表 has_many :forwards, :as => :from, :dependent => :destroy diff --git a/app/models/org_document_comment.rb b/app/models/org_document_comment.rb index dd7734a54..a87fe783f 100644 --- a/app/models/org_document_comment.rb +++ b/app/models/org_document_comment.rb @@ -6,6 +6,8 @@ class OrgDocumentComment < ActiveRecord::Base belongs_to :organization belongs_to :creator, :class_name => 'User', :foreign_key => 'creator_id' has_many :editor_of_documents, :dependent => :destroy + has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + has_one :praise_tread_cache, as: :object, dependent: :destroy acts_as_tree :order => "#{OrgDocumentComment.table_name}.sticky asc, #{OrgDocumentComment.table_name}.created_at desc" acts_as_attachable has_many :org_acts, :class_name => 'OrgActivity',:as =>:org_act ,:dependent => :destroy diff --git a/app/models/praise_tread_cache.rb b/app/models/praise_tread_cache.rb index 739b45876..27f4104fc 100644 --- a/app/models/praise_tread_cache.rb +++ b/app/models/praise_tread_cache.rb @@ -1,6 +1,7 @@ class PraiseTreadCache < ActiveRecord::Base attr_accessible :object_id,:object_type,:praise_num,:tread_num - + belongs_to :object, :polymorphic => true + def plus(flag,num) case flag when 0 diff --git a/app/models/syllabus.rb b/app/models/syllabus.rb index 0c23c1b13..f72463503 100644 --- a/app/models/syllabus.rb +++ b/app/models/syllabus.rb @@ -10,6 +10,8 @@ class Syllabus < ActiveRecord::Base has_many :courses has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :syllabus_members, :dependent => :destroy + has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + has_one :praise_tread_cache, as: :object, dependent: :destroy attr_accessible :description, :user_id, :title, :eng_name, :syllabus_type, :credit, :hours, :theory_hours, :practice_hours, :applicable_major, :pre_course safe_attributes 'title','user', 'description', 'eng_name', 'syllabus_type', 'credit', 'hours', 'theory_hours', 'practice_hours', 'credit', 'applicable_major', 'pre_course' diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index 95c9b7df1..abdeef255 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -93,10 +93,10 @@
    - <% all_comments = []%> - <% comments = get_all_children(all_comments, @topic) %> + <%# all_comments = []%> + <%# comments = get_all_children(all_comments, @topic) %>
    - <% comments.each_with_index do |reply,i| %> + <% @replies.each do |reply| %>