Skip to content

Commit

Permalink
feat: 新增上傳排名
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinlinlee committed Jan 30, 2021
1 parent 1052b2a commit 0e429ce
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 11 deletions.
38 changes: 31 additions & 7 deletions views/atm/Scores.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
</div>
</nav>
<div class="container" style="width:100%">
<div dw-loading="DataList" dw-loading-options="{text: '載入清單...'}">
<table id="setting" class="table table-bordered table-striped table-rwd">
<div id="divScore">
<table id="tableScore" class="table table-bordered table-striped table-rwd">
<thead class="thead-dark">
<tr >
<th>課程名稱</th>
Expand Down Expand Up @@ -70,18 +70,21 @@
</tbody>
</table>
</div>
<div dw-loading="Conlist" dw-loading-options="{text: '載入清單...'}">
<table id="setting_2" class="table table-bordered table-striped table-rwd">
<div id="divRank">
<table id="tableRank" class="table table-bordered table-striped table-rwd">
<tbody>
<tr name="Conlist" ng-repeat="Item2 in Conlist">
<td class="no-th">{{Item2.id}}</td>
<td data-th={{Item2.id}}>{{Item2.name}}</td>
</tr>
</tbody>
</table>
<button class="btn btn-success" ng-click="storeRank();">Store Rank Information</button>
</div>
<div dw-loading="PreRank" dw-loading-options="{text: '載入清單...'}">
<table id="setting_2" class="table table-bordered table-striped table-rwd">
<hr>
<!--暫時不顯示-->
<div id="divPreRank" ng-show="false">
<table id="tablePreRank" class="table table-bordered table-striped table-rwd">
<tbody>
<tr name="Conlist" ng-repeat="Item in PreRank">
<td class="no-th">{{Item.name}}</td>
Expand All @@ -90,6 +93,25 @@
</tbody>
</table>
</div>

<div id="divstoredRank" ng-show="storedRank.length > 0 ">
<table id="tablestoredRank" class="table table-bordered table-striped table-rwd">
<thead class="thead-dark">
<tr >
<th>學期</th>
<th>排名</th>
<th>班級排名百分比</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="(key , Item) in storedRank">
<td >{{Item.sem}}</td>
<td >{{Item.rank}}</td>
<td >{{Item.rankPercentInClass}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>

Expand All @@ -110,6 +132,8 @@
window.onload = async function() {
commonFunc.myDarkModeInit();
await sleep(100);
angular.element(document.getElementById('setting')).scope().Query();
angular.element(document.getElementById('divScore')).scope().Query();
angular.element(document.getElementById('divScore')).scope().getStoredRank();

};
</script>
49 changes: 45 additions & 4 deletions views/atm/scripts/Scores.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ScoresApp.controller("ScoresCtrl", function ($scope, ScoresService , commonServi
$scope.DataList = [];
$scope.Conlist = [];
$scope.PreRank = [];
$scope.storedRank = [];
$scope.Currentuser = "";
commonService.user.getStuInfo().then(function (res) {
$scope.Currentuser = res.data;
Expand All @@ -20,22 +21,43 @@ ScoresApp.controller("ScoresCtrl", function ($scope, ScoresService , commonServi
$scope.PreRank = [];
}
else {
var Scores = res.data[0];
let Scores = res.data[0];
$scope.DataList = Scores;
var Scores_Con = res.data[1];
let Scores_Con = res.data[1];
$scope.Conlist = Scores_Con;
$scope.PreRank = res.data[2];
console.log($scope.PreRank);
}
}))
}

$scope.storeRank = function () {
let storeData = {
data : $scope.Conlist
}
ScoresService.postStoreRank(storeData).then(function (res) {
if (res.status == 200) {
alert('上傳成功');
$scope.getStoredRank();
}
});
}

$scope.getStoredRank = function () {
ScoresService.getStoredRank().then(function (res) {
if (res.status == 200) {
$scope.storedRank = res.data;
}
});
}
});

ScoresApp.service("ScoresService", function ($http) {
return (
{
Get_User: Get_User,
Get_data: Get_data
Get_data: Get_data,
postStoreRank : postStoreRank ,
getStoredRank : getStoredRank
}
);
function Get_User($scope) {
Expand All @@ -58,6 +80,25 @@ ScoresApp.service("ScoresService", function ($http) {
return (request.then(handleSuccess, handleError));
}

function postStoreRank (data) {
let request = $http({
method : "POST" ,
url : "api/Scores/storeRank" ,
data : {
data
}
});
return (request.then(handleSuccess , handleError));
}

function getStoredRank () {
let request = $http({
method : "GET" ,
url : "api/Scores/storeRank"
});
return (request.then(handleSuccess , handleError));
}

function handleSuccess(response) {
return (response);
}
Expand Down

0 comments on commit 0e429ce

Please sign in to comment.