FIxed some Tasks Issues

This commit is contained in:
Sagi Dayan 2015-08-02 19:53:35 +03:00
parent bbc37e734a
commit 0ad5385359
3 changed files with 99 additions and 50 deletions

View file

@ -8,11 +8,27 @@ angular.module('SeHub')
var submitterId = $routeParams.submitterId; var submitterId = $routeParams.submitterId;
var token = $cookies['com.sehub.www']; var token = $cookies['com.sehub.www'];
var groupId = $routeParams.gId; var groupId = $routeParams.gId;
var user = $scope.$parent.user;
$scope.loading = true; $scope.loading = true;
$scope.isMaster = false;
apiService.getTaskById(token, taskId, groupId).success(function(data) { apiService.getTaskById(token, taskId, groupId).success(function(data) {
if(!data.grade.grade)
data.grade.grade = 0;
$scope.task = data; $scope.task = data;
$scope.dateInit($scope.task.dueDate); $scope.dateInit($scope.task.dueDate);
apiService.getCourseById(token, data.courseId).success(function(data) {
$scope.isMaster = (user.id === data.master_id);
});
if (!data.isPersonal) {
apiService.getProjectsById(token, groupId).sucsess(function(data) {
$scope.group = data;
});
} else {
apiService.getUserById(token, groupId).success(function(data) {
$scope.group = data;
});
}
$scope.loading = false; $scope.loading = false;
}).error(function(err) { }).error(function(err) {
$location.path('/tasks'); $location.path('/tasks');
@ -23,7 +39,6 @@ angular.module('SeHub')
} else { //In This Case We Need An Empty Task To Be Able To Fill It } else { //In This Case We Need An Empty Task To Be Able To Fill It
$scope.readOnly = false; $scope.readOnly = false;
apiService.getTaskById(token, taskId, groupId);
} }
$scope.dateInit = function(date) { $scope.dateInit = function(date) {
@ -83,15 +98,13 @@ angular.module('SeHub')
.targetEvent(event) .targetEvent(event)
).then(function() { ).then(function() {
if($scope.task.isPersonal)
$location.path('/tasks/overview/'+taskId+'/'+groupId+'/'+groupId);
else
$location.path('/tasks/overview/' + taskId + '/' + groupId + '/' + groupId); $location.path('/tasks/overview/' + taskId + '/' + groupId + '/' + groupId);
}); });
return;
}) })
} } else {
$mdDialog.show( $mdDialog.show(
$mdDialog.alert() $mdDialog.alert()
.title('Hey There...') .title('Hey There...')
@ -100,42 +113,33 @@ angular.module('SeHub')
.ok('Got it!') .ok('Got it!')
.targetEvent(event) .targetEvent(event)
); );
} }
};
$scope.submitGrade = function(event){
/*================================= apiService.submitGrade(token, taskId, groupId, $scope.task.garde.grade).success(function(data){
= Mock Data = $mdDialog.show(
=================================*/ $mdDialog.alert()
.title('Thanks For Grading')
// $scope.task = { .content('The Grade was successfully posted. you can change the grade later if you want')
// "title": "task1", .ariaLabel('Not All Mandatory Are Filled')
// "courseId": 1234567890, .ok('Go Back To Tasks')
// "description": "one line\nsecondline\nthirdline", .targetEvent(event)
// "dueDate": { ).then(function(){
// "year": 2010, $location.path('/tasks');
// "month": 2, });
// "day": 4 }).error(function(err){
// }, $mdDialog.show(
// "isPersonal": true, $mdDialog.alert()
// "components": [{ .title('Something Happened')
// "type": "radiobuttons", .content('something went wrong... Try Again Later')
// "label": "pick One|this|orthis|MaybeThis", .ariaLabel('Not All Mandatory Are Filled')
// "isMandatory": true, .ok('No Problem!')
// "order": 1 .targetEvent(event)
// }, { );
// "type": "checkbox", })
// "label": "tick Me", }
// "isMandatory": true,
// "order": 2
// }, {
// "type": "textarea",
// "label": "fill shit",
// "isMandatory": false,
// "order": 3
// }]
// };

View file

@ -271,6 +271,14 @@ service.factory('apiService', ['$http', function($http) {
url: url url: url
}; };
return $http(req); return $http(req);
},
submitGrade: function(token, taskId, ownerId, grade){
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/tasks/submitGrade/" + token + '/' + taskId + '/' + ownerId + '/' + grade;
req = {
method: 'POST',
url: url
};
return $http(req);
} }
}; };
}]); }]);

View file

@ -1,8 +1,45 @@
<div ng-if='loading' class='center_all'> <div ng-if='loading' class='center_all'>
<md-progress-circular md-mode="indeterminate"></md-progress-circular> <md-progress-circular md-mode="indeterminate"></md-progress-circular>
</div> </div>
<div ng-if="readOnly && !loading">
<md-card style='position:fixed;top:11%;right:15px;width:20%' layout-padding>
<h1>Submitter</h1>
<div layout="row">
<div flex="30"> <!-- Avatar -->
<img ng-src="{{group.avatar_url}}" alt="" style="max-width:auto;padding:5px" ng-if='task.isPersonal'>
<img ng-src="{{group.logo_url}}" alt="" style="max-width:auto;padding:5px" ng-if='!task.isPersonal'>
</div>
<div class="user-data" layout="column" flex>
<div ng-if='task.isPersonal'>
Student Name: {{group.name}}
</div>
<div ng-if='!task.isPersonal'>
Project Name: {{group.projectName}}
</div>
<div>
Grade : {{task.garde.grade}}
</div>
<div>
<md-slider flex class="md-primary" md-discrete ng-model="task.garde.grade" step="1" min="1" max="100" aria-label="rating" ng-disabled="!isMaster">
</md-slider>
</div>
<div layout="row" ng-if='isMaster'>
<div class="spacer"></div>
<div>
<md-button ng-click='submitGrade($event)'>Submit</md-button>
</div>
</div>
</div>
</div>
</md-card>
</div>
<div layout='row' ng-if='!loading'> <div layout='row' ng-if='!loading'>
<div flex='20'></div> <div flex='10'></div>
<div layout="coulumn" flex="60"> <div layout="coulumn" flex="60">
<md-card layout-padding style="width:100%"> <md-card layout-padding style="width:100%">
<h1><i class="fa fa-clipboard"></i> {{task.title}}</h1> <h1><i class="fa fa-clipboard"></i> {{task.title}}</h1>