班级邀请码弹框修改,我的动态回复数计算修改

This commit is contained in:
yuanke 2016-07-19 10:50:36 +08:00
parent b2f9839d13
commit bc1b4c1b85
14 changed files with 97 additions and 36 deletions

View File

@ -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

View File

@ -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?

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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])

View File

@ -36,5 +36,6 @@
<a ng-click="goResource()" href="javascript:void(0);" class="weixin-tab link-blue2 border-top">我的资源</a>
</div>
<my-alert message="alertService.message" title="alertService.title" visible="alertService.visible" cb="alertService.cb"></my-alert>
<my-alert message="alertService_1.message" title="alertService_1.title" visible="alertService_1.visible" cb="alertService_1.cb"></my-alert>
<my-alert3 message="alertService_3.message" title="alertService_3.title" visible="alertService_3.visible" cb="alertService_3.cb" invite="alertService_3.invite" ></my-alert3>
</div>

View File

@ -20,6 +20,7 @@
</div>
<p ng-show="resources_tag && resources.length<=0" class="class-test-tip">暂无课件,<br />
请登录Trustie网站在PC浏览器中上传课件。</p>
</div>
<div ng-class="{'undis': currentTab!=2}">
<div ng-repeat="r in homeworks|filter:{homework_name: searchText}" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/homework.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.homework_name}}</span><a ng-show="r.current_user_is_teacher" ng-click="sendFile(r,2)" class="fr mr10 link-blue2 ">发送</a><div class="cl"></div>

View File

@ -0,0 +1,15 @@
<div class="post-container" ng-show="visible">
<div class="weui_mask">
<div class="add-class-box">
<p class="tac add-class-tip">{{message}}</p>
<form class="mb20">
<input type="text" class="class-number-input" ng-model="invite" />
</form>
<a href="javascript:void(0);" class="c-grey4 fl cancel-btn" ng-click="dismiss()" >取消</a>
<div class="slice fl">
<div class="slice-line"></div>
</div>
<a href="javascript:void(0);" class="c-blue fl submit-btn" ng-click="confirm()" >确定</a>
</div>
</div>
</div>

View File

@ -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) {

View File

@ -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();
}
}
}
}
}]);

View File

@ -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();}
}