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)
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)
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)
def get(self): user = self.get_current_user() if not user: self.redirect('/') return key = db.Key(encoded=self.request.get('key')) qlist = QuestionList.get(key) questions = [] question_keys = [] for q in qlist.questions: question = Question.get(q) if question: question.formatted_text = mymarkdown(question.text) questions.append(question) question_keys.append(str(question.key())) edit = self.request.get("edit") if edit == 'true' and user.isTeacher(): edit = True class_list = get_teacher_classes(user) self.start_edit_question_list(qlist) else: edit = False class_list = [] goto = self.request.get("goto") if goto == None or goto == '': goto = '/' template_values = {'qlist': qlist, 'questions': questions, 'question_keys': question_keys, 'edit': edit, 'class_list': class_list, 'goto': goto, } write_template(self, user, 'question_list.html', template_values)