def post(self): # we need to be able to update scores for an uncompleted certification # passing (score) id, score, method (update) method = self.request.get("method") certid = int(self.request.get("certid")) scid = int(self.request.get("id")) score = int(self.request.get("score")) sc = ElemScore.get_by_id(scid) sc.score = score sc.put() # TODO check to see if all the scores are passing and update cert.completed if so... c = Certification.get_by_id(certid) completed = True for s in c.scores: if s.score == 0: complete = False break if completed: if c.completed: # already completed pass else: c.completed = True c.put() ctkn = c.template.key().name() if ctkn == "KB1": level = 1 elif ctkn == "KB2": level = 2 elif ctkn == "KB3": level = 3 elif ctkn == "IK1": level = 4 elif ctkn == "IK2": level = 5 elif ctkn == "IK3": level = 6 else: level = 0 c.owner.level = level if c.put() and c.completed: # triggers an email to email c.owner.put() self.redirect("/examiner/certifications?certid=" + self.request.get("certid"))
def post(self): # we need to be able to update scores for an uncompleted certification # passing (score) id, score, method (update) method = self.request.get('method') certid = int(self.request.get('certid')) scid = int(self.request.get('id')) score =int(self.request.get('score')) sc = ElemScore.get_by_id(scid) sc.score = score sc.put() # TODO check to see if all the scores are passing and update cert.completed if so... cert = Certification.get_by_id(certid) complete = True for s in cert.scores: if s.score == 0: complete = False break if complete: cert.completed = True cert.put() self.redirect('/admin/certifications?certid='+self.request.get('certid'))
def post(self): # we need to be able to update scores for an uncompleted certification # passing (score) id, score, method (update) method = self.request.get('method') elemscoreid = int(self.request.get('elemscoreid')) tskscid = int(self.request.get('id')) score = None tsksc = TaskScore.get_by_id(tskscid) tsksc.completed = True if self.request.get('score'): score=int(self.request.get('score')) tsksc.score = score tsksc.put() # check to see if all the other scores are passing and update elemscore.completed if so... e = ElemScore.get_by_id(elemscoreid) completed = True tally = 0 count = 0 for es in e.taskscores: tally += es.score count += 1 if es.score < 1: completed = False break if completed: average = round(tally/count,0) e.score = int(average) e.put() c = e.certification for s in c.scores: if s.score < 1: completed = False break if completed: if c.completed: #already completed pass else: c.completed = True c.put() ctkn = c.template.key().name() if ctkn == 'KB1': level = 1 elif ctkn == 'KB2': level = 2 elif ctkn == 'KB3': level = 3 else: level = 0 c.owner.level = level if c.put() and c.completed: #triggers an email to email c.owner.put() # trigger an email to recipient of certification from google.appengine.api import mail message = mail.EmailMessage(sender="WorldKiteOrg-DoNotReply <*****@*****.**>",subject="Congratulations - your WorldKite Certification is completed") message.to = member.key().name() message.body = "Congratulations" + member.fnam + " " + member.lnam message.body += """ """ message.body += c.template.key().name() + " " + c.template.short message.body += """ Visit http://worldkite.org and login with the email address you provided for your World Kite certification. We use Google's system for authentication so if you email account is not already registered with Google then you will be prompted to do so. Please let us know if you have any questions by dropping an email to: [email protected] Welcome to our team! World Kite Organization """ message.send() self.response.out.write('/instructor/certifications?certid=' + str(c.key().id())) else: pass