function insertQuestion()
{
    global $g_db, $f_question_time_donotuse, $f_question_time, $f_answercount, $f_subjectid, $f_questionid, $f_question_type, $f_question_type2, $f_question_text, $f_answer_correct, $f_answer_percents, $f_answer_text, $f_question_points, $i_nAnswerCount1, $f_testid, $DOCUMENT_PAGES, $srv_settings;
    $f_question_time_donotuse = true;
    $f_question_time = 0;
    $f_answercount = $i_nAnswerCount1;
    if (!isset($f_question_type)) {
        $f_question_type = QUESTION_TYPE_MULTIPLECHOICE;
    }
    if (!isset($f_question_type2)) {
        $f_question_type2 = QUESTION_TYPE_MULTIPLECHOICE;
    }
    switch ($f_question_type) {
        case QUESTION_TYPE_MULTIPLECHOICE:
        case QUESTION_TYPE_MULTIPLEANSWER:
            for ($i = 1; $i <= $f_answercount; $i++) {
                if (!isset($f_answer_correct[$i])) {
                    $f_answer_correct[$i] = '';
                }
                if (!isset($f_answer_percents[$i])) {
                    $f_answer_percents[$i] = '';
                }
            }
            break;
    }
    if (!isset($f_question_points)) {
        $f_question_points = 1;
    }
    $f_question_shufflea = IGT_SHUFFLE_ANSWERS_INHERIT;
    if (empty($f_subjectid)) {
        $f_subjectid = 0;
        $i_rSet1 = $g_db->Execute("SELECT subjectid FROM " . $srv_settings['table_prefix'] . "tests WHERE testid=" . $f_testid);
        if (!$i_rSet1) {
            showDBError(__FILE__, 1);
        } else {
            if (!$i_rSet1->EOF) {
                $f_subjectid = (int) $i_rSet1->fields["subjectid"];
            }
            $i_rSet1->Close();
        }
    }
    if ($g_db->Execute("INSERT INTO " . $srv_settings['table_prefix'] . "questions (subjectid, question_pre, question_post, question_text, question_solution) VALUES(" . $f_subjectid . ", '', '', '', '')") === false) {
        showDBError(__FILE__, 2);
    }
    $f_questionid = (int) $g_db->Insert_ID($srv_settings['table_prefix'] . 'questions', 'questionid');
    createQuestionLink($f_testid, $f_questionid);
    include $DOCUMENT_PAGES . "edit_questions-3-int.inc.php";
    unset($f_question_time_donotuse);
    unset($f_question_time);
    unset($f_answercount);
    unset($f_subjectid);
    unset($f_questionid);
    unset($f_question_type);
    unset($f_question_type2);
    unset($f_question_text);
    if (is_array($f_answer_correct)) {
        foreach ($f_answer_correct as $key => $val) {
            unset($f_answer_correct[$key]);
        }
    }
    unset($f_answer_correct);
    if (is_array($f_answer_percents)) {
        foreach ($f_answer_percents as $key => $val) {
            unset($f_answer_percents[$key]);
        }
    }
    unset($f_answer_percents);
    foreach ($f_answer_text as $key => $val) {
        unset($f_answer_text[$key]);
    }
    unset($f_answer_text);
    unset($f_question_points);
}
<?php

$f_testid = (int) readGetVar('testid');
if ($f_testid) {
    $i_subjectid = 0;
    $i_rSet1 = $g_db->Execute("SELECT subjectid FROM " . $srv_settings['table_prefix'] . "tests WHERE testid={$f_testid}");
    if (!$i_rSet1) {
        showDBError(__FILE__, 1);
    } else {
        if (!$i_rSet1->EOF) {
            $i_subjectid = (int) $i_rSet1->fields['subjectid'];
        }
        $i_rSet1->Close();
    }
    if ($g_db->Execute("INSERT INTO " . $srv_settings['table_prefix'] . "questions (subjectid, question_pre, question_post, question_text, question_solution) VALUES(" . $i_subjectid . ", '', '', '', '')") === false) {
        showDBError(__FILE__, 2);
    }
    $i_questionid = (int) $g_db->Insert_ID($srv_settings['table_prefix'] . 'questions', 'questionid');
    createQuestionLink($f_testid, $i_questionid);
    gotoLocation('question-bank.php' . getURLAddon('?action=editq&questionid=' . $i_questionid, array('action', 'questionid')));
} else {
    if ($g_db->Execute("INSERT INTO " . $srv_settings['table_prefix'] . "questions (question_pre, question_post, question_text, question_solution) VALUES('', '', '', '')") === false) {
        showDBError(__FILE__, 3);
    }
    $i_questionid = (int) $g_db->Insert_ID($srv_settings['table_prefix'] . 'questions', 'questionid');
    gotoLocation('question-bank.php' . getURLAddon('?action=editq&questionid=' . $i_questionid, array('action', 'questionid')));
}