Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/teacher dashboard #146

Merged
merged 7 commits into from
Jan 25, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/main/resources/data.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
INSERT INTO `user` (`id`, `email`, `name`, `password`, `verified`, `reference_id`) VALUES
<<<<<<< HEAD
(1, "[email protected]", "John Doe", "$2a$04$FYZXxiv7A74rX33gfs2m/.AGqhQ/unlJCB2nHLRiuHCVlECcyLyb6", 1, '123456'),
(2, "[email protected]", "Jane Doe", "$2a$04$FYZXxiv7A74rX33gfs2m/.AGqhQ/unlJCB2nHLRiuHCVlECcyLyb6", 1, '654321'),
(3, "[email protected]", "Administrator", "$2a$04$FYZXxiv7A74rX33gfs2m/.AGqhQ/unlJCB2nHLRiuHCVlECcyLyb6", 1, '987555'),
(4, "[email protected]", "John Doe", "$2a$04$FYZXxiv7A74rX33gfs2m/.AGqhQ/unlJCB2nHLRiuHCVlECcyLyb6", 1, '123456');
=======
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please resolve merge conflicts first

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to push them

(1, "[email protected]", "Pascal Drewes", "$2a$04$FYZXxiv7A74rX33gfs2m/.AGqhQ/unlJCB2nHLRiuHCVlECcyLyb6", 1, "123456"),
(2, "[email protected]", "Administrator", "$2a$04$FYZXxiv7A74rX33gfs2m/.AGqhQ/unlJCB2nHLRiuHCVlECcyLyb6", 1, '987555'),
(3, "[email protected]", "Cas van Dinter", "$2a$04$FYZXxiv7A74rX33gfs2m/.AGqhQ/unlJCB2nHLRiuHCVlECcyLyb6", 1, "123456"),
(4, "[email protected]", "Danny Hooijer", "$2a$04$FYZXxiv7A74rX33gfs2m/.AGqhQ/unlJCB2nHLRiuHCVlECcyLyb6", 1, "123456"),
(5, "[email protected]", "Bas van't Holt", "$2a$04$FYZXxiv7A74rX33gfs2m/.AGqhQ/unlJCB2nHLRiuHCVlECcyLyb6", 1, "123456");
>>>>>>> 105352b401274b6ff2367ac5b4f1c8c52968ed58

INSERT INTO `role` (`id`, `code`, `label`) VALUES
(1, "STUDENT_ROLE", "Student"),
Expand All @@ -12,10 +19,16 @@ INSERT INTO `role` (`id`, `code`, `label`) VALUES

INSERT INTO `user_roles` (`user_id`, `role_id`) VALUES
(1, 1),
<<<<<<< HEAD
(2, 2),
(3, 3),
(4, 1);
=======
(2, 3),
(3, 1),
(4, 1),
(5, 2);
>>>>>>> 105352b401274b6ff2367ac5b4f1c8c52968ed58

INSERT INTO `education` (`id`, `name`) VALUES
(1, "INF"),
Expand Down
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,26 @@
<div ng-init="init()">
<div ng-init="$ctrl.onInit()">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needen

<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>
<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><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 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>
<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>
<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>
</div>

Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<div ng-init="init()">
<div ng-init="$ctrl.onInit()">
<table layout-fill>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed

<tr>
<td colspan="3"><span class="md-subhead dashboard-course-name">{{$ctrl.course.name}}</span></td>
<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.group.groupGrade.grade}}</span></td>
<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>
<hr>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<div ng-init="$ctrl.init()">
<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>
</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 @@ -227,5 +227,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
91 changes: 90 additions & 1 deletion src/main/resources/public/app/pages/dashboard-teacher.html
Original file line number Diff line number Diff line change
@@ -1 +1,90 @@
<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>

<!-- $scope.items = [1, 2, 3, 4, 5, 6, 7];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to remove this outcommented code

$scope.selectedItem;
$scope.getSelectedText = function() {
if ($scope.selectedItem !== undefined) {
return "You have selected: Item " + $scope.selectedItem;
} else {
return "Please select an item";
}
};
}); -->

<!-- JS
HTMLJS
<div ng-controller="SelectedTextController" class="md-padding" ng-cloak>
<div>
<h1 class="md-title">Pick an item below</h1>
<div layout="row">
<md-input-container>
<label>Items</label>
<md-select ng-model="selectedItem" md-selected-text="getSelectedText()">
<md-optgroup label="items">
<md-option ng-value="item" ng-repeat="item in items">Item {{item}}</md-option>
</md-optgroup>
</md-select>
</md-input-container>
</div>
</div>
</div> -->
Loading