def export_course(course_id, export_answers=True):
     questions = Question.by_course_id(course_id)
     ret = []
     for question in questions:
         q = {'question': question.question}
         if export_answers:
             answers = AnswerModel.get_filtered(questionID=question.id)
             q['answers'] = []
             for x in answers:
                 q['answers'].append(x.text)
         ret.append(q)
     return ret
Beispiel #2
0
    def delete_question(qid):
        '''removes the question with the provided id from the database'''
        question = Question.by_id(int(qid))
        if g.lti.is_instructor():
            session.delete(question)
            #Delete answers
            quid = {"questionID": int(qid)}
            answers = AnswerModel.get_filtered(**quid)
            for x in answers:
                session.delete(x)
            session.commit()

        return json.dumps({'deleted': g.lti.is_instructor()})
Beispiel #3
0
    def get_filtered(self,limit=None,offset=None):
        args = self.get_args_for_filter()

        if len(args) > 0:
            if offset is None or limit is None:
                return answer.AnswerModel.get_filtered(**args)
            else:
                return answer.AnswerModel.get_filtered_offset(limit,
                                                              offset,
                                                              orderby='created',
                                                              **args)
        else:
            if offset is None or limit is None:
                return AnswerModel.get_filtered()
            else:
                return AnswerModel.get_filtered_offset(limit,
                                                       offset,
                                                       orderby='created')