Hey Guys!
I try to write a POST-Method where you can upload a question into my moodle database.
So it goes like this:
The student submits a form with a question. Then the new information is being uploaded in the table “mdl_question” which gives every new entry an “id” by AUTO_INCREMENT.
The next step is: They click on a second “form” which isn’t really a form for them, but more of a butten which then uploads certain information into the columns of another table called “mdl_qtype_multichoice_options”.
The pivot point here is, that the table “mdl_qtyp…” has a column which is called “questionid”. Now: every two uploads shall have the same number –[B] mdl_choice:id = mdl_qtype_multichoice_options:questionid
How do I do that? I have my code here:
<?php
if(isset($_GET[“page”])) {
if($
$sin = 1;
$sa = 1;
$an = “abc”;
$verbindung = mysql_connect(“——“, “——“, “——-“)
or die(“Entschuldigen sie, es entstand ein Fehler im System.”);
mysql_select_db(“moodle”)
or die (“Verbindung zur Datenbank war nicht möglich.”);
$id = “SELECT id FROM mdl_question ORDER BY id DESC LIMIT 1”;
$eintrag = “INSERT INTO mdl_qtype_multichoice_options
(single, shuffleanswers, answernumbering, questionid)
VALUES
(‘$sin’, ‘$sa’, ‘$an’, ‘$id’)”;
$eintragen = mysql_query($eintrag);
if ($eintragen == true) {
echo “Vielen Dank für ihr Vertrauen in Get2Med. Wir melden uns in Kürze bei ihnen! <a href=”index.html”>Zurück</a>”;
}
else {
echo “Fehler im System, bitte versuchen sie es später noch einmal.”;
}
mysql_close($verbindung);
}
}
?>
I’m grateful for any help! :-)))