我的资源里面都显示未发布的,新建课程后返回会刷新数据

This commit is contained in:
yuanke 2016-07-11 14:49:59 +08:00
parent 99a27766be
commit 374aa9918c
3 changed files with 47 additions and 5 deletions

View File

@ -11,7 +11,9 @@ module Mobile
end
get do
authenticate!
data = current_user.course_attachments
rs = ResourcesService.new
# data = current_user.course_attachments
data = rs.all_course_attachments current_user
present :data, data, with: Mobile::Entities::Attachment
present :status, 0
@ -26,7 +28,8 @@ module Mobile
get 'homeworks' do
authenticate!
homeworks = current_user.homework_commons
rs = ResourcesService.new
homeworks = rs.all_homework_commons current_user
present :data, homeworks, with: Mobile::Entities::Homework
present :status, 0
@ -40,7 +43,8 @@ module Mobile
get 'exercies' do
authenticate!
exercises = current_user.exercises
rs = ResourcesService.new
exercises = rs.all_exercises current_user
present :data, exercises, with: Mobile::Entities::Exercise
present :status, 0
end

View File

@ -50,4 +50,40 @@ class ResourcesService
[@ori, @flag, @save_message]
end
# 我的资源-课件 已发布的
def all_course_attachments user
courses = user.courses.not_deleted
courses_ids = courses.empty? ? '(-1)' :"(" + courses.map(&:id).join(",") + ")"
attchments = Attachment.where("(author_id = #{user.id} and is_publish = 1 and container_id in #{courses_ids} and container_type = 'Course') or (container_type = 'Course' and is_publish = 1 and container_id in #{courses_ids})" ).order("created_on desc")
attchments
end
# 我的资源-作业 已发布的
def all_homework_commons user
courses = user.courses.not_deleted
courses_ids = courses.empty? ? '(-1)' :"(" + courses.map(&:id).join(",") + ")"
homeworks = HomeworkCommon.where("course_id in #{courses_ids} and publish_time <= ?",Time.now.strftime("%Y-%m-%d")).order("created_at desc")
homeworks
end
# 我的资源-测验 已发布的
def all_exercises user
courses = user.courses.not_deleted
courses_ids = courses.empty? ? '(-1)' :"(" + courses.map(&:id).join(",") + ")"
exercises = Exercise.where("exercise_status <> 1 and course_id in #{courses_ids}").order("created_at desc")
exercises
end
end

View File

@ -1,6 +1,6 @@
app.controller('NewClassController', ['$scope', '$http', 'auth', 'config', 'alertService','$location', function($scope, $http, auth, config, alertService, $location){
app.controller('NewClassController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','rms', function($scope, $http, auth, config, alertService, $location,rms){
var vm = $scope;
vm.alertService = alertService.create();
@ -40,7 +40,9 @@ app.controller('NewClassController', ['$scope', '$http', 'auth', 'config', 'aler
vm.alertService.showMessage('出错了', response.data.message);
} else {
vm.alertService.showMessage('提示', '新建课程成功', function(){
window.history.back();
// window.history.back();
rms.save('syllabuses',[]);
$location.path("/class_list");
});
}
console.log(response.data.data);