unserver-unify
Version:
58 lines (55 loc) • 1.73 kB
JavaScript
;
angular.module('bamboo.mystudy').controller('ClassAssignmentRecordsCtrl', function($scope, ApiService, $uibModal, $stateParams, CommonService) {
this.id = $stateParams.aid;
var self = this;
function examApi(info, callback) {
ApiService.post('/exam', info).then(function(result) {
console.log(result);
if (result.data.success) {
if (!callback) {
CommonService.showNoBlockSuccess('Update Successful!');
} else {
callback(result.data.data);
}
}
});
}
this.review = function(id) {
$uibModal.open({
templateUrl: 'app/mystudy/assignment/record-dlg.html',
controller: 'RecordViewingDlgCtrl',
backdrop: 'static',
size: 'lg',
controllerAs: 'ctrl',
resolve: {
id: function() {
return id;
},
}
})
}
this.getRecords = function(tableState) {
var limit = parseInt(tableState.pagination.number || 10);
var start = tableState.pagination.start;
var search = tableState.search.predicateObject;
var info = {
start: start,
limit: limit,
sort: tableState.sort,
aid: self.id,
action: 'getclassmatesassignmentrecords',
};
console.log(info);
examApi(info, function(data) {
console.log(data)
self.counter = data.counter;
angular.forEach(data.items, function(item) {
var author = item.author || {};
item.author_url = CommonService.getAvatarSrc(author);
})
$scope.userrecords = data.items;
self.totalrecords = data.counter;
tableState.pagination.numberOfPages = Math.ceil(data.counter / limit);
});
}
});