Merge branch 'weixin_guange' of https://git.trustie.net/jacknudt/trustieforge into weixin_guange

This commit is contained in:
yuanke 2016-08-12 15:38:39 +08:00
commit a8dda970c4
1 changed files with 184 additions and 181 deletions

View File

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