diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 1c6fd7008..60e00280e 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -397,7 +397,7 @@ module Mobile authenticate! course = Course.find(params[:course_id]) - exercises = course.exercises.where("exercise_status <> 1").order("created_at desc") + exercises = course.exercises.where("exercise_status <> 1").reorder("created_at desc") present :data,exercises,with:Mobile::Entities::Exercise,user: current_user present :status,0 end diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index 9e2a39a5a..bdeff7ae9 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -20,15 +20,17 @@ module Mobile ac.act unless ac.nil? || ac.act.nil? end when :reply_count - if ac.act_type == "HomeworkCommon" - ac.nil? || ac.act.nil? ? 0 : ac.act.journals_for_messages.count - elsif ac.act_type == "News" - ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count - elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" - ac.nil? || ac.act.nil? ? 0 : ac.act.children.count - elsif ac.act_type == "Issue" - ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count - end + # if ac.act_type == "HomeworkCommon" + # ac.nil? || ac.act.nil? ? 0 : ac.act.journals_for_messages.count + # elsif ac.act_type == "News" + # ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count + # elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" + # ac.nil? || ac.act.nil? ? 0 : ac.act.children.count + # elsif ac.act_type == "Issue" + # ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count + # end + all_comments = [] + ac.nil? || ac.act.nil? ? 0 : get_all_children(all_comments, ac.act).count when :subject if ac.act_type == "HomeworkCommon" ac.act.name unless ac.nil? || ac.act.nil? diff --git a/app/api/mobile/entities/blog_comment.rb b/app/api/mobile/entities/blog_comment.rb index 67904d11e..a61864900 100644 --- a/app/api/mobile/entities/blog_comment.rb +++ b/app/api/mobile/entities/blog_comment.rb @@ -25,7 +25,9 @@ module Mobile when :act_id u.id when :comment_count - u.children.count + # u.children.count + all_comments = [] + get_all_children(all_comments, u).count end end end diff --git a/app/api/mobile/entities/issue.rb b/app/api/mobile/entities/issue.rb index ef3d09450..b99ea03a5 100644 --- a/app/api/mobile/entities/issue.rb +++ b/app/api/mobile/entities/issue.rb @@ -23,7 +23,9 @@ module Mobile when :issue_status IssueStatus.find(issue.status_id).name when :journals_count - issue.journals.where("notes is not null and notes != ''").count + # issue.journals.where("notes is not null and notes != ''").count + all_comments = [] + get_all_children(all_comments, f).count when :project_name issue.project.name when :praise_count diff --git a/app/api/mobile/entities/jours.rb b/app/api/mobile/entities/jours.rb index 15e22174c..f98d7a9ed 100644 --- a/app/api/mobile/entities/jours.rb +++ b/app/api/mobile/entities/jours.rb @@ -18,7 +18,9 @@ module Mobile when :lasted_comment time_from_now f.created_on when :reply_count - f.children.count + # f.children.count + all_comments = [] + get_all_children(all_comments, f).count when :praise_count get_activity_praise_num(f) when :act_type diff --git a/app/api/mobile/entities/message.rb b/app/api/mobile/entities/message.rb index 051c92886..d58192378 100644 --- a/app/api/mobile/entities/message.rb +++ b/app/api/mobile/entities/message.rb @@ -30,6 +30,9 @@ module Mobile 'Message' when :act_id u.id + when :replies_count + all_comments = [] + get_all_children(all_comments, u).count end end end diff --git a/app/api/mobile/entities/news.rb b/app/api/mobile/entities/news.rb index 4f973d82e..ff1452b1c 100644 --- a/app/api/mobile/entities/news.rb +++ b/app/api/mobile/entities/news.rb @@ -24,6 +24,9 @@ module Mobile 'News' when :act_id f.id + when :comments_count + all_comments = [] + get_all_children(all_comments, f).count end end elsif f.is_a?(Hash) && !f.key?(field) diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 39c77de4b..091e2749e 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -392,7 +392,7 @@ class CoursesService def homework_list params,current_user course = Course.find(params[:id]) if course.is_public != 0 || current_user.member_of_course?(course) - bids = course.homework_commons.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).page(params[:page] || 1).per(20).order('created_at DESC') + bids = course.homework_commons.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).page(params[:page] || 1).per(20).reorder('created_at DESC') bids = bids.like(params[:name]) if params[:name].present? homeworks = [] bids.each do |bid| @@ -495,7 +495,7 @@ class CoursesService def course_attachments params result = [] course = Course.find(params[:course_id]) - attachments = course.attachments.where("is_publish = 1").order("created_on desc") + attachments = course.attachments.where("is_publish = 1").reorder("created_on desc") if !params[:name].nil? && params[:name] != "" attachments.each do |atta| result << atta if atta.filename.include?(params[:name]) diff --git a/public/assets/wechat/class_list.html b/public/assets/wechat/class_list.html index a3c709cb5..d0074f343 100644 --- a/public/assets/wechat/class_list.html +++ b/public/assets/wechat/class_list.html @@ -36,5 +36,6 @@ 我的资源 - + + \ No newline at end of file diff --git a/public/assets/wechat/myresource.html b/public/assets/wechat/myresource.html index c06c57238..90fb13892 100644 --- a/public/assets/wechat/myresource.html +++ b/public/assets/wechat/myresource.html @@ -20,6 +20,7 @@

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

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

{{message}}

+
+ +
+ 取消 +
+
+
+ 确定 +
+
+
\ No newline at end of file diff --git a/public/javascripts/wechat/controllers/class_list.js b/public/javascripts/wechat/controllers/class_list.js index b3f8a6ea3..9e0087135 100644 --- a/public/javascripts/wechat/controllers/class_list.js +++ b/public/javascripts/wechat/controllers/class_list.js @@ -8,7 +8,8 @@ app.controller('ClassListController', ['$scope', 'config', 'auth', '$http', '$lo var vm = $scope; vm.syllabuses = rms.get('syllabuses') || []; - vm.alertService = alertService.create(); + vm.alertService_1 = alertService.create(); + vm.alertService_3 = alertService.create(); var loadClassList = function () { $http.get(config.apiUrl + "syllabuses?token=" + auth.token()).then( @@ -36,7 +37,7 @@ app.controller('ClassListController', ['$scope', 'config', 'auth', '$http', '$lo function (response) { console.log(response.data); if (response.data.auth == 0) { - vm.alertService.showMessage('提示', '非教师身份不能创建课程哦~'); + vm.alertService_1.showMessage('提示', '非教师身份不能创建课程哦~'); } else{ $location.path("/new_class"); @@ -50,26 +51,28 @@ app.controller('ClassListController', ['$scope', 'config', 'auth', '$http', '$lo } vm.joinClass = function () { - var code = window.prompt("请输入5位班级邀请码(不区分大小写)"); - if (code && code.length == 5) { - $http.post(config.apiUrl + "courses/join", { - token: auth.token(), - invite_code: code - }).then(function (response) { - console.log(response.data); - if (response.data.status != 0) { - vm.alertService.showMessage('错误', response.data.message); - } else { - vm.alertService.showMessage('提示', '加入课程成功'); - loadClassList(); + vm.alertService_3.showMessage('提示', '请输入5位班级邀请码(不区分大小写)', function(){ + if (vm.alertService_3.invite && vm.alertService_3.invite.length == 5) { + $http.post(config.apiUrl + "courses/join", { + token: auth.token(), + invite_code: vm.alertService_3.invite + }).then(function (response) { + console.log(response.data); + if (response.data.status != 0) { + vm.alertService_1.showMessage('错误', response.data.message); + } else { + vm.alertService_1.showMessage('提示', '加入课程成功'); + vm.alertService_3.invite = ""; + loadClassList(); + } + }); + } else { + if(vm.alertService_3.invite){ + vm.alertService_1.showMessage('错误', '邀请码格式不正确'); } - }); - } else { - if(code){ - vm.alertService.showMessage('错误', '邀请码格式不正确'); - } - } + } + }); }; vm.onSetting = function (syllabus) { diff --git a/public/javascripts/wechat/directives/alert.js b/public/javascripts/wechat/directives/alert.js index 4b703811c..e9401de34 100644 --- a/public/javascripts/wechat/directives/alert.js +++ b/public/javascripts/wechat/directives/alert.js @@ -40,3 +40,27 @@ app.directive('myAlert2', ['config', function(config){ } } }]); + +app.directive('myAlert3', ['config', function(config){ + return { + templateUrl: config.rootPath+ 'templates/alert3.html', + scope: { + title: "=", + message: "=", + visible: "=", + cb: "=", + invite: "=" + }, + link: function(scope){ + scope.dismiss = function(){ + scope.visible = false; + }; + scope.confirm = function(){ + scope.visible = false; + if(typeof scope.cb === 'function'){ + scope.cb(); + } + } + } + } +}]); diff --git a/public/javascripts/wechat/others/factory.js b/public/javascripts/wechat/others/factory.js index 6c7709df3..2b0d4f994 100644 --- a/public/javascripts/wechat/others/factory.js +++ b/public/javascripts/wechat/others/factory.js @@ -4,6 +4,7 @@ app.factory('alertService', function(){ this.message = null; this.visible = null; this.cb = null; + this.invite = ""; } Alert.prototype.showMessage = function(title, msg, cb){ @@ -11,12 +12,14 @@ app.factory('alertService', function(){ this.title = title; this.visible = true; this.cb = cb; + this.invite = ""; } Alert.prototype.dismiss = function(){ this.message = null; this.title = null; this.visible = false; + this.invite = ""; if(this.cb) {this.cb();} }