def get(self): sessionid = extractkeyfromrequest(self.request, 's') if sessionid: sessionid = sessionid.strip() user = None if sessionid: cacheservice = MemcacheService() user = cacheservice.getsessionuser(sessionid) # uid, insession = attemptlogin(self.request) # coursesservice = CoursesService() # courses = coursesservice.listupcomingcourses() template_values = { 'sessionid': sessionid, 'user': user, 'newuser': False, } # uid, insession = attemptlogin(self.request) # coursesservice = CoursesService() # courses = coursesservice.listupcomingcourses() # header_template_values = buildheadertemplatevalues(insession, uid) # template_values.update(header_template_values) # course_template_values = buildallcoursestemplatevalues(insession, courses) # template_values.update(course_template_values) template = JINJA_ENVIRONMENT.get_template('index-ace.html') self.response.write(template.render(template_values))
def post(self): sessionid = extractkeyfromrequest(self.request, 's') if sessionid: sessionid = sessionid.strip() profilestudentid = extractkeyfromrequest(self.request, 'p') profilestudentid = int(profilestudentid) userservice = TinkerAcademyUserService() profilestudent = userservice.finduserbystudentid(profilestudentid) cacheservice = MemcacheService() cacheservice.putinsession(sessionid, 'profilestudent', profilestudent) redirecthtml = "./profile.html" + "?s=" + str(sessionid) self.redirect(redirecthtml)
def post(self): emailid = extractkeyfromrequest(self.request, 'email') if emailid: emailid = emailid.strip() validationservice = ValidationService() isvalidemail = validationservice.isvalidemail(emailid) if isvalidemail and emailid: userservice = TinkerAcademyUserService() sessionid = userservice.subscribe(emailid) cacheservice = MemcacheService() cacheservice.putinsession(sessionid, "newuser", True) self.redirect('/subscribe.html?s=' + str(sessionid)) else: self.redirect('/subscribe.html')
def get(self): sessionid = extractkeyfromrequest(self.request, 's') if sessionid: sessionid = sessionid.strip() user = None isnewuser = False isfuture = False isrecservicesclaz = False if sessionid: cacheservice = MemcacheService() user = cacheservice.getsessionuser(sessionid) isnewuser = cacheservice.getfromsession(sessionid, "newuser") # uid, insession = attemptlogin(self.request) # coursesservice = CoursesService() # courses = coursesservice.listupcomingcourses() template_values = { 'sessionid': sessionid, 'user': user, 'isnewuser': isnewuser, 'isfuture': isfuture, 'isrecservicesclaz': isrecservicesclaz } if sessionid: cacheservice.clearfromsession(sessionid, "newuser") template = JINJA_ENVIRONMENT.get_template('subscribe.html') self.response.write(template.render(template_values))
def post(self): emailid = extractkeyfromrequest(self.request, 'email') name = extractkeyfromrequest(self.request, 'name') claz = extractkeyfromrequest(self.request, 'class') favmod = extractkeyfromrequest(self.request, 'favmod') zipcode = extractkeyfromrequest(self.request, 'zipcode') if emailid: emailid = emailid.strip() validationservice = ValidationService() isvalidemail = validationservice.isvalidemail(emailid) if isvalidemail and name: userservice = TinkerAcademyUserService() sessionid = userservice.register(name, emailid, claz, favmod, zipcode) cacheservice = MemcacheService() cacheservice.putinsession(sessionid, "newuser", True) cacheservice.putinsession(sessionid, "claz", claz) self.redirect('/register.html?s=' + str(sessionid)) else: self.redirect('/register.html')
def get(self): sessionid = extractkeyfromrequest(self.request, 's') if sessionid: sessionid = sessionid.strip() user = None isnewuser = False isfuture = False isrecservicesclaz = False if sessionid: cacheservice = MemcacheService() user = cacheservice.getsessionuser(sessionid) isnewuser = cacheservice.getfromsession(sessionid, "newuser") claz = cacheservice.getfromsession(sessionid, "claz") isfuture = claz == 'Future Sessions' isrecservicesclaz = claz == 'Sep 2015 - Nov 2015' or claz == 'Sep 2015 - Nov 2015 (AP)' # uid, insession = attemptlogin(self.request) # coursesservice = CoursesService() # courses = coursesservice.listupcomingcourses() template_values = { 'sessionid': sessionid, 'user': user, 'isnewuser': isnewuser, 'isfuture': isfuture, 'isrecservicesclaz': isrecservicesclaz } if sessionid: cacheservice.clearfromsession(sessionid, "newuser") # uid, insession = attemptlogin(self.request) # coursesservice = CoursesService() # courses = coursesservice.listupcomingcourses() # header_template_values = buildheadertemplatevalues(insession, uid) # template_values.update(header_template_values) # course_template_values = buildallcoursestemplatevalues(insession, courses) # template_values.update(course_template_values) template = JINJA_ENVIRONMENT.get_template('register.html') self.response.write(template.render(template_values))
def post(self): sessionid = extractkeyfromrequest(self.request, 's') if sessionid: sessionid = sessionid.strip() user = None source = None if sessionid: cacheservice = MemcacheService() user = cacheservice.getsessionuser(sessionid) if user: if self.request.params: hw = str(extractkeyfromrequest(self.request, 'hw')) hwint = int(hw) source = str(extractkeyfromrequest(self.request, 'source')) if not source: source = translateclaztosource(user.claz) if source: answerarr = hwanswers(source) studentdict = self.request.params hwresults = evaluateanswer(studentdict, answerarr[hwint]) hwlen = len(answerarr[hwint]) if "free" in answerarr[hwint]: hwlen = hwlen - 1 + answerarr[hwint]["free"] hwresults = hwresults + answerarr[hwint]["free"] kvpairs = extractkeyvaluesfromrequest(self.request) hwstr = kvpairs setattr(user, 'hw' + hw, hwstr) setattr(user, 'hw' + hw + 'results', hwresults) user.put() cacheservice.setsessionuser(sessionid, user) cacheservice.putinsession(sessionid, 'hw' + str(hw) + 'submitted', True) cacheservice.putinsession(sessionid, 'hw' + str(hw) + 'results', hwresults) cacheservice.putinsession(sessionid, 'hw' + str(hw) + 'len', hwlen) redirecthtml = "./index.html" if source == "ap": redirecthtml = "./apcomputerscience.html" elif source == "pj": redirecthtml = "./programmingusingjava.html" if sessionid: redirecthtml = redirecthtml + "?s=" + str(sessionid) self.redirect(redirecthtml)
def post(self): userservice = TinkerAcademyUserService() sessionid = userservice.anonlogin() cacheservice = MemcacheService() self.redirect('/programmingusingjava.html?s=' + str(sessionid))
def get(self): sessionid = extractkeyfromrequest(self.request, 's') if sessionid: sessionid = sessionid.strip() user = None cacheservice = MemcacheService() if sessionid: user = cacheservice.getsessionuser(sessionid) template_values = {'sessionid': sessionid, 'user': user} if sessionid: for i in range(1, 101): template_values['quiz' + str(i) + 'submitted'] = cacheservice.getfromsession( sessionid, 'quiz' + str(i) + 'submitted') template_values['quiz' + str(i) + 'results'] = cacheservice.getfromsession( sessionid, 'quiz' + str(i) + 'results') template_values['quiz' + str(i) + 'len'] = cacheservice.getfromsession( sessionid, 'quiz' + str(i) + 'len') for i in range(1, 101): cacheservice.clearfromsession(sessionid, 'quiz' + str(i) + 'submitted') cacheservice.clearfromsession(sessionid, 'quiz' + str(i) + 'results') cacheservice.clearfromsession(sessionid, 'quiz' + str(i) + 'len') template = JINJA_ENVIRONMENT.get_template('programmingusingjava.html') self.response.write(template.render(template_values))
def get(self): sessionid = extractkeyfromrequest(self.request, 's') if sessionid: sessionid = sessionid.strip() user = None source = None cacheservice = MemcacheService() quizresults = [] hwresults = [] users = [] isadmin = False profilestudent = None if sessionid: profilestudent = cacheservice.getfromsession( sessionid, 'profilestudent') cacheservice.clearfromsession(sessionid, 'profilestudent') user = cacheservice.getsessionuser(sessionid) if not profilestudent: profilestudent = user source = translateclaztosource(profilestudent.claz) quizanswerarr = quizanswers(source) for quizint in range(1, 9): if len(quizanswerarr) > quizint: quiz = quizanswerarr[quizint] quizlen = len(quiz) if "free" in quiz: quizlen = quizlen - 1 + quizanswerarr[quizint]["free"] quizresult = getattr(profilestudent, 'quiz' + str(quizint) + 'results') if quizresult is None: quizresult = 0 quizresults.append({ 'total': quizlen, 'correct': quizresult }) hwanswerarr = hwanswers(source) for hwint in range(1, 9): if len(hwanswerarr) > hwint: hw = hwanswerarr[hwint] hwlen = len(hw) if "free" in hw: hwlen = hwlen - 1 + hwanswerarr[hwint]["free"] hwresult = getattr(profilestudent, 'hw' + str(hwint) + 'results') if hwresult is None: hwresult = 0 hwresults.append({'total': hwlen, 'correct': hwresult}) if user.isadmin: isadmin = True userservice = TinkerAcademyUserService() users = userservice.findusersinclaz(user) template_values = { 'sessionid': sessionid, 'user': profilestudent, 'quizresults': quizresults, 'hwresults': hwresults, 'users': users, 'isadmin': isadmin } template = JINJA_ENVIRONMENT.get_template('profile.html') self.response.write(template.render(template_values))
def post(self): userservice = TinkerAcademyUserService() sessionid = userservice.anonlogin() cacheservice = MemcacheService() self.redirect('/apcomputerscience.html?s=' + str(sessionid))
def get(self): sessionid = extractkeyfromrequest(self.request, 's') if sessionid: sessionid = sessionid.strip() user = None cacheservice = MemcacheService() if sessionid: user = cacheservice.getsessionuser(sessionid) template_values = {'sessionid': sessionid, 'user': user} for i in range(1, 10): template_values['quiz' + str(i) + 'submitted'] = cacheservice.getfromsession( sessionid, 'quiz' + str(i) + 'submitted') template_values['quiz' + str(i) + 'results'] = cacheservice.getfromsession( sessionid, 'quiz' + str(i) + 'results') template_values['quiz' + str(i) + 'len'] = cacheservice.getfromsession( sessionid, 'quiz' + str(i) + 'len') for i in range(1, 10): template_values['hw' + str(i) + 'submitted'] = cacheservice.getfromsession( sessionid, 'hw' + str(i) + 'submitted') template_values['hw' + str(i) + 'results'] = cacheservice.getfromsession( sessionid, 'hw' + str(i) + 'results') template_values['hw' + str(i) + 'len'] = cacheservice.getfromsession( sessionid, 'hw' + str(i) + 'len') logging.info("APComputerSciencePage template_values=" + str(template_values)) if sessionid: for i in range(1, 10): cacheservice.clearfromsession(sessionid, 'quiz' + str(i) + 'submitted') cacheservice.clearfromsession(sessionid, 'quiz' + str(i) + 'results') cacheservice.clearfromsession(sessionid, 'quiz' + str(i) + 'len') for i in range(1, 10): cacheservice.clearfromsession(sessionid, 'hw' + str(i) + 'submitted') cacheservice.clearfromsession(sessionid, 'hw' + str(i) + 'results') cacheservice.clearfromsession(sessionid, 'hw' + str(i) + 'len') template = JINJA_ENVIRONMENT.get_template('apcomputerscience.html') self.response.write(template.render(template_values))