added isTaskSubmitted function

This commit is contained in:
Aran Zaiger 2015-08-02 22:27:51 +03:00
parent 32d7f40b06
commit 1856982dd0

View file

@ -887,6 +887,116 @@ def getUsersStateByTask(token, taskId):
status=200, status=200,
mimetype="application/json") mimetype="application/json")
@task_routes.route('/api/tasks/isTaskSubmitted/<string:token>/<string:taskId>/<string:groupId>', methods=["GET"])
@auto.doc()
def isTaskSubmitted(token, taskId, groupId):
"""
<span class="card-title">>This Call will return an array of all of the User's Tasks</span>
<br>
<b>Route Parameters</b><br>
- SeToken: token<br>
<br>
<br>
<b>Payload</b><br>
- NONE
<br>
<br>
<b>Response</b>
<br>
200 - JSON Example:<br>
<code>[<br>
{<br>
"courseName": "Advance Math",<br>
"courseId": 4762397176758272,<br>
"PersonalTasks": [<br>
{<br>
"grade": 12,<br>
"isPersonal": true,<br>
"dueDate": {<br>
"year": 2010,<br>
"day": 4,<br>
"month": 2<br>
},<br>
"courseId": 4762397176758272,<br>
"title": "task1",<br>
"description": "pls fddfsdfdsk",<br>
"id": 5888297083600896<br>
}<br>
],<br>
"projectTasks": []<br>
},<br>
{<br>
"courseName": "Bad Math",<br>
"courseId": 5659598665023488,<br>
"PersonalTasks": [<br>
{<br>
"grade": 12,<br>
"isPersonal": true,<br>
"dueDate": {<br>
"year": 2010,<br>
"day": 4,<br>
"month": 2<br>
},<br>
"courseId": 5659598665023488,<br>
"title": "new task1",<br>
"description": "pls fddfsdfdsk",<br>
"id": 5096648711602176<br>
},<br>
{<br>
"grade": 12,<br>
"isPersonal": true,<br>
"dueDate": {<br>
"year": 2010,<br>
"day": 4,<br>
"month": 2<br>
},<br>
"courseId": 5659598665023488,<br>
"title": "new task4",<br>
"description": "pls fddfsdfdsk",<br>
"id": 5167017455779840<br>
}<br>
],<br>
"projectTasks": [<br>
{<br>
"grade": 12,<br>
"isPersonal": false,<br>
"dueDate": {<br>
"year": 2010,<br>
"day": 4,<br>
"month": 2<br>
},<br>
"courseId": 5659598665023488,<br>
"title": "new task3",<br>
"description": "pls fddfsdfdsk",<br>
"id": 5237386199957504<br>
}<br>
]<br>
}<br>
]<br>
</code>
<br>
"""
user = get_user_by_token(token)
if user is None:
return bad_request("Bad User Token")
task = Task.get_by_id(int(taskId))
if task is None:
return bad_request("Bad task id")
res = {}
grade = TaskGrade.all().filter("taskId = ", task.key().id()).filter("userId = ", int(groupId))
if grade.count() == 0:
res['submitted'] = False
else:
res['submitted'] = True
return Response(response=res,
status=200,
mimetype="application/json")
# @task_routes.route('/api/tasks/getAllUngradedTasks/<string:token>/<string:taskId>/<string:ownerId>', methods=["GET"]) # @task_routes.route('/api/tasks/getAllUngradedTasks/<string:token>/<string:taskId>/<string:ownerId>', methods=["GET"])
# @auto.doc() # @auto.doc()