forked from alexaverill/Quiz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_question.php
executable file
·74 lines (69 loc) · 3.17 KB
/
new_question.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
include('header.php');
if($_POST['MCQuestion']){
$Question = new Questions;
$input = htmlspecialchars($_POST['inputquest']);
//echo $_FILES['userfile']['name'];
$usID=$user->data['user_id'];
if(strlen($_FILES['userfile']['name'])>1){
$file = new files;
$imageLocation=$file->upload($_FILES['userfile']['name'],$_FILES['userfile']['size'],$_FILES['userfile']['tmp_name'],$_FILES['userfile']['type']);
if($Question->add_question($_POST['event'],$input,$_POST['option1'],$_POST['option2'],$_POST['option3'],$_POST['option4'],$_POST['option5'],$_POST['correct_answer'],$imageLocation,3,NULL,$usID)){
echo 'Question Added';
}else{
echo 'There was an error';
}
} else if( strlen($_POST['URL'])>1){
$file = new files;
$imageLocation=$file->pull_image($_POST['URL']);
if($Question->add_question($_POST['event'],$input,$_POST['option1'],$_POST['option2'],$_POST['option3'],$_POST['option4'],$_POST['option5'],$_POST['correct_answer'],$imageLocation,3,NULL,$usID)){
echo 'Question Added';
}else{
echo 'There was an error';
}
}else{
if($Question->add_question($_POST['event'],$input,$_POST['option1'],$_POST['option2'],$_POST['option3'],$_POST['option4'],$_POST['option5'],$_POST['correct_answer'],NULL,1,NULL,$usID)){
Echo 'Question Added';
}else{
echo 'There was an error';
}
}
}
if($_POST['FRQuestion']){
$Question = new Questions;
$input = htmlspecialchars($_POST['inputquest']);
$usID=$user->data['user_id'];
if(strlen($_FILES['userfile']['name'])>1){
$file = new files;
$imageLocation=$file->upload($_FILES['userfile']['name'],$_FILES['userfile']['size'],$_FILES['userfile']['tmp_name'],$_FILES['userfile']['type']);
// add_question($eventId, $question, $a, $b, $c, $d, $e, $correct,$image, $type, $keywords, $userID)
if($Question->add_question($_POST['event'],$input,NULL,NULL,NULL,NULL,NULL,NULL,$imageLocation,4,$_POST['keywords'],$usID)){
echo 'Question Added';
}else{
echo 'There was an error';
}
} else if( strlen($_POST['URL'])>1){
$file = new files;
$imageLocation=$file->pull_image($_POST['URL']);
// add_question($eventId,$question, $a, $b, $c, $d, $e, $correct,$image, $type, $keywords, $userID)
if($Question->add_question($_POST['event'],$input,NULL,NULL,NULL,NULL,NULL,NULL,$imageLocation,4,$_POST['keywords'],$usID)){
echo 'Question Added';
}else{
echo 'There was an error';
}
}else{
if($Question->add_question($_POST['event'],$input,NULL,NULL,NULL,NULL,NULL,NULL,NULL,2,$_POST['keywords'],$usID)){
Echo 'Question Added';
}else{
echo 'There was an error';
}
}
}
if($loggedIn){
$question = new Questions;
$events = $question->return_all_events();
echo $twig->render('question_entry.html',array('EventList'=>$events));
}else{
echo '<br/><a href="../ucp.php?mode=login">Please Login to add Questions</a>';
}
?>