include $_SERVER['DOCUMENT_ROOT'] . "/WebBuilder/WebApp.class.php";
$db = new DBMain();
echo "
name: " . $_POST['test_name'];
echo "
description: " . $_POST['test_description'];
echo "
nqf: " . $_POST['nqf_level'];
echo "
credits: " . $_POST['credits'];
echo "
Sections total: " . $_POST['sections_total'];
echo "
Passmark: " . $_POST['passmark'];
// echo "
Change value: " . $_POST['change_value'];
// var_dump($_POST['change_value']);
$comments = '';
$subtotal = '';
$record = $db->insert("INSERT INTO `tests` (`test_name`,`expiry`,`test_description`,`nqf_level`,`credits`,`passmark`) VALUES ('{$_POST['test_name']}','36','{$_POST['test_description']}','{$_POST['nqf_level']}','{$_POST['credits']}','{$_POST['passmark']}')");
$index = 0;
$test_id_res = $db->exec_query('tests', ['*'], '', '', '', '', "test_name = '{$_POST['test_name']}'");
$test_id = $test_id_res->fetch_assoc();
while ($index <= $_POST['sections_total']) {
echo "
I: " . $index;
echo "
section_name: " . $_POST["section_" . $index . "_name"];
if (strlen($_POST["section_" . $index . "_name"]) != 0) {
$section_id = $db->insert("INSERT INTO `test_questions` (`test_id`,`section_name`) VALUES ({$test_id['record_id']},'{$_POST["section_" .$index . "_name"]}')");
echo "INSERT INTO `test_questions` (`test_id`,`section_name`) VALUES ({$test_id['record_id']},'{$_POST["section_" .$index . "_name"]}')";
echo "
test_section_id: " . $section_id;
echo "
rows: " . $_POST['row_count_' . $index];
$a_index = 0;
while ($a_index <= $_POST['row_count_' . $index]) {
// echo "
QI " . $a_index;
if (strlen($_POST[$index . "_answer_$a_index"]) != 0) {
echo "
answer: " . $_POST[$index . "_answer_$a_index"];
$db->insert("INSERT INTO `test_answers` (`test_question_id`,`answer`,`option`) VALUES ($section_id,'{$_POST[$index . "_answer_$a_index"]}','{$_POST[$index . "_change_value_$a_index"]}')");
echo "
change_value: " . $_POST[$index . "_change_value_$a_index"];
echo "
" . "INSERT INTO `test_answers` (`test_question_id`,`answer`,`option`) VALUES ($section_id,'{$_POST[$index . "_answer_$a_index"]}','{$_POST[$index . "_change_value_$a_index"]}')";
}
$a_index++;
}
}
$index++;
}
echo "";