Merge branch 'master' into UI
This commit is contained in:
commit
6d0505fa28
5 changed files with 210 additions and 66 deletions
|
@ -70,11 +70,13 @@ def send_create_campus_request(email, name, campus_name):
|
|||
"""
|
||||
|
||||
message.html = """
|
||||
<html><head></head><body>
|
||||
<html><head>
|
||||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
|
||||
</head><body>
|
||||
<div>
|
||||
<center>
|
||||
<img src='https://cloud.githubusercontent.com/assets/2984053/6825467/7c9d0402-d303-11e4-9827-62a6d66f937a.png'>
|
||||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
|
||||
|
||||
</center>
|
||||
</div>
|
||||
<div style='width:70%'>
|
||||
|
@ -108,11 +110,13 @@ def notify_se_hub_campus_request(campus, campus_name):
|
|||
""" + str(campus.to_JSON())
|
||||
|
||||
message.html = """
|
||||
<html><head></head><body>
|
||||
<html><head>
|
||||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
|
||||
</head><body>
|
||||
<div>
|
||||
<center>
|
||||
<img src='https://cloud.githubusercontent.com/assets/2984053/6825467/7c9d0402-d303-11e4-9827-62a6d66f937a.png'>
|
||||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
|
||||
|
||||
</center>
|
||||
</div>
|
||||
<div style='width:70%'>
|
||||
|
@ -151,18 +155,19 @@ def send_task_reminder( email, name, task_name, course_name):
|
|||
"""
|
||||
|
||||
message.html = """
|
||||
<html><head></head><body>
|
||||
<html><head>
|
||||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
|
||||
</head><body>
|
||||
<div>
|
||||
<center>
|
||||
<img src='https://cloud.githubusercontent.com/assets/2984053/6825467/7c9d0402-d303-11e4-9827-62a6d66f937a.png'>
|
||||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
|
||||
</center>
|
||||
</div>
|
||||
<div style='width:70%'>
|
||||
<h3>Dear """+name+""":</h3>
|
||||
|
||||
<center>
|
||||
<img src='https://pixabay.com/static/uploads/photo/2014/03/05/07/54/reminder-279903_640.png'>
|
||||
<img src='https://pixabay.com/static/uploads/photo/2014/03/05/07/54/reminder-279903_640.png' style='height:100px'>
|
||||
</center>
|
||||
<br>
|
||||
|
||||
|
|
|
@ -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/<string:token>/<string:taskId>/<string:ownerId>/<string:grade>', methods=['POST'])
|
||||
@auto.doc()
|
||||
def submitGrade(token, taskId, ownerId, grade):
|
||||
"""
|
||||
<span class="card-title">This call will create a new Task in the DB</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
- JSON Object, Example: <br>
|
||||
{<br>
|
||||
"title":"task1",<br>
|
||||
"courseId":1234567890,<br>
|
||||
"description":"pls fddfsdfdsk",<br>
|
||||
"dueDate":{"year":2010,<br>
|
||||
"month":2,<br>
|
||||
"day":4<br>
|
||||
},
|
||||
"isPersonal":true,<br>
|
||||
"components":[<br>
|
||||
{<br>
|
||||
"type" : "should be type1",<br>
|
||||
"label" : "should be label1",<br>
|
||||
"isMandatory" : true,<br>
|
||||
"order" : 1<br>
|
||||
},<br>
|
||||
{<br>
|
||||
"type" : "should be type2",<br>
|
||||
"label" : "should be label2",<br>
|
||||
"isMandatory" : true,<br>
|
||||
"order" : 2<br>
|
||||
},<br>
|
||||
{<br>
|
||||
"type" : "should be type3",<br>
|
||||
"label" : "should be label3",<br>
|
||||
"isMandatory" : false,<br>
|
||||
"order" : 3<br>
|
||||
}<br>
|
||||
]<br>
|
||||
}
|
||||
<br>
|
||||
<br>
|
||||
<b>Response</b>
|
||||
<br>
|
||||
201 - Created
|
||||
<br>
|
||||
400 - Bad Request
|
||||
<br>
|
||||
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,6 +966,7 @@ def sendTaskReminder():
|
|||
course = Course.get_by_id(int(t.courseId))
|
||||
if t.isPersonal:
|
||||
for uId in course.membersId:
|
||||
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))
|
||||
|
|
|
@ -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,17 +95,16 @@ 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...')
|
||||
|
@ -99,42 +113,33 @@ angular.module('SeHub')
|
|||
.ok('Got it!')
|
||||
.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.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)
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
}]);
|
|
@ -1,8 +1,45 @@
|
|||
<div ng-if='loading' class='center_all'>
|
||||
<md-progress-circular md-mode="indeterminate"></md-progress-circular>
|
||||
</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 flex='20'></div>
|
||||
<div flex='10'></div>
|
||||
<div layout="coulumn" flex="60">
|
||||
<md-card layout-padding style="width:100%">
|
||||
<h1><i class="fa fa-clipboard"></i> {{task.title}}</h1>
|
||||
|
|
Loading…
Reference in a new issue