2016-08-12 15:34:53 +08:00
|
|
|
app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams','alertService','rms','common', function($scope, config, $http, auth, $location, $routeParams,alertService,rms,common){
|
|
|
|
common.checkLogin();
|
|
|
|
|
|
|
|
var vm = $scope;
|
|
|
|
var courseid = $routeParams.id;
|
|
|
|
var tag = $routeParams.tag;
|
|
|
|
|
|
|
|
|
|
|
|
var getUsers = function(){
|
|
|
|
if(vm.teachers.length<=0){
|
|
|
|
$http.get(config.apiUrl + 'courses/teachers?token='+auth.token()+'&course_id='+courseid).then(
|
|
|
|
function(response) {
|
|
|
|
console.log(response.data);
|
|
|
|
vm.teachers = response.data.data;
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
if(vm.course.is_creator){
|
|
|
|
if(vm.reviewers.length<=0){
|
|
|
|
$http.get(config.apiUrl + 'courses/reviewers?token='+auth.token()+'&course_id='+courseid).then(
|
|
|
|
function(response) {
|
|
|
|
console.log(response.data);
|
|
|
|
vm.reviewers = response.data.data;
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(vm.students.length<=0){
|
|
|
|
$http.get(config.apiUrl + 'courses/students?token='+auth.token()+'&course_id='+courseid).then(
|
|
|
|
function(response) {
|
|
|
|
console.log(response.data);
|
|
|
|
vm.students = response.data.data;
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var getResources = function(){
|
|
|
|
if(vm.resources.length<=0){
|
|
|
|
$http.post(config.apiUrl + "courses/"+courseid+"/attachments",
|
|
|
|
{token: auth.token(), name: ''}
|
|
|
|
).then(function(response){
|
|
|
|
vm.resources = response.data.data;
|
|
|
|
vm.resources_tag = true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var getHomeworks = function(){
|
|
|
|
if(vm.homeworks.length <=0){
|
|
|
|
$http.get(config.apiUrl + "courses/homeworks/"+courseid+"?token="+auth.token()).then(function(response){
|
|
|
|
vm.homeworks = response.data.data;
|
|
|
|
console.log(response.data);
|
|
|
|
vm.homeworks_tag = true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var getExercises = function(){
|
|
|
|
if(vm.exercises.length <=0){
|
|
|
|
$http.get(config.apiUrl + "courses/"+courseid+"/exercises?token="+auth.token()).then(function(response){
|
|
|
|
vm.exercises = response.data.data;
|
|
|
|
console.log(response.data);
|
|
|
|
vm.exercises_tag = true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
vm.isTeacher = false;
|
|
|
|
vm.currentTab = 1;
|
|
|
|
vm.tab = function(index){
|
|
|
|
vm.currentTab = index;
|
|
|
|
vm.searchText = '';
|
|
|
|
|
|
|
|
vm.showClassMate = false;
|
|
|
|
vm.showResources = false;
|
|
|
|
vm.showHomework = false;
|
|
|
|
vm.showTestcase = false;
|
|
|
|
vm.resources_tag = false;
|
|
|
|
vm.homeworks_tag = false;
|
|
|
|
vm.exercises_tag = false;
|
|
|
|
|
|
|
|
if(vm.isTeacher){
|
|
|
|
if(index == 1){ //课件
|
|
|
|
getResources();
|
|
|
|
vm.showResources = true;
|
|
|
|
} else if(index==2){ //作业
|
|
|
|
getHomeworks();
|
|
|
|
vm.showHomework = true;
|
|
|
|
} else if(index==3){ //小测验
|
|
|
|
getExercises();
|
|
|
|
vm.showTestcase = true;
|
|
|
|
} else if(index==4){ //学生管理
|
|
|
|
getUsers();
|
|
|
|
vm.showClassMate = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if(index == 2){
|
|
|
|
getUsers();
|
|
|
|
vm.showClassMate = true;
|
|
|
|
} else if(index==1){
|
|
|
|
getResources();
|
|
|
|
vm.showResources = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rms.save("tab_num",index);
|
|
|
|
}
|
|
|
|
|
|
|
|
vm.tabRecord = rms.get('tab_num') || 1;
|
|
|
|
|
|
|
|
vm.course = {};
|
|
|
|
vm.students = [];
|
|
|
|
vm.teachers = [];
|
|
|
|
vm.reviewers = []; //待审批
|
|
|
|
vm.resources = [];
|
|
|
|
vm.homeworks = [];
|
|
|
|
vm.exercises = [];
|
|
|
|
|
|
|
|
//发送类别 1课件 2作业 3测验
|
|
|
|
vm.myresource_sendIndex = rms.get('myresource_sendIndex') || 1;
|
|
|
|
|
|
|
|
vm.alertService = alertService.create();
|
|
|
|
|
|
|
|
vm.invite = function(){
|
|
|
|
$location.path("/invite_code").search({id: courseid});
|
|
|
|
};
|
|
|
|
|
|
|
|
vm.sendFile = function(r,index){
|
|
|
|
vm.myresource_sendIndex = index;
|
|
|
|
rms.save('myresource_sendIndex',index);
|
|
|
|
$location.path("/send_class_list").search({id: r.id});
|
|
|
|
}
|
|
|
|
|
|
|
|
$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;
|
|
|
|
resetMenu(vm.course.current_user_is_teacher,vm.tabRecord);
|
|
|
|
if(tag){
|
|
|
|
vm.tab(4);
|
|
|
|
tag = null;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
vm.tab(vm.tabRecord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
vm.alertService.showMessage('提示', response.data.message);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
var resetMenu = function(is_teacher){
|
|
|
|
vm.isTeacher = is_teacher;
|
|
|
|
if(is_teacher){
|
|
|
|
vm.menus = ["课件", "作业", "测验", "成员管理"];
|
|
|
|
} else {
|
|
|
|
vm.menus = ['课件', "我的同学"];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
vm.onSetting = function(user){
|
|
|
|
rms.save('current_edit_member', user);
|
|
|
|
$location.path("/edit_class_member").search({id: courseid,user_id: user.id});
|
|
|
|
};
|
|
|
|
|
|
|
|
vm.review = function(user){
|
|
|
|
rms.save('current_review_member', user);
|
|
|
|
rms.save('current_course', vm.course);
|
|
|
|
|
|
|
|
$location.path("/review_class_member").search({id: courseid,user_id: user.id});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-06-20 19:42:51 +08:00
|
|
|
}]);
|