Пример #1
0
 def get_chapters(self):
     chapters = []
     for key in self.chapters:
         chapter = Chapter.get(key)
         chapter.questions = list_questions(chapter)
         chapters.append(chapter)
     return chapters
Пример #2
0
    def get(self):

        user = self.get_current_user()
        if not user:
            self.redirect('/')
            return
        
        encoded_chapter_key = self.request.get('chapter')
        chapter, encoded_chapter_key = get_chapter_by_encoded_key(encoded_chapter_key)

        questions = list_questions(chapter)
        for q in questions:
            if q.refresh:
                text = q.text
                set_question_text(chapter, q, text, True)
            q.formatted_text = mymarkdown(q.text)
        
        has_questions = len(questions) > 0
        has_text = chapter.text and len(chapter.text) > 0
        template_values = {
                           'questions' : questions,
                           'has_questions' : has_questions,
                           'has_text': has_text,
                           }
        add_chapter_values(template_values, chapter)
        template_values['title'] = 'Edit chapter ' + chapter.title
        
        write_template(self, user, 'chapter_edit.html',template_values)
Пример #3
0
 def get(self):
     user = self.get_current_student()
     if not user:
         self.redirect('/')
         return
     
     encoded_chapter_key = self.request.get('chapter')
     chapter, encoded_chapter_key = get_chapter_by_encoded_key(encoded_chapter_key)
     
     encoded_course_key = self.request.get('course')
     course = Course.get(db.Key(encoded=encoded_course_key))
     
     if not course.has_chapter(chapter):
         self.redirect('/studentcoursepage?course='+encoded_course_key)
     
     subchapters = chapter.subchapters()
     subchapters_empty = len(subchapters) == 0
     parents = list_parents(chapter)
     parents.reverse()
     
     if chapter.text != None:
         chapter_formatted_text = mymarkdown(chapter.text)
     else:
         chapter_formatted_text = ''
         
     questions = list_questions(chapter)
     for q in questions:
         q.result = get_result(user,q)
         q.formatted_text = mymarkdown(q.text)
         
     has_questions = len(questions) > 0
     
     template_values = {
                        'subchapters': subchapters,
                        'subchapters_empty': subchapters_empty,
                        'parents' : parents,
                        'chapter_formatted_text' : chapter_formatted_text,
                        'questions' : questions,
                        'has_questions' : has_questions,
                        'course' : course,
                        }
     
     add_chapter_values(template_values, chapter)
     
     write_template(self, user, 'student_chapter.html',template_values)
Пример #4
0
 def get(self):
     user = self.get_current_user()
     if not user:
         self.redirect('/')
         return
     
     encoded_chapter_key = self.request.get('chapter')
     
     chapter, encoded_chapter_key = get_chapter_by_encoded_key(encoded_chapter_key)
     subchapters = list_edit_chapters(user, chapter)
     subchapters_empty = len(subchapters) == 0
     parents = list_parents(chapter)
     parents.reverse()
     
     if chapter.text != None:
         if chapter.refresh:
             text = chapter.text
             set_chapter_text(chapter, text, True)
         chapter_formatted_text = mymarkdown(chapter.text)
     else:
         chapter_formatted_text = ''
         
     questions = list_questions(chapter)
     for q in questions:
         if q.refresh:
             text = q.text
             set_question_text(chapter, q, text, True)
         q.formatted_text = mymarkdown(q.text)
     
     has_questions = len(questions) > 0
     
     template_values = {
                        'subchapters': subchapters,
                        'subchapters_empty': subchapters_empty,
                        'parents' : parents,
                        'chapter_formatted_text' : chapter_formatted_text,
                        'questions' : questions,
                        'has_questions' : has_questions,
                        }
     
     add_chapter_values(template_values, chapter)
     
     write_template(self, user, 'chapter.html',template_values)