diff --git a/SE_API/TaskRoutes.py b/SE_API/TaskRoutes.py index 9012749..4b65dc7 100644 --- a/SE_API/TaskRoutes.py +++ b/SE_API/TaskRoutes.py @@ -1000,6 +1000,142 @@ def isTaskSubmitted(token, taskId, groupId): status=200, mimetype="application/json") + +@task_routes.route('/api/tasks/getAllUnsubmittedTasks/', methods=["GET"]) +@auto.doc() +def getAllUnsubmittedTasks(token): + """ + >This Call will return an array of all of the User's Tasks +
+ Route Parameters
+ - SeToken: token
+
+
+ Payload
+ - NONE +
+
+ Response +
+ 200 - JSON Example:
+ [
+ {
+ "courseName": "Advance Math",
+ "courseId": 4762397176758272,
+ "PersonalTasks": [
+ {
+ "grade": 12,
+ "isPersonal": true,
+ "dueDate": {
+ "year": 2010,
+ "day": 4,
+ "month": 2
+ },
+ "courseId": 4762397176758272,
+ "title": "task1",
+ "description": "pls fddfsdfdsk",
+ "id": 5888297083600896
+ }
+ ],
+ "projectTasks": []
+ },
+ {
+ "courseName": "Bad Math",
+ "courseId": 5659598665023488,
+ "PersonalTasks": [
+ {
+ "grade": 12,
+ "isPersonal": true,
+ "dueDate": {
+ "year": 2010,
+ "day": 4,
+ "month": 2
+ },
+ "courseId": 5659598665023488,
+ "title": "new task1",
+ "description": "pls fddfsdfdsk",
+ "id": 5096648711602176
+ },
+ {
+ "grade": 12,
+ "isPersonal": true,
+ "dueDate": {
+ "year": 2010,
+ "day": 4,
+ "month": 2
+ },
+ "courseId": 5659598665023488,
+ "title": "new task4",
+ "description": "pls fddfsdfdsk",
+ "id": 5167017455779840
+ }
+ ],
+ "projectTasks": [
+ {
+ "grade": 12,
+ "isPersonal": false,
+ "dueDate": {
+ "year": 2010,
+ "day": 4,
+ "month": 2
+ },
+ "courseId": 5659598665023488,
+ "title": "new task3",
+ "description": "pls fddfsdfdsk",
+ "id": 5237386199957504
+ }
+ ]
+ }
+ ]
+
+
+ """ + user = get_user_by_token(token) + if user is None: + return bad_request("Bad User Token") + + arr = [] + + courses = Course.all().filter("master_id = ", user.key().id()) + + for course in courses.run(): + dic = {} + dic['courseId'] = course.key().id() + dic['courseName'] = course.courseName + dic['tasks'] = [] + + tasks = Task.all().filter("courseId = ", course.key().id()) + for task in tasks.run(): + taskDic = {} + taskDic['title'] = task.title + taskDic['isPersonal'] = task.isPersonal + taskDic['usersToReview'] = [] + taskDic['projectsToReview'] = [] + + tgs = TaskGrade.all().filter("taskId = ", task.key().id()) + tcs = TaskComponent.all().filter("taskId = ", task.key().id()).filter("order = ", 0).filter("userId != ", -1) + for tg in tgs.run(): + tcs.filter("userId != ", tg.userId) + + for tc in tcs.run(): + if task.isPersonal: + u = User.get_by_id(tc.userId) + taskDic['usersToReview'].append(json.loads(u.to_JSON())) + else: + p = Project.get_by_id(tc.userId) + taskDic['projectsToReview'].append(json.loads(p.to_JSON())) + + dic['tasks'].append(taskDic) + + arr.append(dic) + + return Response(response=json.dumps(arr), + status=200, + mimetype="application/json") + + + + # @task_routes.route('/api/tasks/getAllUngradedTasks///', methods=["GET"]) # @auto.doc() # def getAllUngradedTasks(token, taskId, ownerId):