Ejemplo n.º 1
0
def get_rev_set_raw(rev):
    qs = []
    #first object to be the description of the revision
    lect_class = LectClass.get(rev.lect_class)
    rev_desc = {
                'lecturer':rev.user.name,
                'institution':rev.user.institution,
                'title':rev.title,
                'class':lect_class.name,
                'description':rev.description,
                'created':rev.created.strftime("%B %d, %Y")
                }
    qs.append(rev_desc)
    questions = Question.gql('WHERE revision = :1',rev).fetch(100) #how do we fetch all the Qs?
    for q in questions:
        answers = Answer.gql('WHERE question=:1',q)
        ans = []
        for a in answers:
            ans.append(a.answer)
        question = {
                    'question':q.question.replace("\n","").replace("\r",""),
                    'answers':ans
                    }
        qs.append(question)
    return qs
Ejemplo n.º 2
0
def get_rev_set(rev):
    questions = Question.gql('WHERE revision = :1',rev).fetch(100) #how do we fetch all the Qs?
    qs = []
    for q in questions:
        answers = Answer.gql('WHERE question=:1',q)
        comments = QuestionComment.gql('WHERE question=:1',q)
        comments_ = []
        for c in comments:
            c_ = {
                  'comment':c.comment,
                  'ckey':c.key().__str__(),
                  'user':QAUser.get(c.ukey)
                  }
            comments_.append(c_)

        question = {
                    'question':q,
                    'qkey':q.key().__str__(),
                    'answers':answers,
                    'comments':comments_,
                    'comment_count':comments.count()
                    }
        qs.append(question)
    return qs