List questions in a quiz or a submission.

        Returns the list of QuizQuestions in this quiz.
432507
def list_questions_in_quiz_or_submission(self, quiz_id, course_id, quiz_submission_attempt=None, quiz_submission_id=None):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """ID"""
        path["course_id"] = course_id

        # REQUIRED - PATH - quiz_id
        """ID"""
        path["quiz_id"] = quiz_id

        # OPTIONAL - quiz_submission_id
        """If specified, the endpoint will return the questions that were presented
        for that submission. This is useful if the quiz has been modified after
        the submission was created and the latest quiz version's set of questions
        does not match the submission's.
        NOTE: you must specify quiz_submission_attempt as well if you specify this
        parameter."""
        if quiz_submission_id is not None:
            params["quiz_submission_id"] = quiz_submission_id

        # OPTIONAL - quiz_submission_attempt
        """The attempt of the submission you want the questions for."""
        if quiz_submission_attempt is not None:
            params["quiz_submission_attempt"] = quiz_submission_attempt

        self.logger.debug("GET /api/v1/courses/{course_id}/quizzes/{quiz_id}/questions with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("GET", "/api/v1/courses/{course_id}/quizzes/{quiz_id}/questions".format(**path), data=data, params=params, all_pages=True)
647365
public String getQuestion() {
    if (InputElement_Type.featOkTst && ((InputElement_Type)jcasType).casFeat_question == null)
      jcasType.jcas.throwFeatMissing("question", "edu.cmu.lti.oaqa.framework.types.InputElement");
    return jcasType.ll_cas.ll_getStringValue(addr, ((InputElement_Type)jcasType).casFeatCode_question);}
893140
def post(self, request, question_level, question_number, format=None):
        
        user = User.objects.get(username=request.user.username)
        question = Question.objects.filter(question_level=question_level).filter(question_number=question_number)
        if int(user.profile.user_access_level) < int(question_level):
            content = {'user_nick':profile.user_nick, 'please move along': 'Nothing to see here' }
            return Response(content, status=status.HTTP_406_NOT_ACCEPTABLE)

        time_last = None
        time_last_query = Comment.objects.filter(comment_user__username=request.user.username).order_by('comment_timestamp').last()
        if time_last_query:
            time_last = time_last_query.comment_timestamp
        time_limit = self.get_contest_consecutive_submission_halt_time() # the halt time for submission is kept same as submission halt time

#        print time_last, time_limit, datetime.datetime.now(), time_limit <= datetime.datetime.now()

        if(time_last is None or time_last + time_limit <= datetime.datetime.now()):

            serializer = CommentSerializer(data=request.data)
            if not request.data['comment_message'] or len(str(request.data['comment_message'])) >= 255:
                content = {'user_nick':profile.user_nick, 'Try to submit something small': 'Like your Dick' }
                return Response(content, status=status.HTTP_406_NOT_ACCEPTABLE)
            if serializer.is_valid():
                serializer.save(comment_user = request.user,
                                comment_question = question[0],
                )
                checker_queue.delay(int(serializer.data['id']))
                return Response(serializer.data, status=status.HTTP_201_CREATED)
            else:
                return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
        else:
            content = {'user_nick':profile.user_nick, 'Try to submit after some time': 'Nothing to see here' }
            return Response(content, status=status.HTTP_406_NOT_ACCEPTABLE)
897032
def queryset(self, request, queryset):
        
        if self.value():
            parent = Question.objects.get(slug=self.value())
            return Choice.objects.child_of(parent).order_by('-id')
        return queryset
399176
def create(request):
    """"""

    errors = []
    success = False
    listOfResponses = ['', '', '']  # 3 Blank lines by default
    title = ''
    description = ''
    id = ''

    if request.method == 'POST':  # User saved the form
        # Retrieve parameters
        title = request.form.get('title')
        description = request.form.get('description')

        listOfResponses = []
        for rep in request.form.getlist('rep[]'):
            if rep != '':
                listOfResponses.append(rep)

        # Test if everything is ok
        if title == "":
            errors.append("Please set a title !")

        if len(listOfResponses) == 0:
            errors.append("Please set at least one response !")

        # Can we save the new question ?
        if len(errors) == 0:
            # Yes. Let save data
            curDB.execute("INSERT INTO Poll (title, description) VALUES (?, ?)", (title, description))

            # The id of the poll
            id = curDB.lastrowid

            # Insert responses
            for rep in listOfResponses:
                curDB.execute("INSERT INTO Response (pollId, title) VALUES (?, ?)", (id, rep))

            coxDB.commit()

            success = True

        # Minimum of 3 lines of questions
        while len(listOfResponses) < 3:
            listOfResponses.append('')

    return {'errors': errors, 'success': success, 'listOfResponses': listOfResponses, 'title': title, 'description': description, 'id': id}
124051
def create_single_quiz_question(self, quiz_id, course_id, question_answers=None, question_correct_comments=None, question_incorrect_comments=None, question_neutral_comments=None, question_points_possible=None, question_position=None, question_question_name=None, question_question_text=None, question_question_type=None, question_quiz_group_id=None, question_text_after_answers=None):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """ID"""
        path["course_id"] = course_id

        # REQUIRED - PATH - quiz_id
        """ID"""
        path["quiz_id"] = quiz_id

        # OPTIONAL - question[question_name]
        """The name of the question."""
        if question_question_name is not None:
            data["question[question_name]"] = question_question_name

        # OPTIONAL - question[question_text]
        """The text of the question."""
        if question_question_text is not None:
            data["question[question_text]"] = question_question_text

        # OPTIONAL - question[quiz_group_id]
        """The id of the quiz group to assign the question to."""
        if question_quiz_group_id is not None:
            data["question[quiz_group_id]"] = question_quiz_group_id

        # OPTIONAL - question[question_type]
        """The type of question. Multiple optional fields depend upon the type of question to be used."""
        if question_question_type is not None:
            self._validate_enum(question_question_type, ["calculated_question", "essay_question", "file_upload_question", "fill_in_multiple_blanks_question", "matching_question", "multiple_answers_question", "multiple_choice_question", "multiple_dropdowns_question", "numerical_question", "short_answer_question", "text_only_question", "true_false_question"])
            data["question[question_type]"] = question_question_type

        # OPTIONAL - question[position]
        """The order in which the question will be displayed in the quiz in relation to other questions."""
        if question_position is not None:
            data["question[position]"] = question_position

        # OPTIONAL - question[points_possible]
        """The maximum amount of points received for answering this question correctly."""
        if question_points_possible is not None:
            data["question[points_possible]"] = question_points_possible

        # OPTIONAL - question[correct_comments]
        """The comment to display if the student answers the question correctly."""
        if question_correct_comments is not None:
            data["question[correct_comments]"] = question_correct_comments

        # OPTIONAL - question[incorrect_comments]
        """The comment to display if the student answers incorrectly."""
        if question_incorrect_comments is not None:
            data["question[incorrect_comments]"] = question_incorrect_comments

        # OPTIONAL - question[neutral_comments]
        """The comment to display regardless of how the student answered."""
        if question_neutral_comments is not None:
            data["question[neutral_comments]"] = question_neutral_comments

        # OPTIONAL - question[text_after_answers]
        """no description"""
        if question_text_after_answers is not None:
            data["question[text_after_answers]"] = question_text_after_answers

        # OPTIONAL - question[answers]
        """no description"""
        if question_answers is not None:
            data["question[answers]"] = question_answers

        self.logger.debug("POST /api/v1/courses/{course_id}/quizzes/{quiz_id}/questions with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("POST", "/api/v1/courses/{course_id}/quizzes/{quiz_id}/questions".format(**path), data=data, params=params, single_item=True)
25013
def _load_simple_section_questions(self, item_ids):
        
        self._insert_part_map(
            get_default_part_map(self._assessment_part_id,
                                 0,
                                 self._assessment_part.are_items_sequential()))
        lookup_session = self._get_item_lookup_session()
        items = lookup_session.get_items_by_ids(item_ids)
        display_num = 1
        for item in items:
            question_id = item.get_question().get_id()
            self._my_map['questions'].append(get_default_question_map(
                item.get_id(),
                question_id,
                self._assessment_part_id,
                [display_num]))
            display_num += 1
        self._save()
973191
def get_question(self):
        
        question_map = dict(self._my_map['question'])
        question_map['learningObjectiveIds'] = self._my_map['learningObjectiveIds']
        return Question(osid_object_map=question_map,
                        runtime=self._runtime,
                        proxy=self._proxy)
1301156
def question_fetchable(self, **kwargs):
        
        return util.Fetchable(QuestionFetcher(
            self._session, self.username,
            is_user=self.is_logged_in_user, **kwargs
        ))
131443
def questions
      extracted_questions = []

      unless self.qp_questions.nil?
        self.qp_questions.each do |question|   
          extracted_questions.push(Question.new(question))
        end           
      end

      return extracted_questions			
		end
209541
def get_submissions(self, course, user_input):
        

        # Build lists of wanted users based on classrooms and specific users
        list_classroom_id = [ObjectId(o) for o in user_input.aggregation]
        classroom = list(self.database.aggregations.find({"_id": {"$in": list_classroom_id}}))
        more_username = [s["students"] for s in classroom]  # Extract usernames of students
        more_username = [y for x in more_username for y in x]  # Flatten lists
        
        # Get tasks based on organisational tags
        more_tasks = []
        for org_tag in user_input.org_tags:
            if org_tag in course.get_organisational_tags_to_task():
                more_tasks += course.get_organisational_tags_to_task()[org_tag]

        #Base query
        query_base = {
                "username": {"$in": user_input.user + more_username},
                "courseid": course.get_id(),
                "taskid": {"$in": user_input.task + more_tasks}
                }

        # Additional query field
        query_advanced = {}
        if user_input.grade_min and not user_input.grade_max:
            query_advanced["grade"] = {"$gte": float(user_input.grade_min)}
        elif not user_input.grade_min and user_input.grade_max:
            query_advanced["grade"] = {"$lte": float(user_input.grade_max)}
        elif user_input.grade_min and user_input.grade_max:
            query_advanced["grade"] = {"$gte": float(user_input.grade_min), "$lte": float(user_input.grade_max)}

        try:
            date_before = datetime.strptime(user_input.date_before, "%Y-%m-%d %H:%M:%S") if user_input.date_before else ''
            date_after = datetime.strptime(user_input.date_after, "%Y-%m-%d %H:%M:%S") if user_input.date_after else ''

            if date_before and not date_after:
                query_advanced["submitted_on"] = {"$lte": date_before}
            elif not date_before and date_after:
                query_advanced["submitted_on"] = {"$gte": date_after}
            elif date_before and date_after:
                query_advanced["submitted_on"] = {"$gte": date_after, "$lte": date_before}
        except ValueError:  # If match of datetime.strptime() fails
            pass
        
        # Query with tags
        if len(user_input.filter_tags) == len(user_input.filter_tags_presence):
            for i in range(0, len(user_input.filter_tags)):
                if id_checker(user_input.filter_tags[i]):
                    state = (user_input.filter_tags_presence[i] in ["True", "true"])
                    query_advanced["tests." + user_input.filter_tags[i]] = {"$in": [None, False]} if not state else True
            
        # Mongo operations
        data = list(self.database.submissions.find({**query_base, **query_advanced}).sort([(user_input.sort_by, 
            pymongo.DESCENDING if user_input.order == "0" else pymongo.ASCENDING)]))
        data = [dict(list(f.items()) + [("url", self.submission_url_generator(str(f["_id"])))]) for f in data]

        # Get best submissions from database
        user_tasks = list(self.database.user_tasks.find(query_base, {"submissionid": 1, "_id": 0}))
        best_submissions_list = [u["submissionid"] for u in user_tasks]  # list containing ids of best submissions
        for d in data:
            d["best"] = d["_id"] in best_submissions_list  # mark best submissions

        # Keep best submissions
        if "eval" in user_input or ("eval_dl" in user_input and "download" in web.input()):
            data = [d for d in data if d["best"]]
        return data, classroom
1153424
def choice(self, question, choices, default=None, attempts=None, multiple=False):
        
        question = ChoiceQuestion(question, choices, default)

        question.set_max_attempts(attempts)
        question.set_multi_select(multiple)

        return self._io.ask_question(question)
572254
def form(**kwargs: Question):
    """"""
    return Form(*(FormField(k, q) for k, q in kwargs.items()))
1055116
def show
      @question_sheet = @answer_sheet.question_sheet
      pf = Qe.table_name_prefix
      @elements = @question_sheet.pages.collect {|p| p.elements.includes(:pages).order("#{pf}pages.number,#{pf}page_elements.position").all}.flatten
      @elements = QuestionSet.new(@elements, @answer_sheet).elements.group_by{ |e| e.pages.first }
    end
168832
def post(self, request, question_level, question_number, format=None):
        

        user = User.objects.get(username=request.user.username)
        question = Question.objects.filter(question_level=question_level).filter(question_number=question_number)
        if int(user.profile.user_access_level) < int(question_level):
            content = {'user_nick':profile.user_nick, 'please move along': 'Nothing to see here' }
            return Response(content, status=status.HTTP_406_NOT_ACCEPTABLE)

        time_last = None
        time_last_query = Submission.objects.filter(submission_user__username=request.user.username).filter(submission_question__question_level=question_level).filter(submission_question__question_number=question_number).filter(submission_state='WA').order_by('submission_timestamp').last()
        check_resubmission = AcceptedQuestion.objects.filter(record_user=request.user).filter(record_question=question)
        if check_resubmission:
            content = {'user_nick':profile.user_nick, 'Do not try to resubmit': 'Already Accepted' }
            return Response(content, status=status.HTTP_406_NOT_ACCEPTABLE)
        if time_last_query:
            time_last = time_last_query.submission_timestamp
        time_limit = self.get_contest_consecutive_submission_halt_time()

#        print time_last, time_limit, datetime.datetime.now(), time_limit <= datetime.datetime.now()

        if(time_last is None or time_last + time_limit <= datetime.datetime.now()):

            type_of_contest =  self.get_contest_type()
            type_of_submission = self.get_question_type()
            if type_of_submission != STRING:
                content = { 'user_nick':profile.user_nick, 'please move along': 'WRONG TYPE SUBMISSION'}
                return Response(content, status=status.HTTP_405_METHOD_NOT_ALLOWED)

            serializer = SubmissionSerializer(data=request.data)
            if serializer.is_valid():
                serializer.save(submission_user = request.user,
                                submission_question = self.get_object(question_level,question_number)[0],
                )
                # checker_queue.delay(int(serializer.data['id']))
                return Response(serializer.data, status=status.HTTP_201_CREATED)
            else:
                return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
        else:
            content = {'user_nick':profile.user_nick, 'Try to submit after some time': 'Nothing to see here' }
            return Response(content, status=status.HTTP_406_NOT_ACCEPTABLE)
95690
def questions(self):
        
        from .question import Question

        if self.url is None or self.question_num == 0:
            return
        for page_index in range(1, (self.question_num - 1) // 20 + 2):
            html = self._session.get(
                self.url + 'asks?page=' + str(page_index)).text
            soup = BeautifulSoup(html)
            question_links = soup.find_all('a', class_='question_link')
            question_datas = soup.find_all(
                'div', class_='zm-profile-section-main')
            for link, data in zip(question_links, question_datas):
                url = Zhihu_URL + link['href']
                title = link.text.strip()
                answer_num = int(
                    re_get_number.match(data.div.contents[4]).group(1))
                follower_num = int(
                    re_get_number.match(data.div.contents[6]).group(1))
                q = Question(url, title, follower_num, answer_num,
                             session=self._session)
                yield q
496319
def answer(self) -> str:
        
        answers = self._data['answers']
        return self.random.choice(answers)