From 336c8354a8a7abe384d23f7d20fac40b2085048a Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sun, 2 Aug 2015 17:54:27 +0300 Subject: [PATCH 1/7] Fixed Email --- SE_API/Email_Utils.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/SE_API/Email_Utils.py b/SE_API/Email_Utils.py index 90f2ec4..086a025 100644 --- a/SE_API/Email_Utils.py +++ b/SE_API/Email_Utils.py @@ -70,11 +70,13 @@ def send_create_campus_request(email, name, campus_name): """ message.html = """ - + + +
- +
@@ -108,11 +110,13 @@ def notify_se_hub_campus_request(campus, campus_name): """ + str(campus.to_JSON()) message.html = """ - + + +
- +
@@ -151,11 +155,12 @@ def send_task_reminder( email, name, task_name, course_name): """ message.html = """ - + + +
-
From 1615963c15c9d3ee0478ef3394b7418f8f5e10bb Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Sun, 2 Aug 2015 17:55:45 +0300 Subject: [PATCH 2/7] fix mail to master of course --- SE_API/TaskRoutes.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/SE_API/TaskRoutes.py b/SE_API/TaskRoutes.py index e7c6c54..891abea 100644 --- a/SE_API/TaskRoutes.py +++ b/SE_API/TaskRoutes.py @@ -878,11 +878,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()) From 014fa602cb9f6169dfebfdef4b66ea161b001292 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sun, 2 Aug 2015 18:15:51 +0300 Subject: [PATCH 3/7] Fix to task --- SE_API/Email_Utils.py | 2 +- templates/js/controllers/taskController.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/SE_API/Email_Utils.py b/SE_API/Email_Utils.py index 086a025..93bc34b 100644 --- a/SE_API/Email_Utils.py +++ b/SE_API/Email_Utils.py @@ -167,7 +167,7 @@ def send_task_reminder( email, name, task_name, course_name):

Dear """+name+""":

- +

diff --git a/templates/js/controllers/taskController.js b/templates/js/controllers/taskController.js index e29a493..04f8e80 100644 --- a/templates/js/controllers/taskController.js +++ b/templates/js/controllers/taskController.js @@ -80,14 +80,15 @@ angular.module('SeHub') .content('Your Task Was Successfully Submitted!') .ariaLabel('ddd') .ok('GoTo My Submitted Task') - .then(function(dd){ + .targetEvent(event) + + ).then(function(){ if($scope.task.isPersonal) $location.path('/tasks/overview/'+taskId+'/'+groupId+'/'+groupId); else $location.path('/tasks/overview/'+taskId+'/'+groupId+'/'+groupId); - }) - .targetEvent(event) - ); + }); + return; }) } From 9e5d6f91399455f026d9614fb039cfa7bd0bb23a Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Sun, 2 Aug 2015 18:41:19 +0300 Subject: [PATCH 4/7] fix --- SE_API/TaskRoutes.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/SE_API/TaskRoutes.py b/SE_API/TaskRoutes.py index 891abea..302c94d 100644 --- a/SE_API/TaskRoutes.py +++ b/SE_API/TaskRoutes.py @@ -704,9 +704,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 +714,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(): From 8bb73c7bc7c43b556e22cb65b53eece77b84d1d6 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Sun, 2 Aug 2015 19:35:08 +0300 Subject: [PATCH 5/7] added submitGrade --- SE_API/TaskRoutes.py | 89 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/SE_API/TaskRoutes.py b/SE_API/TaskRoutes.py index 302c94d..64e04a0 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 submitTask(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 #---------------------------------------------------------- From 2107ca1aea3944d5e066e622ba53adda8f334662 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Sun, 2 Aug 2015 19:37:58 +0300 Subject: [PATCH 6/7] added submitGrade --- SE_API/TaskRoutes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SE_API/TaskRoutes.py b/SE_API/TaskRoutes.py index 64e04a0..652cf90 100644 --- a/SE_API/TaskRoutes.py +++ b/SE_API/TaskRoutes.py @@ -234,7 +234,7 @@ def submitTask(token, taskId, ownerId): @task_routes.route('/api/tasks/submitGrade////', methods=['POST']) @auto.doc() -def submitTask(token, taskId, ownerId, grade): +def submitGrade(token, taskId, ownerId, grade): """ This call will create a new Task in the DB
From 0ad5385359c3902a2b2d8e2a1f28ae44ebba5e31 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sun, 2 Aug 2015 19:53:35 +0300 Subject: [PATCH 7/7] FIxed some Tasks Issues --- templates/js/controllers/taskController.js | 102 +++++++++++---------- templates/js/services/apiService.js | 8 ++ templates/views/task.html | 39 +++++++- 3 files changed, 99 insertions(+), 50 deletions(-) diff --git a/templates/js/controllers/taskController.js b/templates/js/controllers/taskController.js index 04f8e80..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) { @@ -82,63 +97,52 @@ angular.module('SeHub') .ok('GoTo My Submitted Task') .targetEvent(event) - ).then(function(){ - if($scope.task.isPersonal) - $location.path('/tasks/overview/'+taskId+'/'+groupId+'/'+groupId); - else - $location.path('/tasks/overview/'+taskId+'/'+groupId+'/'+groupId); + ).then(function() { + $location.path('/tasks/overview/' + taskId + '/' + groupId + '/' + groupId); }); - return; + }) + } 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}} +
+
+ + +
+
+
+
+ Submit +
+
+
+
+ + +
+
+
-
+

{{task.title}}