This gets called by editquestion.php after the standard question is saved.
165803
public function print_next_wizard_page($question, $form, $course) {
        global $CFG, $SESSION, $COURSE;

        // Catch invalid navigation & reloads.
        if (empty($question->id) && empty($SESSION->calculated)) {
            redirect('edit.php?courseid='.$COURSE->id, 'The page you are loading has expired.', 3);
        }

        // See where we're coming from.
        switch($form->wizardpage) {
            case 'question':
                require("{$CFG->dirroot}/question/type/calculated/datasetdefinitions.php");
                break;
            case 'datasetdefinitions':
            case 'datasetitems':
                require("{$CFG->dirroot}/question/type/calculated/datasetitems.php");
                break;
            default:
                print_error('invalidwizardpage', 'question');
                break;
        }
    }
167459
def RetryQuestion(question_text, output_re="", default_val=None):
  """"""
  while True:
    if default_val is not None:
      new_text = "%s [%s]: " % (question_text, default_val)
    else:
      new_text = "%s: " % question_text
    # pytype: disable=wrong-arg-count
    output = builtins.input(new_text) or str(default_val)
    # pytype: enable=wrong-arg-count
    output = output.strip()
    if not output_re or re.match(output_re, output):
      break
    else:
      print("Invalid input, must match %s" % output_re)
  return output
675941
public function getQuestion() : ?string 
    {
        if ( ! $this->hasQuestion()) {
            $this->setQuestion($this->getDefaultQuestion());
        }
        return $this->question;
    }
1162170
public function _edit_form_after_editor() {
		$post_type = get_post_type();

		if ( ! $post_type ) {
			return;
		}

		if ( false === get_post_type_object( $post_type )->public ) {
			return;
		}

		ob_start();
		include( __DIR__ . '/view/modal.php' );
		// @codingStandardsIgnoreStart
		echo ob_get_clean();
		// @codingStandardsIgnoreEnd
	}
642998
public function on_question_category_end() {
        // make sure that the category data were written by {@link self::process_question()}
        // if not, write it now. this may happen when the current category does not contain any
        // questions so the subpaths is missing completely
        if (empty($this->currentcategorywritten)) {
            $this->write_xml('question_category', $this->currentcategory, array('/question_category/id'));
        } else {
            $this->xmlwriter->end_tag('question_category');
        }
        $this->converter->set_stash('question_categories', $this->currentcategory, $this->currentcategory['id']);
    }
49323
public function getPostCreateQuestion()
    {
        $question = new Question($this->di->get("db"));

        $form       = new CreateQuestionForm($this->di);
        $form->check();

        $views = [
            ["comment/question/create-question", ["form" => $form->getHTML()], "main"],
            ["comment/question/view-all", ["questions" => $question->getQuestions(),
             "headerTitle" => "Senaste frågor"], "main"]
        ];

        $this->di->get("pageRenderComment")->renderPage([
            "views" => $views,
            "title" => "Create your question"
        ]);
    }
905352
def add_question(self, qname, rdtype, rdclass=dns.rdataclass.IN):
        

        self._set_section(QUESTION)
        before = self.output.tell()
        qname.to_wire(self.output, self.compress, self.origin)
        self.output.write(struct.pack("!HH", rdtype, rdclass))
        after = self.output.tell()
        if after >= self.max_size:
            self._rollback(before)
            raise dns.exception.TooBig
        self.counts[QUESTION] += 1
665215
public function save_question_flags() {
        global $DB;

        $transaction = $DB->start_delegated_transaction();
        $this->quba->update_question_flags();
        question_engine::save_questions_usage_by_activity($this->quba);
        $transaction->allow_commit();
    }
407508
public function onSave()
    {
        $this->validateRequestTheme();
        $type = Request::input('templateType');
        $templatePath = trim(Request::input('templatePath'));
        $template = $templatePath ? $this->loadTemplate($type, $templatePath) : $this->createTemplate($type);
        $formWidget = $this->makeTemplateFormWidget($type, $template);

        $saveData = $formWidget->getSaveData();
        $postData = post();
        $templateData = [];

        $settings = array_get($saveData, 'settings', []) + Request::input('settings', []);
        $settings = $this->upgradeSettings($settings);

        if ($settings) {
            $templateData['settings'] = $settings;
        }

        $fields = ['markup', 'code', 'fileName', 'content'];

        foreach ($fields as $field) {
            if (array_key_exists($field, $saveData)) {
                $templateData[$field] = $saveData[$field];
            }
            elseif (array_key_exists($field, $postData)) {
                $templateData[$field] = $postData[$field];
            }
        }

        if (!empty($templateData['markup']) && Config::get('cms.convertLineEndings', false) === true) {
            $templateData['markup'] = $this->convertLineEndings($templateData['markup']);
        }

        if (!empty($templateData['code']) && Config::get('cms.convertLineEndings', false) === true) {
            $templateData['code'] = $this->convertLineEndings($templateData['code']);
        }

        if (
            !Request::input('templateForceSave') && $template->mtime
            && Request::input('templateMtime') != $template->mtime
        ) {
            throw new ApplicationException('mtime-mismatch');
        }

        $template->attributes = [];
        $template->fill($templateData);
        $template->save();

        /**
         * @event cms.template.save
         * Fires after a CMS template (page|partial|layout|content|asset) has been saved.
         *
         * Example usage:
         *
         *     Event::listen('cms.template.save', function ((\Cms\Controllers\Index) $controller, (mixed) $templateObject, (string) $type) {
         *         \Log::info("A $type has been saved");
         *     });
         *
         * Or
         *
         *     $CmsIndexController->bindEvent('template.save', function ((mixed) $templateObject, (string) $type) {
         *         \Log::info("A $type has been saved");
         *     });
         *
         */
        $this->fireSystemEvent('cms.template.save', [$template, $type]);

        Flash::success(Lang::get('cms::lang.template.saved'));

        $result = [
            'templatePath'  => $template->fileName,
            'templateMtime' => $template->mtime,
            'tabTitle'      => $this->getTabTitle($type, $template)
        ];

        if ($type === 'page') {
            $result['pageUrl'] = Url::to($template->url);
            $router = new Router($this->theme);
            $router->clearCache();
            CmsCompoundObject::clearCache($this->theme);
        }

        return $result;
    }
344036
public function save_question_options($question) {
        global $DB;
        $context = $question->context;

        // Get old versions of the objects.
        $oldanswers = $DB->get_records('question_answers',
                array('question' => $question->id), 'id ASC');
        $oldoptions = $DB->get_records('question_numerical',
                array('question' => $question->id), 'answer ASC');

        // Save the units.
        $result = $this->save_units($question);
        if (isset($result->error)) {
            return $result;
        } else {
            $units = $result->units;
        }

        // Insert all the new answers.
        foreach ($question->answer as $key => $answerdata) {
            // Check for, and ingore, completely blank answer from the form.
            if (trim($answerdata) == '' && $question->fraction[$key] == 0 &&
                    html_is_blank($question->feedback[$key]['text'])) {
                continue;
            }

            // Update an existing answer if possible.
            $answer = array_shift($oldanswers);
            if (!$answer) {
                $answer = new stdClass();
                $answer->question = $question->id;
                $answer->answer = '';
                $answer->feedback = '';
                $answer->id = $DB->insert_record('question_answers', $answer);
            }

            if (trim($answerdata) === '*') {
                $answer->answer = '*';
            } else {
                $answer->answer = $this->apply_unit($answerdata, $units,
                        !empty($question->unitsleft));
                if ($answer->answer === false) {
                    $result->notice = get_string('invalidnumericanswer', 'qtype_numerical');
                }
            }
            $answer->fraction = $question->fraction[$key];
            $answer->feedback = $this->import_or_save_files($question->feedback[$key],
                    $context, 'question', 'answerfeedback', $answer->id);
            $answer->feedbackformat = $question->feedback[$key]['format'];
            $DB->update_record('question_answers', $answer);

            // Set up the options object.
            if (!$options = array_shift($oldoptions)) {
                $options = new stdClass();
            }
            $options->question = $question->id;
            $options->answer   = $answer->id;
            if (trim($question->tolerance[$key]) == '') {
                $options->tolerance = '';
            } else {
                $options->tolerance = $this->apply_unit($question->tolerance[$key],
                        $units, !empty($question->unitsleft));
                if ($options->tolerance === false) {
                    $result->notice = get_string('invalidnumerictolerance', 'qtype_numerical');
                }
            }
            if (isset($options->id)) {
                $DB->update_record('question_numerical', $options);
            } else {
                $DB->insert_record('question_numerical', $options);
            }
        }

        // Delete any left over old answer records.
        $fs = get_file_storage();
        foreach ($oldanswers as $oldanswer) {
            $fs->delete_area_files($context->id, 'question', 'answerfeedback', $oldanswer->id);
            $DB->delete_records('question_answers', array('id' => $oldanswer->id));
        }
        foreach ($oldoptions as $oldoption) {
            $DB->delete_records('question_numerical', array('id' => $oldoption->id));
        }

        $result = $this->save_unit_options($question);
        if (!empty($result->error) || !empty($result->notice)) {
            return $result;
        }

        $this->save_hints($question);

        return true;
    }
932354
public function process_extraanswerdata($data) {
        global $DB;

        $extra = $this->qtypeobj->extra_answer_fields();
        $tablename = array_shift($extra);

        $oldquestionid = $this->get_old_parentid('question');
        $questioncreated = $this->get_mappingid('question_created', $oldquestionid) ? true : false;

        if ($questioncreated) {
            $data['answerid'] = $this->get_mappingid('question_answer', $data['id']);
            $DB->insert_record($tablename, $data);
        } else {
            $DB->update_record($tablename, $data);
        }
    }
403783
public function afterDelete()
    {
        $this->user->extend->updateCounters(['questions' => -1]);
        Answer::deleteAll(['question_id' => $this->id]);
        parent::afterDelete();
    }
1207602
public function callbackQuestion()
    {
        // Get values from the submitted form
        $this->user->question = $this->form->value("answer");
        $this->form->addOutput("Du har ändrat svaret på din kontrollfråga till `{$this->user->question}`");
        $this->user->save();
        return true;
    }
885249
public function page_after_submit() {
        global $CFG;
        require_once($CFG->libdir . '/filelib.php');

        $pageaftersubmit = $this->get_feedback()->page_after_submit;
        if (empty($pageaftersubmit)) {
            return null;
        }
        $pageaftersubmitformat = $this->get_feedback()->page_after_submitformat;

        $context = context_module::instance($this->get_cm()->id);
        $output = file_rewrite_pluginfile_urls($pageaftersubmit,
                'pluginfile.php', $context->id, 'mod_feedback', 'page_after_submit', 0);

        return format_text($output, $pageaftersubmitformat, array('overflowdiv' => true));
    }
1250658
public function onAfterWrite()
    {
        parent::onAfterWrite();
        $owner = $this->owner;

        $owner->writePresets();

        if ($owner->ClassName == 'PlaceablePage') {
            // Save fields to related regions and blocks
            foreach ($owner->PageFields as $region) {
                $regionObject = $region->DataObject;
                foreach ($region->Fields as $field) {
                    if (isset($_POST["$field->name"])) {
                        $regionObject->{$field->original_name} = $_POST["$field->name"];
                    }
                }
                $regionObject->forceChange()->write();
                foreach ($region->Blocks as $block) {
                    $blockObject = $block->DataObject;
                    foreach ($block->Fields as $field) {
                        if (isset($_POST["$field->name"])) {
                            $blockObject->{$field->original_name} = $_POST["$field->name"];
                        }
                    }
                    $blockObject->forceChange()->write();
                }
            }
        }
    }
90435
public function questionsAction()
    {
        $this->addSnippet('Survey\\SurveyQuestionsSnippet',
                'menu', $this->menu,
                'surveyId', $this->_getParam(\Gems_Model::SURVEY_ID),
                'trackId', $this->_getIdParam()
                );
    }
624226
@Override
    public void processIOSettingQuestion(IOSetting setting) {
        // post the question
        if (setting.getLevel().ordinal() <= this.level.ordinal()) {
            String answer = setting.getSetting();

            if (setting instanceof BooleanIOSetting) {
                int n = JOptionPane.showConfirmDialog(frame, setting.getQuestion(), setting.getName(),
                        JOptionPane.YES_NO_OPTION);
                if (n == JOptionPane.YES_OPTION) {
                    answer = "true";
                } else if (n == JOptionPane.NO_OPTION) {
                    answer = "false";
                } else {
                    // default of setting
                }
            } else if (setting instanceof OptionIOSetting) {
                OptionIOSetting optionSetting = (OptionIOSetting) setting;
                List<String> settings = optionSetting.getOptions();
                Iterator<String> elements = settings.iterator();
                Object[] options = new Object[settings.size()];
                for (int i = 0; i < options.length; i++) {
                    options[i] = elements.next();
                }
                int n = JOptionPane.showOptionDialog(frame, setting.getQuestion(), setting.getName(),
                        JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, setting.getSetting());
                answer = (String) options[n];
            } else if (setting instanceof StringIOSetting) {
                answer = JOptionPane.showInputDialog(frame, setting.getQuestion(), setting.getName(),
                        JOptionPane.QUESTION_MESSAGE, null, null, setting.getSetting()).toString();
            } else {
                answer = JOptionPane.showInputDialog(frame, setting.getQuestion(), setting.getName(),
                        JOptionPane.QUESTION_MESSAGE, null, null, setting.getSetting()).toString();
            }

            try {
                setting.setSetting(answer);
            } catch (CDKException exception) {
            }
        } // else skip question

    }