UNPKG

unserver-unify

Version:

88 lines (85 loc) 2.6 kB
'use strict'; angular.module('bamboo.course').controller('CourseExamCtrl', function($scope, ApiService, CourseApi, $state, $stateParams) { this.id = $scope.id = $stateParams.id; this.cid = $stateParams.cid; this.mvsubject = {}; var _self = this; $scope.imageUrl = ApiService.SHOST + '/examphoto/' + ApiService.gid + '/'; $scope.appUrl = ApiService.APPURL; console.log($state.current.name); $scope.tabs = 'exam'; var counterlist = []; var _cindex = 0; var loopstart = false; var examtestids = []; var counterready = false; var examready = false; var testready = false; var examidscounter = {}; this.showexam=true; this.getexamitems = function(tableState) { var limit = tableState.pagination.number; var start = tableState.pagination.start; var info = { cid: _self.cid, start: start, limit: limit, sort: tableState.sort, action: "getuserpublishexamsforcourse", } console.log(info); CourseApi.lcApi(info, function(data) { // console.log(data); if (!data || !data.counter) { _self.showexam = false; } $scope.examitems = data.items; _self.total=data.counter; // console.log($scope.examitems); tableState.pagination.numberOfPages = Math.ceil(data.counter / limit); }); } function getInfo() { CourseApi.getInfo(_self.id, function(_result) { _self.mvsubject = _result; }) /* var info = { cid: _self.cid, action: "getcourseexamlist", } console.log(info); CourseApi.lcApi(info, function(data) { console.log(data); $scope.examitems = data.exams; $scope.testitems = data.tests; });*/ var info = { cid: _self.cid, id: _self.id, action: "getsectionexamlist", } console.log(info); CourseApi.lcApi(info, function(data) { console.log(data); $scope.assignmentitems = data.assignments; var ids = []; angular.forEach($scope.assignmentitems, function(item) { ids.push(item._id); }) var ascounterinfo = { ids: ids, action: "getmyassignmentstatus", } console.log(ids); ApiService.post('/exam', ascounterinfo).then(function(result) { if (result.data.success) { console.log(result.data); $scope.assignmentcounter = result.data.data; // $scope.assignmentitems = result.data.data; } }); $scope.chapterexams = data.chapterexams; }) } getInfo(); });