def post(self): headers = {'Content-Type': 'application/json'} args = parser.parse_args() name = args['name'] ranker = args['ranker'] params = args['params'] dataset = args['dataset'] deadline = args['deadline'] doc_scores = args['doc_scores'] num_results = args['num_results'] assignment = Assignment() assignment.name = name assignment.owner = User.objects(id=session['user_id']).first() assignment.ranker = ranker assignment.params = params assignment.dataset = Dataset.objects(id=dataset).first() assignment.annotators = User.objects() assignment.statuses = { str(anno.id): False for anno in assignment.annotators } assignment.deadline = deadline assignment.num_results = num_results assignment.save() return str(assignment.id)
def post(self): check_role('instructor') args = parser.parse_args() queries = [q for q in args['query[]'] if q != ''] if not queries: flash('Empty Query!') return redirect(url_for('instructorapi')) ranker = args['ranker'] assignment_name = args['assignment_name'] dataset_name = args['ds_name'] params = self.generate_params_dict(ranker, args['param[]']) num_results = args['num_results'] instructor = User.objects(email=current_user.email).first() dataset = DataSet.objects(name=dataset_name).first() assignment = Assignment(name=assignment_name, instructor=instructor, data_set=dataset, ranker=ranker, params=params, num_results=num_results) try: assignment.save() except (NotUniqueError, ValidationError): flash('Invalid Input!') return redirect(url_for('instructorapi')) q = self.generate_queries(queries) assignment.update(queries=q) assignment.update(queries_need_to_show=q) try: self.search(assignment, dataset_name, queries, ranker, params, num_results) except Exception as e: print(e) flash('Assignment Created!') return redirect(url_for('instructorapi'))