-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPergunta.php
51 lines (43 loc) · 1.51 KB
/
Pergunta.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
<?php
class Pergunta{
public $id;
public $enunciado;
public $resposta;
function __construct(){
$c=pg_connect ("host='localhost' dbname='gincana' user='postgres' password='m2smart'");
$r = pg_execute($c,$query);
$r = pg_query($c, "SELECT id,enunciado,resposta FROM quest ORDER BY random() limit 1000");
$q = @pg_fetch_array($r, 0);
$this->id = $q['id'];
$this->enunciado = $q['enunciado'];
$this->resposta = $q['resposta'];
}
function show(){
?><h3>
<?php echo $this->enunciado; ?>
</h3>
<script type="text/javascript">
function showR(){
document.getElementById("resposta-certa").innerHTML = "<?php echo $this->resposta; ?>";
// document.getElementById("buttons").innerHTML = "<input type='submit' value='Acertei'><input type='submit' value='Errei'>";
document.getElementById("button-yes").innerHTML = "<input type='submit' value='Acertei'>";
document.getElementById("button-no").innerHTML = "<input type='submit' value='Errei'>";
}
</script>
<input type='text' name='resp'>
<button onclick="showR();">Responder</button><br>
<span id='resposta-certa'></span>
<form method='post'>
<input type='hidden' name='id' value='<?php echo $this->id ;?>'>
<input type='hidden' name='status' value='1'>
<div id='button-yes'></div>
</form>
<form method='post'>
<input type='hidden' name='id' value='<?php echo $this->id ;?>'>
<input type='hidden' name='status' value='0'>
<div id='button-no'></div>
</form>
<?php
}
}
?>