public function add_question($eventId, $question, $a, $b, $c, $d, $e, $correct, $image, $type, $keywords, $userID) { //$type is one for MC and 2 for fill in the blank/short responses //3 is for images //$userID=$user->data['user_id']; global $dbh; $stats = new stats(); //Lets increase the number of max questions. $increase = "UPDATE Events SET maxQuestions = maxQuestions +1 WHERE id=?"; $increasing = $dbh->prepare($increase); $increasing->execute(array($eventId)); //defualt time is eastern for this area of the application date_default_timezone_set('America/New_York'); $date = date("Y-m-d H:i:s", time()); $totalMax = 0; if ($type == 1) { $sql = "INSERT INTO Questions(eventid,eventNumber,Question,optionA,optionB,optionC,optionD,optionE,correctResponse,questionType,time,userID)\n Values(?,?,?,?,?,?,?,?,?,?,?,?)"; $add = $dbh->prepare($sql); $add->execute(array($eventId, $totalMax, $question, $a, $b, $c, $d, $e, $correct, $type, $date, $userID)); } elseif ($type == 3) { $sql = "INSERT INTO Questions(eventid,eventNumber,Question,optionA,optionB,optionC,optionD,optionE,correctResponse,questionType,imageLocation,time,userID) Values(?,?,?,?,?,?,?,?,?,?,?,?,?)"; $add = $dbh->prepare($sql); $add->execute(array($eventId, $totalMax, $question, $a, $b, $c, $d, $e, $correct, $type, $image, $date, $userID)); } elseif ($type == 4) { $question = $this->check_delim($question); if (!$this->check_single_delim($question)) { //if there is more then one deliminator break. echo 'Please only use one deliminator.'; return false; } $sql = "INSERT INTO Questions(eventid,eventNumber,Question,questionType,KeyWords,imageLocation,time,userID) Values(?,?,?,?,?,?,?,?)"; $add = $dbh->prepare($sql); $add->execute(array($eventId, $totalMax, $question, $type, $keywords, $image, $date, $userID)); } else { $question = $this->check_delim($question); if (!$this->check_single_delim($question)) { //if there is more then one deliminator break. echo 'Please only use one deliminator.'; return false; } $sql = "INSERT INTO Questions(eventid,eventNumber,question,questionType,KeyWords,time,userID)Values(?,?,?,?,?,?,?)"; $add = $dbh->prepare($sql); $add->execute(array($eventId, $totalMax, $question, $type, $keywords, $date, $userID)); } //increase the total each user has submitted. $increase = $stats->increase_submitted($userID); return true; }