示例#1
0
 def get(self):
     user = users.get_current_user()
     if user:
         if self.request.get('keys'):
             try:
                 filtered = self.dictionary.filter(self.request.get('keys'), self.request.get('require'))
                         
                 self.dictionary.augment_with_rank(filtered)
                 
                 material = self.dictionary.prepare_for_quiz(filtered)
                 
             except Exception, e:
                 print Exceptions.format_exception(e)
             
             if self.errorMsg is not '':
                 self.set_cookie('error', str(self.errorMsg))
         
             self.response.out.write(json.dumps(material))    
         elif self.request.get('unit'):
             material = self.get_material(int(self.request.get('unit')) - 1, self.request.get('stage') == 'review')
             self.response.out.write(material)
         elif self.request.get('recent'):
             disciple = Disciple.get_current(user)
             material = self.dictionary.prepare_for_quiz(json.loads(disciple.recent_mastered))
             self.response.out.write(json.dumps(material))
示例#2
0
 def get(self):
     user = users.get_current_user()
     if user:
         if self.request.get('keys'):
             try:
                 filtered = self.dictionary.filter(self.request.get('keys'), self.request.get('require'))
                         
                 self.dictionary.augment_with_rank(filtered)
                 
                 material = self.dictionary.prepare_for_quiz(filtered)
                 
             except Exception, e:
                 print Exceptions.format_exception(e)
             
             if self.errorMsg is not '':
                 self.set_cookie('error', str(self.errorMsg))
         
             self.response.out.write(json.dumps(material))    
         elif self.request.get('unit'):
             material = self.get_material(int(self.request.get('unit')), self.request.get('stage') == 'review')
             self.response.out.write(material)
         elif self.request.get('recent'):
             disciple = Disciple.get_current(user)
             material = self.dictionary.prepare_for_quiz(json.loads(disciple.recent_mastered))
             self.response.out.write(json.dumps(material))
示例#3
0
 def post(self):
     """OBSOLETE Updates user profile information"""
     
     user = users.get_current_user()
     if user:
         disciple = Disciple.get_current(user)
         
         item_saving = self.request.get('item')
         
         if item_saving == 'key':
             # stage = self.request.get('stage')
             
             disciple = Disciple.get_current(user)
             disciple.tutor_max_lesson = int(self.request.get('current_lesson'))
             
         else:
             self.error(404)
         
         disciple.put()
示例#4
0
 def check_user(self):
     """Returns user profile information"""
     user = users.get_current_user()
     disciple = None
     if user:
         disciple = Disciple.get_current(user)        
     else:
         self.redirect(users.create_login_url(self.request.uri))
         
     return disciple
示例#5
0
    def check_user(self):
        """Returns user profile information"""
        user = users.get_current_user()
        disciple = None
        if user:
            disciple = Disciple.get_current(user)
        else:
            self.redirect(users.create_login_url(self.request.uri))

        return disciple
示例#6
0
 def get(self, *args):
     user = users.get_current_user()
     template_values = {}
     if user:
         logout_url = users.create_logout_url('home.html')
         disciple = Disciple.get_current(user)
         template_values['logout_url'] = logout_url;
         self.write_template('main.html', **template_values)
     else:
         loginURL = users.create_login_url(self.request.uri)
         self.redirect(loginURL)
示例#7
0
    def post(self):
        """OBSOLETE Updates user profile information"""

        user = users.get_current_user()
        if user:
            disciple = Disciple.get_current(user)

            item_saving = self.request.get('item')

            if item_saving == 'key':
                # stage = self.request.get('stage')

                disciple = Disciple.get_current(user)
                disciple.tutor_max_lesson = int(
                    self.request.get('current_lesson'))

            else:
                self.error(404)

            disciple.put()
示例#8
0
 def get(self, *args):
     user = users.get_current_user()
     template_values = {}
     if user:
         logout_url = users.create_logout_url('home.html')
         disciple = Disciple.get_current(user)
         template_values['logout_url'] = logout_url
         self.write_template('main.html', **template_values)
     else:
         loginURL = users.create_login_url(self.request.uri)
         self.redirect(loginURL)
示例#9
0
    def post(self):
        current_lesson = self.request.get('current_lesson')
        max_lesson = self.request.get('max_lesson')
        user = users.get_current_user()
        
        disciple = Disciple.get_current(user)

        disciple.tutor_max_lesson = int(max_lesson)
        disciple.tutor_current_lesson = current_lesson
        disciple.put()
           
        self.set_cookie('current_lesson', str(disciple.tutor_current_lesson))
示例#10
0
    def post(self):
        current_lesson = self.request.get('current_lesson')
        max_lesson = self.request.get('max_lesson')
        user = users.get_current_user()

        disciple = Disciple.get_current(user)

        disciple.tutor_max_lesson = int(max_lesson)
        disciple.tutor_current_lesson = current_lesson
        disciple.put()

        self.set_cookie('current_lesson', str(disciple.tutor_current_lesson))
示例#11
0
    def get(self):
        user = users.get_current_user()
        if user:
            template_args = {
                'user': user,
                'login_href': users.create_logout_url('/'),
                'login_content': 'Logout'
            }

            mode = self.request.get('mode')
            if mode == 'key':
                stage = self.request.get('stage')
                current_lesson = 1
                # unit number from the URL should override that from the database
                if (self.request.get('unit')):
                    current_lesson = int(self.request.get('unit'))
                    if (current_lesson >= len(LESSONS)):
                        current_lesson = 1
                else:
                    disciple = Disciple.get_current(user)

                isReview = (stage == 'review' or current_lesson == 1)

                config = '?unit=%d' % (current_lesson)
                if stage:
                    config += '&stage=%s' % stage

                self.set_cookie('quiz_config', str(config))
                self.set_cookie('current_lesson', current_lesson)
                self.set_cookie('is_review', isReview)

                template_args.update({
                    'current_lesson':
                    current_lesson,
                    'is_review':
                    isReview,
                    'lessonDescription':
                    LESSONS[current_lesson - 1]["description"]
                })

                self.write_template('quiz-key.html', **template_args)
            elif mode == 'word':
                # the words to be quizzed should have already been loaded into the cookie

                self.write_template('quiz-word.html', **template_args)

        else:
            self.redirect(users.create_login_url(self.request.uri))
示例#12
0
 def get(self):
     user = users.get_current_user()
     if user:
         template_args = {
                          'user': user,
                          'login_href': users.create_logout_url('/'),
                          'login_content': 'Logout'}
         
         mode = self.request.get('mode')
         if mode == 'key':
             stage = self.request.get('stage')
             current_lesson = 1
             # unit number from the URL should override that from the database
             if(self.request.get('unit')):
                 current_lesson = int(self.request.get('unit'))
                 if(current_lesson >= len(LESSONS)):
                     current_lesson = 1
             else:
                 disciple = Disciple.get_current(user)
                     
             isReview = (stage == 'review' or current_lesson == 1)
             
             config = '?unit=%d' % (current_lesson)
             if stage:
                 config += '&stage=%s' % stage
                 
             self.set_cookie('quiz_config', str(config))
             self.set_cookie('current_lesson', current_lesson)
             self.set_cookie('is_review', isReview)
             
             template_args.update({
                 'current_lesson': current_lesson,
                 'is_review': isReview,
                 'lessonDescription': LESSONS[current_lesson - 1]["description"]
             })
             
             
             self.write_template('quiz-key.html', **template_args)
         elif mode == 'word':
             # the words to be quizzed should have already been loaded into the cookie
             
             self.write_template('quiz-word.html', **template_args)
             
             
     else:
         self.redirect(users.create_login_url(self.request.uri))
示例#13
0
    def get(self):
        user = users.get_current_user()

        if user:
            logout_url = users.create_logout_url('home.html')

            disciple = Disciple.get_current(user)

            template_values = {'logout_url': logout_url}

            self.set_cookie('current_lesson',
                            str(disciple.tutor_current_lesson))
            self.write_template('tutor.html', **template_values)
        else:
            loginURL = users.create_login_url(self.request.uri)

            self.redirect(loginURL)
示例#14
0
    def get(self):
        user = users.get_current_user()

        if user:
            logout_url = users.create_logout_url('home.html')

            disciple = Disciple.get_current(user)

            template_values = {
                'logout_url': logout_url
            }

            self.set_cookie('current_lesson', str(disciple.tutor_current_lesson))
            self.write_template('tutor.html', **template_values)
        else:
            loginURL = users.create_login_url(self.request.uri)
            
            self.redirect(loginURL)
示例#15
0
    def get(self, *args):
        specific_page_requested = len(args) > 0
        user = users.get_current_user()
        template_values = {}
        if user:
            logout_url = users.create_logout_url('home.html')
            disciple = Disciple.get_current(user)
            template_values['logout_url'] = logout_url;
                      
        if specific_page_requested:
            try:
                self.write_static_template(args[0], **template_values)
            except:
                self.error(404)
                self.write_static_template("error.html", **template_values) 
        elif user:
            self.redirect('/main')
        else:
            loginURL = users.create_login_url(self.request.uri)

            template_values['loginURL'] = loginURL
            
            self.write_static_template('home.html', **template_values)     
示例#16
0
    def get(self, *args):
        specific_page_requested = len(args) > 0
        user = users.get_current_user()
        template_values = {}
        if user:
            logout_url = users.create_logout_url('home.html')
            disciple = Disciple.get_current(user)
            template_values['logout_url'] = logout_url

        if specific_page_requested:
            try:
                self.write_static_template(args[0], **template_values)
            except:
                self.error(404)
                self.write_static_template("error.html", **template_values)
        elif user:
            self.redirect('/main')
        else:
            loginURL = users.create_login_url(self.request.uri)

            template_values['loginURL'] = loginURL

            self.write_static_template('home.html', **template_values)