parent
c248249983
commit
b010ce2e61
@ -1 +1 @@
|
|||||||
{"access_token":"oEEf8ZKAB8Y2G0o_xnTPkPJHKKk8iHkLC-f5ptvQ2nCMj9IpC86ivLD2-p38GfOkuG-HuQp3pWZqhs3NJXUMdPLWsr5k67hPZYuqg4ozLccx0xdLswapj0mn8ovZhK1tKIKiAFAOMO","expires_in":7200,"got_token_at":1467012449}
|
{"access_token":"m8kGwb7G0laM6-0uHmPtxETR6WJk5PgR37te_h8aBwgqGXkml2ZZAvPUBldmzF5hDZsQBHEn8PUACSL60eDKlCWigwwUJReK2wB4UbXIc1UA-rrkpHuWl84H3rcswtlvHENjAHAZWF","expires_in":7200,"got_token_at":1467472907}
|
@ -0,0 +1,53 @@
|
|||||||
|
#coding=utf-8
|
||||||
|
|
||||||
|
class ResourcesService
|
||||||
|
|
||||||
|
#发送资源到课程
|
||||||
|
def send_resource_to_course params
|
||||||
|
send_id = params[:send_id]
|
||||||
|
@ori = Attachment.find_by_id(send_id)
|
||||||
|
course_ids = params[:course_ids]
|
||||||
|
@flag = false
|
||||||
|
unless course_ids.nil?
|
||||||
|
course_ids.each do |id|
|
||||||
|
next if @ori.blank?
|
||||||
|
@exist = false
|
||||||
|
Course.find(id).attachments.each do |att| #如果课程中包含该资源
|
||||||
|
if att.id == @ori.id || (!att.copy_from.nil? && !@ori.copy_from.nil? && att.copy_from == @ori.copy_from) || att.copy_from == @ori.id || att.id == @ori.copy_from
|
||||||
|
att.created_on = Time.now
|
||||||
|
att.save
|
||||||
|
@exist = true
|
||||||
|
@flag = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
next if @exist
|
||||||
|
attach_copied_obj = @ori.copy
|
||||||
|
attach_copied_obj.tag_list.add(@ori.tag_list) # tag关联
|
||||||
|
attach_copied_obj.container = Course.find(id)
|
||||||
|
attach_copied_obj.created_on = Time.now
|
||||||
|
attach_copied_obj.author_id = User.current.id
|
||||||
|
attach_copied_obj.is_public = 0
|
||||||
|
attach_copied_obj.copy_from = @ori.copy_from.nil? ? @ori.id : @ori.copy_from #发送要添加copy_from
|
||||||
|
if attach_copied_obj.attachtype == nil
|
||||||
|
attach_copied_obj.attachtype = 4
|
||||||
|
end
|
||||||
|
if attach_copied_obj.save
|
||||||
|
# 更新引用次数
|
||||||
|
quotes = @ori.quotes.to_i + 1
|
||||||
|
@ori.update_attribute(:quotes, quotes) unless @ori.nil?
|
||||||
|
@ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
|
||||||
|
@flag = true
|
||||||
|
else
|
||||||
|
@flag = false
|
||||||
|
@save_message = attach_copied_obj.errors.full_messages
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
[@ori, @flag, @save_message]
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
<div class="post-container">
|
||||||
|
<div loading-spinner></div>
|
||||||
|
|
||||||
|
<div class="blue-title">发送课程列表</div>
|
||||||
|
<div class="course-list-row f13 c-grey3 mt10"><img src="/images/wechat/plus.png" width="15" class="fl ml10 mt11 spread-btn undis" /><img src="/images/wechat/minus.png" width="15" class="fl ml10 mt11 retract-btn " /><span class="fl ml10">未命名课程</span></div>
|
||||||
|
<ul class="class-list f13 c-grey3">
|
||||||
|
<li ng-click="selectCourse(course)" ng-class="{'border-bottom-none': $last }" ng-repeat="course in courses"><img src="/images/wechat/dot.png" width="15px" class="class-list-dot" /><span class="fl ml10 class-list-name hidden">{{course.name}}</span><span ng-class="['login-box', 'fr', 'mr5', 'mt12', {'checked': course.checked}]"></span></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div class="btn2 bg-blue" ng-click="sendToCourses()">发送</div>
|
||||||
|
<my-alert message="alertService.message" title="alertService.title" visible="alertService.visible" cb="alertService.cb"></my-alert>
|
||||||
|
</div>
|
@ -0,0 +1,21 @@
|
|||||||
|
<!-- loading toast -->
|
||||||
|
<div id="loadingToast" class="weui_loading_toast" ng-show="activeCalls>0">
|
||||||
|
<div class="weui_mask_transparent"></div>
|
||||||
|
<div class="weui_toast">
|
||||||
|
<div class="weui_loading">
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_0"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_1"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_2"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_3"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_4"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_5"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_6"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_7"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_8"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_9"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_10"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_11"></div>
|
||||||
|
</div>
|
||||||
|
<p class="weui_toast_content">数据加载中</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -1,12 +1,12 @@
|
|||||||
|
|
||||||
|
|
||||||
app.controller('NewClassController', ['$scope', '$http', 'auth', 'config', function($scope, $http, auth, config){
|
app.controller('NewClassController', ['$scope', '$http', 'auth', 'config', 'alertService', function($scope, $http, auth, config, alertService){
|
||||||
var vm = $scope;
|
var vm = $scope;
|
||||||
|
|
||||||
vm.resources = [];
|
vm.alertService = alertService.create();
|
||||||
vm.homeworks = [];
|
|
||||||
vm.exercises = [];
|
|
||||||
|
|
||||||
|
|
||||||
|
vm.newClass = function () {
|
||||||
|
vm.alertService.showMessage('提示', '此功能正在开发中');
|
||||||
|
}
|
||||||
|
|
||||||
}] );
|
}] );
|
@ -0,0 +1,47 @@
|
|||||||
|
app.controller('SendClassListController', ['$scope', '$http','$routeParams', 'config','auth','alertService', function($scope, $http, $routeParams, config, auth, alertService){
|
||||||
|
var vm = $scope;
|
||||||
|
var send_id = $routeParams.id;
|
||||||
|
|
||||||
|
vm.alertService = alertService.create();
|
||||||
|
vm.courses = [];
|
||||||
|
|
||||||
|
var loadClassList = function () {
|
||||||
|
$http.get(config.apiUrl + "courses?token=" + auth.token() + "&per_page_count=10&page=1").then(
|
||||||
|
function (response) {
|
||||||
|
console.log(response.data);
|
||||||
|
vm.courses = response.data.data;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
loadClassList();
|
||||||
|
|
||||||
|
vm.selectCourse = function(course){
|
||||||
|
if( typeof course.checked !== 'boolean' ) course.checked = false;
|
||||||
|
course.checked = !course.checked;
|
||||||
|
}
|
||||||
|
|
||||||
|
vm.sendToCourses = function(){
|
||||||
|
var course_ids = [];
|
||||||
|
|
||||||
|
for(var i in vm.courses){
|
||||||
|
if(vm.courses[i].checked){
|
||||||
|
course_ids.push(vm.courses[i].id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$http.post(config.apiUrl + "resources/send", {
|
||||||
|
token: auth.token(), course_ids: course_ids, send_id: send_id
|
||||||
|
}).then(function(response){
|
||||||
|
console.log(response.data);
|
||||||
|
if(response.data.status == 0){
|
||||||
|
vm.alertService.showMessage('提示', '发送成功', function () {
|
||||||
|
window.history.back();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
vm.alertService.showMessage('发送出错', response.data.message);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}]);
|
@ -1,7 +1,5 @@
|
|||||||
app.directive('loadingSpinner', ['$http', function ($http) {
|
app.directive('loadingSpinner', ['$http', 'config', function ($http, config) {
|
||||||
return {
|
return {
|
||||||
restrict: 'A',
|
templateUrl: config.rootPath+ 'templates/loading.html',
|
||||||
replace: true,
|
|
||||||
template: '<div ng-show="activeCalls>0" class="loading-bg"><div class="loading-box"><img src="/images/loading.gif" alt=""/><span>加载中...</span></div></div>',
|
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
|
Loading…
Reference in new issue