Skip to content

Commit

Permalink
Merge branch 'develop' into feature/retard
Browse files Browse the repository at this point in the history
  • Loading branch information
cassshh authored Jan 25, 2018
2 parents c9b108a + 0902a01 commit eadc90d
Show file tree
Hide file tree
Showing 14 changed files with 228 additions and 71 deletions.
47 changes: 31 additions & 16 deletions src/main/resources/public/app/components/dashboard.component.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
function DashboardCtrl($scope, StudentGroupsService, UserService){
var ctrl = this;
function DashboardCtrl($scope, $state, StudentGroupsService, UserService, GroupService, CourseService){
let ctrl = this;

$scope.init = function(){
ctrl.init = function(){
ctrl.closed = 0;
ctrl.open = 0;
ctrl.pending = 0;

UserService.getSelf().then(user => {
ctrl.self = user;

StudentGroupsService.getStudentGroups(ctrl.self.data.id).then(function(response){
GroupService.getGroupsByUserId(ctrl.self.data.id).then(function(response){
ctrl.groupsDetails = response.data;

if(ctrl.groupsDetails.length == 0){
$state.transitionTo('app.empty');
}

angular.forEach(ctrl.groupsDetails, function(value, key) {
StudentGroupsService.getGradingStatus(value.id).then(function(response){
if(response.data.status == "CLOSED"){
ctrl.closed += 1;
}else if(response.data.status == "OPEN"){
ctrl.open += 1;
}else if(response.data.status == "PENDING"){
ctrl.pending += 1;
GroupService.getGradingStatus(value.id).then(function(response){
switch(response.data.status){
case 'CLOSED':
ctrl.closed += 1;
break;
case 'OPEN':
ctrl.open += 1;
break;
case 'PENDING':
ctrl.pending += 1;
break;
}
})
});
Expand All @@ -28,23 +36,30 @@ function DashboardCtrl($scope, StudentGroupsService, UserService){
}
}

app.component('dashboardCourseOverview', {
app.component('dashboardProjectsOverview', {
templateUrl: '/app/components/dashboardProjectsOverview.component.html',
controller: DashboardCtrl
})
.component('dashboardCourseOverview', {
templateUrl: '/app/components/dashboardCourseOverview.component.html',
controller: GroupCardCtrl,
bindings: {
user: '<',
group: '<',
}
})
.component('dashboardProjectsOverview', {
templateUrl: '/app/components/dashboardProjectsOverview.component.html',
controller: DashboardCtrl
})
.component('dashboardGradeOverview', {
templateUrl: '/app/components/dashboardGradeOverview.component.html',
controller: GroupCardCtrl,
bindings: {
user: '<',
group: '<',
}
})
.component('dashboardGroupOverview', {
templateUrl: '/app/components/dashboardGroupOverview.component.html',
controller: DashboardCtrl,
bindings: {
group: '<'
}
});
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
<div ng-init="init()">
<table layout-fill>
<tr>
<td colspan="3"><span class="md-headline">{{$ctrl.name}}</span></td>
</tr>
<tr>
<td><span class="md-subhead" flex="">Status</span></td>
<td><span class="md-subhead" flex="">Group grade</span></td>
<td><span class="md-subhead" flex="">Your grade</span></td>
</tr>
<tr>
<td><span ng-class="$ctrl.groupStatusClass" class="md-title">{{$ctrl.groupStatus}}</span></td>
<td><span class="md-title grade">{{$ctrl.group.groupGrade.grade}}</span></td>
<td><span class="md-title grade">{{$ctrl.finalGrade}}</span></td>
</tr>
<tr>
<td colspan="2">
<div class="md-caption" ng-repeat="member in groupMembers">
<div ng-if="!$last">
{{member.name}}, &nbsp;
</div>
<div ng-if="$last">
{{member.name}}
</div>
</div>
</td>
</tr>
</table>
<hr>
<table layout-fill>
<tr>
<td colspan="3"><span class="md-headline">{{$ctrl.name}}</span></td>
</tr>
<tr>
<td><span class="md-subhead">Status</span></td>
<td><span class="md-subhead">Group grade</span></td>
<td><span class="md-subhead">Your grade</span></td>
</tr>
<tr>
<td class="align-status"><span ng-class="$ctrl.groupStatusClass" class="md-title">{{$ctrl.groupStatus}}</span></td>
<td><span class="md-title grade">{{$ctrl.groupGrade}}</span></td>
<td><span class="md-title grade">{{$ctrl.finalGrade}}</span></td>
</tr>
</table>
<div class="md-caption caption-compact" ng-repeat="member in $ctrl.group.users">
<div ng-if="!$last">
{{member.name}}, &nbsp;
</div>
<div ng-if="$last">
{{member.name}}
</div>
</div>

Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<div ng-init="init()">
<table layout-fill>
<tr>
<td colspan="3"><span class="md-subhead dashboard-course-name">{{$ctrl.course.name}}</span></td>
</tr>
<tr>
<td><span class="md-subhead" flex="">Group grade</span></td>
<td><span class="md-subhead" flex="">Your grade</span></td>
<td><span class="md-subhead" flex="">Change in grade</span></td>
</tr>
<tr>
<td><span class="md-title grade">{{$ctrl.group.groupGrade.grade}}</span></td>
<td><span class="md-title grade">{{$ctrl.finalGrade}}</span></td>
<td><span ng-class="$ctrl.percentage" class="md-title grade">{{$ctrl.calculateGradeChange($ctrl.group.groupGrade.grade, $ctrl.finalGrade)}}</span></td>
</tr>
</table>
<hr>
</div>
<table layout-fill>
<tr>
<td colspan="3"><span class="md-subhead dashboard-course-name">{{$ctrl.group.course.name}}</span></td>
</tr>
<tr>
<td><span class="md-subhead" flex="">Group grade</span></td>
<td><span class="md-subhead" flex="">Your grade</span></td>
<td><span class="md-subhead" flex="">Change in grade</span></td>
</tr>
<tr>
<td>
<span class="md-title grade">{{$ctrl.groupGrade}}</span>
</td>
<td><span class="md-title grade">{{$ctrl.finalGrade}}</span></td>
<td><span ng-class="$ctrl.percentage" class="md-title grade">{{$ctrl.calculateGradeChange($ctrl.group.groupGrade.grade, $ctrl.finalGrade)}}</span></td>
</tr>
</table>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<table>
<tr>
<td>Course</td>
<td class="md-subhead dashboard-course-name">{{$ctrl.group.course.name}}</td>
</tr>
<tr>
<td>Education</td>
<td class="md-subhead dashboard-course-name">{{$ctrl.group.course.education.name}}</td>
</tr>
<tr>
<td>Group name</td>
<td class="md-subhead dashboard-course-name">{{$ctrl.group.groupName}}</td>
</tr>
<tr>
<td ng-if="$ctrl.group.groupGrade.grade">Group grade</td>
<td ng-if="$ctrl.group.groupGrade.grade" class="md-subhead dashboard-course-name">{{$ctrl.group.groupGrade.grade}}</td>
</tr>
</table>
<div class="md-caption caption-compact" ng-repeat="member in $ctrl.group.users">
<div ng-if="!$last">
{{member.name}}, &nbsp;
</div>
<div ng-if="$last">
{{member.name}}
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div ng-init="init()">
<div ng-init="$ctrl.init()">
<table layout-fill>
<tr>
<td><span class="md-subhead" flex="">Projects closed</span></td>
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/public/app/components/empty.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="empty-page-wrap">
<md-title class="empty-page-txt">Nothing to see here...yet</md-title>
</div>
3 changes: 3 additions & 0 deletions src/main/resources/public/app/components/empty.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
app.component('empty', {
templateUrl: '/app/components/empty.component.html'
})
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ function GroupCardCtrl($state, StudentGroupsService, CourseService) {
let ctrl = this;

ctrl.groupMembers = [];
ctrl.groupGrade = '';

ctrl.$onInit = () => {
ctrl.name = ctrl.group.groupName;

ctrl.groupGrade = (ctrl.group.groupGrade == null) ? 'TBD' : ctrl.group.groupGrade.grade;

StudentGroupsService.getFinalGroupGrade(ctrl.group.id, ctrl.user.id).then((response) => {
if (response.data.grade) {
ctrl.finalGrade = response.data.grade;
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/public/app/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,5 +237,8 @@ app.config(function ($stateProvider) {
return AuthService.authenticate();
},
},
})
.state('app.empty', {
component: 'empty'
});
});
23 changes: 22 additions & 1 deletion src/main/resources/public/app/js/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ app.controller('StudentGroupsCtrl', function ($scope, UserService, StudentGroups
});

app.controller('TeacherGroupsCtrl', function ($scope, $mdDialog, UserService, GroupService) {
$scope.status = ' ';
$scope.limit = 10;
$scope.limitOptions = [5, 10, 15, 20, 50, 100];
$scope.teacherGroupList = [];
$scope.onInit = () => {
$scope.getGroups();
Expand All @@ -22,6 +23,26 @@ app.controller('TeacherGroupsCtrl', function ($scope, $mdDialog, UserService, Gr
UserService.getSelf().then((response) => {
return GroupService.getGroupsByUserId(response.data.id).then((response) => {
$scope.teacherGroupList = response.data;

$scope.closed = [];
$scope.pending = [];
$scope.open = [];

angular.forEach($scope.teacherGroupList, function(value, key) {
GroupService.getGradingStatus(value.id).then(function(response){
switch(response.data.status){
case "CLOSED":
$scope.closed.push(value);
break;
case "PENDING":
$scope.pending.push(value);
break;
case "OPEN":
$scope.open.push(value);
break;
}
})
});
});
});

Expand Down
62 changes: 61 additions & 1 deletion src/main/resources/public/app/pages/dashboard-teacher.html
Original file line number Diff line number Diff line change
@@ -1 +1,61 @@
<h1>Teacher Dashboard</h1>
<div ng-cloak ng-controller="TeacherGroupsCtrl" ng-init="onInit()">
<div layout="row">
<div flex>
<md-card>
<md-card-content>
<span class="md-subhead dashboard-card-title">Projects Overview</span>
<dashboard-projects-overview></dashboard-projects-overview>
</md-card-content>
</md-card>
</div>
</div>
<div layout="row">
<div flex>
<md-card>
<md-card-content>
<label>Amount to show</label>
<md-select aria-label="Select amount of groups to show" class="dashboard-select" ng-model="limit" md-selected-text="limit">
<md-optgroup label="options">
<md-option ng-value="option" ng-repeat="option in limitOptions">{{option}}</md-option>
</md-optgroup>
</md-select>
</md-card-content>
</md-card>
</div>
</div>
<div layout="row" layout-xs="column" layout-sm="column">
<div flex>
<md-card class="teacher-dashboard-groups">
<md-card-content>
<span class="md-subhead dashboard-card-title">Recent closed</span>
<span ng-repeat="group in closed | orderBy:'-id' | limitTo: limit">
<dashboard-group-overview group="group"></dashboard-group-overview>
<md-divider ng-if="!$last"></md-divider>
</span>
</md-card-content>
</md-card>
</div>
<div flex>
<md-card class="teacher-dashboard-groups">
<md-card-content>
<span class="md-subhead dashboard-card-title">Recent open</span>
<span ng-repeat="group in open | orderBy:'-id' | limitTo: limit">
<dashboard-group-overview group="group"></dashboard-group-overview>
<md-divider ng-if="!$last"></md-divider>
</span>
</md-card-content>
</md-card>
</div>
<div flex>
<md-card class="teacher-dashboard-groups">
<md-card-content>
<span class="md-subhead dashboard-card-title">Recent pending</span>
<span ng-repeat="group in pending | orderBy:'-id' | limitTo: limit">
<dashboard-group-overview group="group"></dashboard-group-overview>
<md-divider ng-if="!$last"></md-divider>
</span>
</md-card-content>
</md-card>
</div>
</div>
</div>
12 changes: 7 additions & 5 deletions src/main/resources/public/app/pages/dashboard.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
<div ng-cloak ng-controller="GroupsCtrl">
<div layout="row" layout-xs="column" ng-controller="StudentGroupsCtrl">
<div flex="50" flex-xs="100">
<div ng-cloak>
<div layout="row" layout-xs="column" layout-sm="column" ng-controller="StudentGroupsCtrl">
<div flex="50" flex-xs="100" flex-sm="100">
<md-card>
<md-card-content>
<div ng-repeat="group in groupsDetails | orderBy:'id'">
<dashboard-course-overview group="group" user="userDetails"></dashboard-course-overview>
<md-divider ng-if="!$last"></md-divider>
</div>
</md-card-content>
</md-card>
</div>
<div flex="50" flex-xs="100">
<div flex="50" flex-xs="100" flex-sm="100">
<div layout="column">
<div flex>
<md-card>
<md-card-content>
<span class="md-subhead dashboard-card-title">Projects Overview</span>
<dashboard-projects-overview user="userDetails"></dashboard-projects-overview>
<dashboard-projects-overview></dashboard-projects-overview>
</md-card-content>
</md-card>
</div>
Expand All @@ -25,6 +26,7 @@
<span class="md-subhead dashboard-card-title">Grade Overview</span>
<div ng-repeat="group in groupsDetails | orderBy:'id'">
<dashboard-grade-overview group="group" user="userDetails"></dashboard-grade-overview>
<md-divider ng-if="!$last"></md-divider>
</div>
</md-card-content>
</md-card>
Expand Down
Loading

0 comments on commit eadc90d

Please sign in to comment.