@@ -108,11 +110,13 @@ def notify_se_hub_campus_request(campus, campus_name):
""" + str(campus.to_JSON())
message.html = """
-
+
+
@@ -151,18 +155,19 @@ def send_task_reminder( email, name, task_name, course_name):
"""
message.html = """
-
+
+
+
-
Dear """+name+""":
-
+
diff --git a/SE_API/TaskRoutes.py b/SE_API/TaskRoutes.py
index e7c6c54..652cf90 100644
--- a/SE_API/TaskRoutes.py
+++ b/SE_API/TaskRoutes.py
@@ -230,6 +230,95 @@ def submitTask(token, taskId, ownerId):
return Response(response=task.to_JSON(),
status=200,
mimetype="application/json")
+
+
+@task_routes.route('/api/tasks/submitGrade/
///', methods=['POST'])
+@auto.doc()
+def submitGrade(token, taskId, ownerId, grade):
+ """
+ This call will create a new Task in the DB
+
+ Route Parameters
+ - seToken: 'seToken'
+
+
+ Payload
+ - JSON Object, Example:
+ {
+ "title":"task1",
+ "courseId":1234567890,
+ "description":"pls fddfsdfdsk",
+ "dueDate":{"year":2010,
+ "month":2,
+ "day":4
+ },
+ "isPersonal":true,
+ "components":[
+ {
+ "type" : "should be type1",
+ "label" : "should be label1",
+ "isMandatory" : true,
+ "order" : 1
+ },
+ {
+ "type" : "should be type2",
+ "label" : "should be label2",
+ "isMandatory" : true,
+ "order" : 2
+ },
+ {
+ "type" : "should be type3",
+ "label" : "should be label3",
+ "isMandatory" : false,
+ "order" : 3
+ }
+ ]
+}
+
+
+ Response
+
+ 201 - Created
+
+ 400 - Bad Request
+
+ 403 - Invalid token or not a lecturer
+ """
+ user = get_user_by_token(token)
+ if user is None:
+ bad_request("bad user Token")
+
+ task = Task.get_by_id(int(taskId))
+ if task is None:
+ bad_request("bad Task id")
+
+
+ if task.isPersonal:
+ if User.get_by_id(int(ownerId)) is None:
+ return bad_request("no such user")
+ else:
+ if Project.get_by_id(int(ownerId)) is None:
+ return bad_request("no such project")
+
+ try:
+ tg = TaskGrade.all().filter("taskId = ", int(taskId)).filter("userId = ", int(ownerId))
+ if tg.count() == 0:
+ grade = TaskGrade(taskId=int(taskId), userId=int(ownerId), grade=int(grade))
+ else:
+ for g in tg.run():
+ g.grade=int(grade)
+ g.taskId=int(taskId)
+ g.userId=int(ownerId)
+ db.put(grade)
+ db.save
+ return Response(response=grade.to_JSON(),
+ status=200,
+ mimetype="application/json")
+ except Exception as e:
+ print e.message
+ return bad_request("wrong format")
+
+
#----------------------------------------------------------
# PUT
#----------------------------------------------------------
@@ -704,9 +793,9 @@ def getTaskById(token, taskId, ownerId):
task['grade'] = {}
taskCompQuery = TaskComponent.all()
- taskCompQuery.filter("taskId = ", taskId)
+ taskCompQuery.filter("taskId = ", int(taskId))
- taskCompQuery.filter("userId = ", ownerId)
+ taskCompQuery.filter("userId = ", int(ownerId))
# if task.isPersonal:
# taskCompQuery.filter("userId = ", user.key().id())
# else:
@@ -714,7 +803,6 @@ def getTaskById(token, taskId, ownerId):
#check if never created a personalized task and if so, create it
if taskCompQuery.count() == 0:
- print "here"
taskCompQuery = TaskComponent.all().filter("taskId =", int(taskId)).filter("userId =", -1)
print "query count is: ", taskCompQuery.count()
for tc in taskCompQuery.run():
@@ -878,11 +966,12 @@ def sendTaskReminder():
course = Course.get_by_id(int(t.courseId))
if t.isPersonal:
for uId in course.membersId:
- tc = TaskComponent.all().filter("taskId = ", t.key().id()).filter("userId = ", int(uId))
- if tc.count() == 0:
- user = User.get_by_id(int(uId))
- send_task_reminder(user.email, user.name, t.title, course.courseName)
- print ""
+ if int(uId) != course.master_id:
+ tc = TaskComponent.all().filter("taskId = ", t.key().id()).filter("userId = ", int(uId))
+ if tc.count() == 0:
+ user = User.get_by_id(int(uId))
+ send_task_reminder(user.email, user.name, t.title, course.courseName)
+ print ""
else:
projects = Project.all().filter("courseId = ", course.key().id())
diff --git a/templates/js/controllers/taskController.js b/templates/js/controllers/taskController.js
index e29a493..3619d56 100644
--- a/templates/js/controllers/taskController.js
+++ b/templates/js/controllers/taskController.js
@@ -8,11 +8,27 @@ angular.module('SeHub')
var submitterId = $routeParams.submitterId;
var token = $cookies['com.sehub.www'];
var groupId = $routeParams.gId;
+ var user = $scope.$parent.user;
$scope.loading = true;
+ $scope.isMaster = false;
apiService.getTaskById(token, taskId, groupId).success(function(data) {
+ if(!data.grade.grade)
+ data.grade.grade = 0;
$scope.task = data;
$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;
}).error(function(err) {
$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
$scope.readOnly = false;
- apiService.getTaskById(token, taskId, groupId);
}
$scope.dateInit = function(date) {
@@ -80,64 +95,54 @@ angular.module('SeHub')
.content('Your Task Was Successfully Submitted!')
.ariaLabel('ddd')
.ok('GoTo My Submitted Task')
- .then(function(dd){
- if($scope.task.isPersonal)
- $location.path('/tasks/overview/'+taskId+'/'+groupId+'/'+groupId);
- else
- $location.path('/tasks/overview/'+taskId+'/'+groupId+'/'+groupId);
- })
.targetEvent(event)
- );
+
+ ).then(function() {
+ $location.path('/tasks/overview/' + taskId + '/' + groupId + '/' + groupId);
+ });
+
})
+ } else {
+
+ $mdDialog.show(
+ $mdDialog.alert()
+ .title('Hey There...')
+ .content('You Must Fill All Mandatory Fields In Order To Submit The Task')
+ .ariaLabel('Not All Mandatory Are Filled')
+ .ok('Got it!')
+ .targetEvent(event)
+ );
}
- $mdDialog.show(
- $mdDialog.alert()
- .title('Hey There...')
- .content('You Must Fill All Mandatory Fields In Order To Submit The Task')
- .ariaLabel('Not All Mandatory Are Filled')
- .ok('Got it!')
- .targetEvent(event)
- );
+ };
+
+ $scope.submitGrade = function(event){
+ apiService.submitGrade(token, taskId, groupId, $scope.task.garde.grade).success(function(data){
+ $mdDialog.show(
+ $mdDialog.alert()
+ .title('Thanks For Grading')
+ .content('The Grade was successfully posted. you can change the grade later if you want')
+ .ariaLabel('Not All Mandatory Are Filled')
+ .ok('Go Back To Tasks')
+ .targetEvent(event)
+ ).then(function(){
+ $location.path('/tasks');
+ });
+ }).error(function(err){
+ $mdDialog.show(
+ $mdDialog.alert()
+ .title('Something Happened')
+ .content('something went wrong... Try Again Later')
+ .ariaLabel('Not All Mandatory Are Filled')
+ .ok('No Problem!')
+ .targetEvent(event)
+ );
+ })
}
- /*=================================
- = Mock Data =
- =================================*/
-
- // $scope.task = {
- // "title": "task1",
- // "courseId": 1234567890,
- // "description": "one line\nsecondline\nthirdline",
- // "dueDate": {
- // "year": 2010,
- // "month": 2,
- // "day": 4
- // },
- // "isPersonal": true,
- // "components": [{
- // "type": "radiobuttons",
- // "label": "pick One|this|orthis|MaybeThis",
- // "isMandatory": true,
- // "order": 1
- // }, {
- // "type": "checkbox",
- // "label": "tick Me",
- // "isMandatory": true,
- // "order": 2
- // }, {
- // "type": "textarea",
- // "label": "fill shit",
- // "isMandatory": false,
- // "order": 3
- // }]
- // };
-
-
-
$scope.dueTime = function() {
if (!$scope.task.date || $scope.task.date === '')
$scope.dueTimeFromNow = "";
diff --git a/templates/js/services/apiService.js b/templates/js/services/apiService.js
index 2460da0..c82d25a 100644
--- a/templates/js/services/apiService.js
+++ b/templates/js/services/apiService.js
@@ -271,6 +271,14 @@ service.factory('apiService', ['$http', function($http) {
url: url
};
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);
}
};
}]);
\ No newline at end of file
diff --git a/templates/views/task.html b/templates/views/task.html
index b682860..eccf7af 100644
--- a/templates/views/task.html
+++ b/templates/views/task.html
@@ -1,8 +1,45 @@
+
+
+
+
+ Submitter
+
+
+
+
+
+
+
+ Student Name: {{group.name}}
+
+
+ Project Name: {{group.projectName}}
+
+
+ Grade : {{task.garde.grade}}
+
+
+
+
+
+
+
+
+
+
+
+
+