예제 #1
0
    def get(self):
        if self.request.get('langCode'):
            langCode = self.request.get('langCode')

            q = TopicAreas.query(TopicAreas.LangCode == langCode)
            units = q.fetch(999)

            countmap_other_language={}
            for unit in units:
                logging.info('QQQ: LangCode in clone: %s' % unit.LangCode)
                if unit.LearningUnitID not in countmap_other_language:
                    logging.info('QQQ: LearningUnitID in clone: %s' % unit.LearningUnitID)
                    countmap_other_language[unit.LearningUnitID] = 1

            q = TopicAreas.query(TopicAreas.LangCode == 'en')
            units_en = q.fetch(999)

            for unit2 in units_en:
                if unit2.LearningUnitID not in countmap_other_language:
                    logging.info('QQQ: LearningUnitID to add in clone: %s' % unit2.LearningUnitID)
                    logging.info('QQQ: LangCode to add in clone: %s' % langCode)
                    n = TopicAreas(LearningUnitID = unit2.LearningUnitID
                        , Subject = unit2.Subject
                        , Seq = unit2.Seq
                        , Name = unit2.Name
                        , LangCode = langCode
                        , Description = unit2.Description
                        , Status = 'Pending Translation'
                        )
                    n.put()
            return self.redirect('/topareas')        

        else:
            return self.redirect('/topareas')  
예제 #2
0
 def post(self):
     #logging.error('QQQ: templatecreate POST')
     Subject=self.request.get('Subject')
     n = TopicAreas(LearningUnitID = self.request.get('Name')
               , Subject=Subject
               , Name = self.request.get('Name')
               , Seq = 999
               , LangCode = 'en'
               , Description=self.request.get('Description')
               , Status = 'Pending Review'
               )
     n.put()
     return self.redirect('/topareas/create?SubjFilter=' + Subject)
예제 #3
0
    def get(self):

        if self.request.get('SubjFilter'):
            SubjFilter=self.request.get('SubjFilter')
            self.session['SubjFilter'] = SubjFilter
        else:
            SubjFilter = self.session.get('SubjFilter')
        if not SubjFilter:
            self.session['SubjFilter'] = 'all'
            SubjFilter = 'all'

        if self.request.get('TopAreaFilter'):
            TopAreaFilter=self.request.get('TopAreaFilter')
            self.session['TopAreaFilter'] = TopAreaFilter
        else:
            TopAreaFilter = self.session.get('TopAreaFilter')
        if not TopAreaFilter:
            self.session['TopAreaFilter'] = 'all'
            TopAreaFilter = 'all'

        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/aids' )
        else:
              login = users.create_login_url('/aids')

        q4 = TopicAreas.query(TopicAreas.Subject == SubjFilter)
        subjects = q4.fetch(999)
        SubjectList = []
        if subjects:
            for subject in subjects:
                SubjectList.append(subject.Name)
        else:
            SubjectList.append('none')
            
#        SubjectList = [
#            'Arithmetic and Pre-Algebra: Addition and subtraction', 
#            'Arithmetic and Pre-Algebra: Multiplication and division', 
#            'Arithmetic and Pre-Algebra: Negative numbers',
#            'Arithmetic and Pre-Algebra: Number properties',
#            'Arithmetic and Pre-Algebra: Order of operations',
#            'Arithmetic and Pre-Algebra: Factors and multiples',
#            'Arithmetic and Pre-Algebra: Fractions',
#            'Arithmetic and Pre-Algebra: Decimals',
#            'Arithmetic and Pre-Algebra: Percents',
#            'Arithmetic and Pre-Algebra: Ratios and proportions (basic)',
#            'Arithmetic and Pre-Algebra: Exponents (basic)'
#            ];		  
        self.render_template('LearnAidCreate.html', {'SubjectList': SubjectList, 'TopAreaFilter': TopAreaFilter, 'currentuser':currentuser, 'login':login, 'logout': logout})
예제 #4
0
    def get(self, unit_id):
        iden = int(unit_id)
        unit = ndb.Key('TopicAreas', iden).get()

        f = TopicAreas.query(TopicAreas.LangCode == 'en', TopicAreas.LearningUnitID == unit.LearningUnitID)
        units_en = f.get()
        
        if self.request.get('SubjFilter'):
            SubjFilter=self.request.get('SubjFilter')
            self.session['SubjFilter'] = SubjFilter
        else:
            SubjFilter = self.session.get('SubjFilter')
        if not SubjFilter:
            self.session['SubjFilter'] = 'all'
            SubjFilter = 'all'
        logging.info('QQQ: SubjFilter in Topic Grp Edit: %s' % SubjFilter)

        if self.request.get('SubjAreaFilter'):
            SubjAreaFilter=self.request.get('SubjAreaFilter')
            self.session['SubjAreaFilter'] = SubjAreaFilter
        else:
            SubjAreaFilter = self.session.get('SubjAreaFilter')
        if not SubjAreaFilter:
            self.session['SubjAreaFilter'] = 'Math'
            SubjAreaFilter = 'Math'

        q3 = Subjects.query(Subjects.Subject == SubjAreaFilter).order(Subjects.Seq)
        subjects = q3.fetch(999)
        SubjectList = []
        if subjects:
            for subject in subjects:
                SubjectList.append(subject.Name)
        else:
            SubjectList.append('none')
        
        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/topareas' )
        else:
              login = users.create_login_url('/topareas')

#        SubjectList = ['Math', 'Biology', 'Chemistry'];		  
        StatusList = ['Pending Translation', 'Pending Review', 'Published'];		  
        self.render_template('LearnTopicAreaEdit.html', {'unit': unit, 'units_en': units_en, 'SubjectList': SubjectList, 'StatusList': StatusList, 'currentuser':currentuser, 'login':login, 'logout': logout})
예제 #5
0
    def get(self, aid_id):
        iden = int(aid_id)
        aid = ndb.Key('LearnAids', iden).get()

        f = LearnAids.query(LearnAids.LangCode == 'en', LearnAids.LearnAidID == aid.LearnAidID)
        units_en = f.get()

        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/aids' )
        else:
              login = users.create_login_url('/aids')

        if self.request.get('SubjFilter'):
            SubjFilter=self.request.get('SubjFilter')
            self.session['SubjFilter'] = SubjFilter
        else:
            SubjFilter = self.session.get('SubjFilter')
        if not SubjFilter:
            self.session['SubjFilter'] = 'all'
            SubjFilter = 'all'
        logging.info('QQQ: SubjFilter in Topic Grp Edit: %s' % SubjFilter)

        q4 = TopicAreas.query(TopicAreas.Subject == SubjFilter)
        subjects = q4.fetch(999)
        SubjectList = []
        if subjects:
            for subject in subjects:
                SubjectList.append(subject.Name)
        else:
            SubjectList.append('none')

        StatusList = ['Pending Translation', 'Pending Review', 'Published'];		  
        VideoStatusList = ['Pending Translation', 'Pending Review', 'Published'];		  
        self.render_template('LearnAidEdit.html', {'aid': aid, 'units_en':units_en, 'SubjectList': SubjectList, 'StatusList': StatusList, 'VideoStatusList': VideoStatusList, 'currentuser':currentuser, 'login':login, 'logout': logout})
예제 #6
0
    def get(self):
#        AidSubjRecalc()
        AidSeqPop()
#        AidSeqRecalc()
        languages = memcache.get("languages")
        if languages is not None:
            logging.info("get languages from memcache.")
        else:
            q = Languages.query().order(Languages.langName)
            languages = q.fetch(99)
            logging.info("Can not get languages from memcache.")
            if not memcache.add("languages", languages, 10):
                logging.info("Memcache set failed.")

        if self.request.get('langCode'):
            langCode=self.request.get('langCode')
            self.session['langCode'] = langCode
        else:
            langCode = self.session.get('langCode')
        if not langCode:
            self.session['langCode'] = 'en' 
            langCode = 'en'

        langName = 'no language'
        for language in languages:
            if language.langCode == langCode:
                langName = language.langName

        if self.request.get('StatusFilter'):
            StatusFilter=self.request.get('StatusFilter')
            self.session['StatusFilter'] = StatusFilter
        else:
            StatusFilter = self.session.get('StatusFilter')
        if not StatusFilter:
            self.session['StatusFilter'] = 'all'
            StatusFilter = 'all'

        if self.request.get('SubjFilter'):
            SubjFilter=self.request.get('SubjFilter')
            self.session['SubjFilter'] = SubjFilter
        else:
            SubjFilter = self.session.get('SubjFilter')
        if not SubjFilter:
            self.session['SubjFilter'] = 'all'
            SubjFilter = 'all'

        if self.request.get('TopAreaFilter'):
            TopAreaFilter=self.request.get('TopAreaFilter')
            self.session['TopAreaFilter'] = TopAreaFilter
        else:
            TopAreaFilter = self.session.get('TopAreaFilter')
        if not TopAreaFilter:
            self.session['TopAreaFilter'] = 'all'
            TopAreaFilter = 'all'

        count_en = 0
        langCode_en = 'en'
        q = LearnAids.query(LearnAids.LangCode == langCode_en)
        aids = q.fetch(999)
        for aid in aids:
            logging.info('QQQ: count_en: %d' % count_en)
            count_en = count_en + 1
        logging.info('QQQ: Total count_en: %d' % count_en)

        logging.info('QQQ: langCode: %s' % langCode)
        count_other_language = 0
        q2 = LearnAids.query(LearnAids.LangCode == langCode)
        aidsx = q2.fetch(999)
        for aid in aidsx:
            logging.info('QQQ: count_other_language: %d' % count_other_language)
            count_other_language = count_other_language + 1
        logging.info('QQQ: Total count_other_language: %d' % count_other_language)

        logging.info('GGG: StatusFilter in LearnAidList: %s' % StatusFilter)
        if StatusFilter == 'all':
            if TopAreaFilter == 'all':
                q = LearnAids.query(LearnAids.LangCode == langCode).order(LearnAids.Seq, LearnAids.LearnAidID)
            else:
                q = LearnAids.query(LearnAids.LangCode == langCode, LearnAids.Subject == TopAreaFilter).order(LearnAids.Seq, LearnAids.LearnAidID)
        else:
            if TopAreaFilter == 'all':
                q = LearnAids.query(LearnAids.LangCode == langCode, LearnAids.Status == StatusFilter).order(LearnAids.Seq, LearnAids.LearnAidID)
            else:
                q = LearnAids.query(LearnAids.LangCode == langCode, LearnAids.Status == StatusFilter, LearnAids.Subject == TopAreaFilter).order(LearnAids.Seq, LearnAids.LearnAidID)
        aids = q.fetch(999)

        if StatusFilter == 'all':
            if TopAreaFilter == 'all':
                f = LearnAids.query(LearnAids.LangCode == 'en')
            else:
                f = LearnAids.query(LearnAids.LangCode == 'en', LearnAids.Subject == TopAreaFilter)
        else:
            if TopAreaFilter == 'all':
                f = LearnAids.query(LearnAids.LangCode == 'en', LearnAids.Status == StatusFilter)
            else:
                f = LearnAids.query(LearnAids.LangCode == 'en', LearnAids.Status == StatusFilter, LearnAids.Subject == TopAreaFilter)
        units_en = f.fetch(999)
        
        dict_units_en = {}
        for unit_en in units_en:
#            logging.info('GGG: Subjects.py/LearningUnitID: %s' % unit_en.LearningUnitID)
#            logging.info('GGG: Subjects.py/Description: %s' % unit_en.Description)
            dict_units_en[unit_en.LearnAidID] = unit_en.Description

        q4 = TopicAreas.query(TopicAreas.Subject == SubjFilter)
        subjects = q4.fetch(999)
        SubjectList = []
        if subjects:
            for subject in subjects:
                SubjectList.append(subject.Name)
        else:
            SubjectList.append('none')

        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/aids' )
        else:
              login = users.create_login_url('/aids')

        StatusList = ['Pending Translation', 'Pending Review', 'Published'];
        VideoStatusList = ['Pending Translation', 'Pending Review', 'Published'];

        self.render_template('LearnAidListEdit.html', {'aids': aids, 'count_en': count_en, 'count_other_language': count_other_language, 'StatusList':StatusList, 'VideoStatusList':VideoStatusList, 'StatusFilter':StatusFilter, 'SubjFilter':SubjFilter, 'SubjectList':SubjectList, 'TopAreaFilter':TopAreaFilter, 'dict_units_en':dict_units_en, 'languages':languages, 'langCode':langCode, 'langName':langName, 'currentuser':currentuser, 'login':login, 'logout': logout})
예제 #7
0
    def get(self):
        languages = memcache.get("languages")
        if languages is not None:
            logging.info("get languages from memcache.")
        else:
            q = Languages.query().order(Languages.langName)
            languages = q.fetch(99)
            logging.info("Can not get languages from memcache.")
            if not memcache.add("languages", languages, 10):
                logging.info("Memcache set failed.")

        if self.request.get('langCode'):
            langCode=self.request.get('langCode')
            self.session['langCode'] = langCode
        else:
            langCode = self.session.get('langCode')
        if not langCode:
            self.session['langCode'] = 'en' 
            langCode = 'en'

        langName = 'no language'
        for language in languages:
            if language.langCode == langCode:
                langName = language.langName

        if self.request.get('StatusFilter'):
            StatusFilter=self.request.get('StatusFilter')
            self.session['StatusFilter'] = StatusFilter
        else:
            StatusFilter = self.session.get('StatusFilter')
        if not StatusFilter:
            self.session['StatusFilter'] = 'all'
            StatusFilter = 'all'

        if self.request.get('SubjFilter'):
            SubjFilter=self.request.get('SubjFilter')
            self.session['SubjFilter'] = SubjFilter
        else:
            SubjFilter = self.session.get('SubjFilter')
        if not SubjFilter:
            self.session['SubjFilter'] = 'all'
            SubjFilter = 'all'

        count_en = 0
        langCode_en = 'en'
        q = TopicAreas.query(TopicAreas.LangCode == langCode_en)
        units = q.fetch(999)
        for unit in units:
            logging.info('QQQ: count_en: %d' % count_en)
            count_en = count_en + 1
        logging.info('QQQ: Total count_en: %d' % count_en)

        logging.info('QQQ: langCode: %s' % langCode)
        count_other_language = 0
        q2 = TopicAreas.query(TopicAreas.LangCode == langCode)
        unitsx = q2.fetch(999)
        for unit in unitsx:
            logging.info('QQQ: count_other_language: %d' % count_other_language)
            count_other_language = count_other_language + 1
        logging.info('QQQ: Total count_other_language: %d' % count_other_language)

        logging.info('GGG: StatusFilter in LearnUnitList: %s' % StatusFilter)
        if StatusFilter == 'all':
            if SubjFilter == 'all':
                q = TopicAreas.query(TopicAreas.LangCode == langCode).order(TopicAreas.Seq, TopicAreas.LearningUnitID)
            else:
                q = TopicAreas.query(TopicAreas.LangCode == langCode, TopicAreas.Subject == SubjFilter).order(TopicAreas.Seq, TopicAreas.LearningUnitID)
        else:
            if SubjFilter == 'all':
                q = TopicAreas.query(TopicAreas.LangCode == langCode, TopicAreas.Status == StatusFilter).order(TopicAreas.Seq, TopicAreas.LearningUnitID)
            else:
                q = TopicAreas.query(TopicAreas.LangCode == langCode, TopicAreas.Status == StatusFilter, TopicAreas.Subject == SubjFilter).order(TopicAreas.Seq, TopicAreas.LearningUnitID)

        units = q.fetch(999)

        q4 = Subjects.query(Subjects.LangCode == langCode, Subjects.Subject == 'Math')
        subjects = q4.fetch(999)
        SubjectList = []
        if subjects:
            for subject in subjects:
                SubjectList.append(subject.Name)
        else:
            SubjectList.append('none')
            
        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/topareas' )
        else:
              login = users.create_login_url('/topareas')

        StatusList = ['Pending Translation', 'Pending Review', 'Published'];
#        SubjectList = ['Math', 'Science'];	
        self.render_template('LearnTopicAreaList.html', {'units': units, 'count_en': count_en, 'count_other_language': count_other_language, 'StatusList':StatusList, 'SubjectList':SubjectList, 'StatusFilter':StatusFilter, 'SubjFilter':SubjFilter, 'languages':languages, 'langCode':langCode, 'langName':langName, 'currentuser':currentuser, 'login':login, 'logout': logout})