unserver-unify
Version:
91 lines (84 loc) • 2.6 kB
JavaScript
;
angular.module('bamboo.common').controller('UserExamTestRecordsCtrl', function($scope, loginService, CourseApi, $stateParams, $state, CommonService, ApiService) {
var self = this;
this.userrecords = [];
var userdata = [];
this.id = $stateParams.id;
console.log(loginService.user);
function examApi(info, callback) {
ApiService.post('/exam', info).then(function(result) {
if (result.data.success) {
if (!callback) {
CommonService.showNoBlockSuccess('Update Successful!');
} else {
callback(result.data.data);
}
}
});
}
this.deleteRecord = function(id) {
CommonService.showDeleteConfirm(function() {
var info = {
action: "delpaperrecords",
id: id
};
examApi(info, function(data) {
CommonService.showNoBlockSuccess('Update Successful!');
$state.reload();
//console.log(data);
});
});
};
this.examquestion = {};
this.examresult = {};
this.getRecord = function(tableState) {
// console.log("getrecord")
// console.log(tableState);
var limit =parseInt( tableState.pagination.number || self.itemNumber);
var start = tableState.pagination.start;
var search = tableState.search.predicateObject;
var info = {
start: start,
limit: limit,
sort: tableState.sort,
// search: search,
action: "getuserexamrecords",
uid: loginService.user.name,
};
console.log(info);
examApi(info, function(data) {
console.log(data.items);
$scope.userrecords = data.items;
self.totalrecords=data.counter;
tableState.pagination.numberOfPages = Math.ceil(data.counter / limit);
});
}
this.reportFlag;
this.secondsToTime = function(secs) {
var sec_num = parseInt(secs, 10); // don't forget the second param
var hours = Math.floor(sec_num / (60 * 60));
var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
var seconds = sec_num - (hours * 3600) - (minutes * 60);
if (hours < 10) {
hours = "0" + hours;
}
if (minutes < 10) {
minutes = "0" + minutes;
}
if (seconds < 10) {
seconds = "0" + seconds;
}
var time = hours + ':' + minutes + ':' + seconds;
return time;
};
initActionFlag();
function initActionFlag(){
$scope.actionFlag = true;
switch(loginService.subDomain){
case "sgpower":
$scope.actionFlag = false;
break;
default: break;
}
}
});