def question_export(): exp = Question.export_course(g.lti.get_course_id()) exp = yaml.dump(exp, default_flow_style=False) return Response(exp, mimetype="text/plain", headers={"Content-Disposition": "attachment;filename=questions_%s.yaml" % g.lti.get_course_name()})
def list_questions_table(): limit = 20 offset = 0 if 'limit' in request.args: limit = int(request.args['limit']) if 'offset' in request.args: offset = int(request.args['offset']) return Question.get_list_table(limit, offset)
def handle_question(): """Used for the feedback from inserting a question into the database, and for actually inserting questions into the database.""" isActive = request.form.get('active', "false") in ['true', 'True'] comment = request.form.get('comment', "false") in ['true', 'True'] tags = request.form.get('tags', "false") in ['true', 'True'] rating = request.form.get('rating', "false") in ['true', 'True'] Question.create_question(request.form['question'], g.lti.get_user_id(), g.lti.get_course_id(), isActive, request.form['time'], comment, tags, rating) return json.dumps({'done': True})
def import_data(): if 'file' not in request.files or not request.files['file']: return render_template('error.html', error="No file given.") #answers = request.form.get('answers', False) == 'on' data = request.files['file'].read() data = yaml.load(data) return Question.import_course(g.lti.get_user_id(), g.lti.get_course_id(), data) #, answers)
def export_data(): # TODO: settings (answers, etc?) answers = request.form.get('answers', False) == 'on' exp = Question.export_course(g.lti.get_course_id(), answers) exp = yaml.dump(exp, default_flow_style=False) return Response(exp, mimetype="text/plain", headers={"Content-Disposition": "attachment;filename=questions_%s.yaml" % g.lti.get_course_name()})
def handle_question(): """Used inserting the question into the database and its feedback.""" if 'question' not in request.args or request.args['question'] == '': return json.dumps({'done': False}) question_text = request.args['question'] isActive = request.args.get('active', "false") in ['true', 'True'] comment = request.args.get('comment', "false") in ['true', 'True'] tags = request.args.get('tags', "false") in ['true', 'True'] rating = request.args.get('rating', "false") in ['true', 'True'] Question.create_question(question_text, g.lti.get_user_id(), g.lti.get_course_id(), isActive, request.args['time'], comment, tags, rating) return json.dumps({'done': True})
def start_review(request): try: question_id = request.form['question_id'] except: return json.dumps({'Reviewable':False}) question = Question.by_id(question_id) reviewable = False if question is not None: if g.lti.is_instructor() or \ (question.get_time_left() <= 0 and question.time > 0): return QuestionController.toggle_options( {'id':question_id, 'type':'Reviewable'}) return json.dumps({'Reviewable':reviewable})
def edit_question(): return Question.edit_question(request.args['id'], request.args['text'], request.args['time'])
def delete_user_question(id): return Question.delete_userquestion(id)
def delete_question(id): return Question.delete_question(id)
def list_questions_answer(): return Question.get_list_to_answer()
def activate_question(): return Question.edit_question(request.args['id'], None, True)
def toggle_question(): """Used to toggle a question's availability.""" return Question.toggle_question(request.args['id'], request.args['field'])
def questionavailability(): return Question.availability(request.args)
def list_questions(): return Question.get_list()
def handle_question(): if g.lti.is_instructor() == False: return render_template("access_restricted.html") return Question.create_question(request.form['question'], g.lti.get_user_id(),g.lti.get_course_id(),request.form['time'])
def ask_question(): if g.lti.is_instructor() == False: return render_template("access_restricted.html") return Question.ask_question(g.lti.get_user_id())
def toggle_options(): return Question.toggle_options(request.args)
def ask_question(): """Used to asked questions to students.""" if g.lti.is_instructor() == False: return render_template("access_restricted.html") return Question.ask_question(g.lti.get_user_id())
def list_questions_asked(): return Question.get_list_asked()