survey
This commit is contained in:
parent
415d623452
commit
714864cdbc
|
@ -0,0 +1,4 @@
|
|||
|
||||
.idea/
|
||||
|
||||
vendor/
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace goeranh;
|
||||
|
||||
class Seite
|
||||
{
|
||||
private $title, $inhalt;
|
||||
|
||||
public function __construct($title = "")
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->inhalt = '';
|
||||
}
|
||||
|
||||
public function setInhalt($inhalt){
|
||||
$this->inhalt = $inhalt;
|
||||
}
|
||||
|
||||
public function addInhalt($inhalt){
|
||||
$this->inhalt .= $inhalt;
|
||||
}
|
||||
|
||||
public function augeben(){
|
||||
$page = '<html>
|
||||
<head>
|
||||
<style>
|
||||
table{
|
||||
width: 100%;
|
||||
}
|
||||
input{
|
||||
width: 100%;
|
||||
}
|
||||
td{
|
||||
white-space:nowrap;
|
||||
}
|
||||
</style>
|
||||
<title>'.$this->title.'</title>
|
||||
</head>
|
||||
<body>
|
||||
'.$this->inhalt.'
|
||||
</body>
|
||||
</html>';
|
||||
echo $page;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
|
||||
use ArangoDBClient\CollectionHandler;
|
||||
use ArangoDBClient\Connection;
|
||||
use ArangoDBClient\ConnectionOptions;
|
||||
use ArangoDBClient\Document;
|
||||
use ArangoDBClient\DocumentHandler;
|
||||
use ArangoDBClient\UpdatePolicy;
|
||||
|
||||
include 'config.php';
|
||||
require "vendor/autoload.php";
|
||||
require "Seite.php";
|
||||
|
||||
session_start();
|
||||
|
||||
$connectionOptions = array(
|
||||
// server endpoint to connect to
|
||||
//ConnectionOptions::OPTION_ENDPOINT => 'tcp://10.16.17.154:8529',
|
||||
ConnectionOptions::OPTION_ENDPOINT => 'tcp://' . $server . ':8529',
|
||||
// authorization type to use (currently supported: 'Basic')
|
||||
ConnectionOptions::OPTION_AUTH_TYPE => 'Basic',
|
||||
// user for basic authorization
|
||||
ConnectionOptions::OPTION_AUTH_USER => $dbuser,
|
||||
// password for basic authorization
|
||||
ConnectionOptions::OPTION_AUTH_PASSWD => $passwd,
|
||||
// connection persistence on server. can use either 'Close' (one-time connections) or 'Keep-Alive' (re-used connections)
|
||||
ConnectionOptions::OPTION_CONNECTION => 'Close',
|
||||
// connect timeout in seconds
|
||||
ConnectionOptions::OPTION_TIMEOUT => 3,
|
||||
// whether or not to reconnect when a keep-alive connection has timed out on server
|
||||
ConnectionOptions::OPTION_RECONNECT => true,
|
||||
// optionally create new collections when inserting documents
|
||||
ConnectionOptions::OPTION_CREATE => true,
|
||||
// optionally create new collections when inserting documents
|
||||
ConnectionOptions::OPTION_UPDATE_POLICY => UpdatePolicy::LAST,
|
||||
ConnectionOptions::OPTION_DATABASE => 'database',
|
||||
);
|
||||
|
||||
// open connection
|
||||
$connection = new Connection($connectionOptions);
|
||||
$collectionHandler = new CollectionHandler($connection);
|
||||
$documentHandler = new DocumentHandler($connection);
|
||||
$edgeHandler = new \ArangoDBClient\EdgeHandler($connection);
|
||||
|
||||
if (!isset($_SESSION['name'])) {
|
||||
if (count($_POST) == 2) {
|
||||
$user = $documentHandler->insert($collectionHandler->get('users'), new Document());
|
||||
foreach (array_keys($_POST) as $key) {
|
||||
var_dump($keys);
|
||||
$edge = new Document();
|
||||
$edge->set("answer", $_POST[$key]);
|
||||
$edge->set('_from', $user);
|
||||
$edge->set('_to', 'questions/' . $key);
|
||||
$documentHandler->insert('answered', $edge);
|
||||
}
|
||||
$_SESSION['name'] = $user;
|
||||
}
|
||||
} elseif (!isset($_SESSION['personal'])) {
|
||||
foreach (array_keys($_POST) as $key) {
|
||||
if ($_POST[$key] != '') {
|
||||
$edge = new Document();
|
||||
$edge->set("answer", $_POST[$key]);
|
||||
$edge->set('_from', $_SESSION['name']);
|
||||
$edge->set('_to', 'questions/' . $key);
|
||||
$documentHandler->insert('answered', $edge);
|
||||
}
|
||||
}
|
||||
$_SESSION['personal'] = true;
|
||||
} elseif (!isset($_SESSION['schueler'])) {
|
||||
foreach (array_keys($_POST) as $key) {
|
||||
if ($_POST[$key] != '') {
|
||||
$edge = new Document();
|
||||
$edge->set("answer", $_POST[$key]);
|
||||
$edge->set('_from', $_SESSION['name']);
|
||||
$edge->set('_to', 'questions/' . $key);
|
||||
$documentHandler->insert('answered', $edge);
|
||||
}
|
||||
}
|
||||
$_SESSION['schueler'] = true;
|
||||
} elseif (!isset($_SESSION['lehrer'])) {
|
||||
foreach (array_keys($_POST) as $key) {
|
||||
if ($_POST[$key] != '') {
|
||||
$edge = new Document();
|
||||
$edge->set("answer", $_POST[$key]);
|
||||
$edge->set('_from', $_SESSION['name']);
|
||||
$edge->set('_to', 'questions/' . $key);
|
||||
$documentHandler->insert('answered', $edge);
|
||||
}
|
||||
}
|
||||
$_SESSION['lehrer'] = true;
|
||||
}
|
||||
|
||||
header('Location: umfrage.php');
|
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
use ArangoDBClient\CollectionHandler;
|
||||
use ArangoDBClient\Connection;
|
||||
use ArangoDBClient\ConnectionOptions;
|
||||
use ArangoDBClient\DocumentHandler;
|
||||
use ArangoDBClient\Statement;
|
||||
use ArangoDBClient\UpdatePolicy;
|
||||
|
||||
include "config.php";
|
||||
include "Seite.php";
|
||||
require "vendor/autoload.php";
|
||||
|
||||
$connectionOptions = array(
|
||||
// server endpoint to connect to
|
||||
//ConnectionOptions::OPTION_ENDPOINT => 'tcp://10.16.17.154:8529',
|
||||
ConnectionOptions::OPTION_ENDPOINT => 'tcp://' . $server . ':8529',
|
||||
// authorization type to use (currently supported: 'Basic')
|
||||
ConnectionOptions::OPTION_AUTH_TYPE => 'Basic',
|
||||
// user for basic authorization
|
||||
ConnectionOptions::OPTION_AUTH_USER => $dbuser,
|
||||
// password for basic authorization
|
||||
ConnectionOptions::OPTION_AUTH_PASSWD => $passwd,
|
||||
// connection persistence on server. can use either 'Close' (one-time connections) or 'Keep-Alive' (re-used connections)
|
||||
ConnectionOptions::OPTION_CONNECTION => 'Close',
|
||||
// connect timeout in seconds
|
||||
ConnectionOptions::OPTION_TIMEOUT => 3,
|
||||
// whether or not to reconnect when a keep-alive connection has timed out on server
|
||||
ConnectionOptions::OPTION_RECONNECT => true,
|
||||
// optionally create new collections when inserting documents
|
||||
ConnectionOptions::OPTION_CREATE => true,
|
||||
// optionally create new collections when inserting documents
|
||||
ConnectionOptions::OPTION_UPDATE_POLICY => UpdatePolicy::LAST,
|
||||
ConnectionOptions::OPTION_DATABASE => 'database',
|
||||
);
|
||||
|
||||
// open connection
|
||||
$connection = new Connection($connectionOptions);
|
||||
$collectionHandler = new CollectionHandler($connection);
|
||||
$documentHandler = new DocumentHandler($connection);
|
||||
|
||||
if (isset($_GET['pwd'])){
|
||||
if ($_GET['pwd'] == 123){
|
||||
$statement = new Statement($connection, [
|
||||
'query' => 'for user in users
|
||||
let name = (
|
||||
for v, e, p in 1..1 outbound user answered
|
||||
filter v._key==\'29551\'
|
||||
return e.answer
|
||||
)
|
||||
let answers = (
|
||||
for v, e, p in 1..1 outbound user answered
|
||||
return {qkey: v._key, question: v.question, answer: e.answer}
|
||||
)
|
||||
return {user: user._key, name: name[0], answers: answers}',
|
||||
'count' => true,
|
||||
'batchSize' => 1000,
|
||||
'bindVars' => null,
|
||||
'sanitize' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$cursor = $statement->execute();
|
||||
$users = array();
|
||||
foreach ($cursor->getAll() as $doc) {
|
||||
$users[] = json_decode(json_encode($doc));
|
||||
}
|
||||
|
||||
$seite = new \goeranh\Seite('Antworten');
|
||||
$inhalt = '
|
||||
<style>
|
||||
table{
|
||||
border-collapse: collapse;
|
||||
}
|
||||
tr{
|
||||
border-collapse: collapse;
|
||||
}
|
||||
td{
|
||||
border-bottom: 1px solid black;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
</style>
|
||||
<table>';
|
||||
foreach ($users as $user){
|
||||
$inhalt .= '<tr><td colspan="2"><h2>'.$user->name.'</h2></td></tr>';
|
||||
foreach ($user->answers as $answers){
|
||||
$inhalt .= '<tr><td>'.$answers->question.'</td><td>'.$answers->answer.'</td></tr>';
|
||||
}
|
||||
}
|
||||
$inhalt .= '</table>';
|
||||
|
||||
$seite->addInhalt($inhalt);
|
||||
$seite->augeben();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "goeranh/abi-umfrage",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"triagens/arangodb": "^3.6",
|
||||
"ext-json": "*"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Goeran Heinemann",
|
||||
"email": "goeran@karsdorf.net"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "c31a48dde83dfa22c80a0c02955f2276",
|
||||
"packages": [
|
||||
{
|
||||
"name": "triagens/arangodb",
|
||||
"version": "v3.6.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/arangodb/arangodb-php.git",
|
||||
"reference": "d331f1a493772960c4d0e3d1fb753900eb181ce2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/arangodb/arangodb-php/zipball/d331f1a493772960c4d0e3d1fb753900eb181ce2",
|
||||
"reference": "d331f1a493772960c4d0e3d1fb753900eb181ce2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.6.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"ArangoDBClient": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"Apache-2.0"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jan Steemann",
|
||||
"homepage": "https://github.com/arangodb/arangodb-php",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Frank Mayer",
|
||||
"homepage": "https://github.com/arangodb/arangodb-php",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Contributors",
|
||||
"homepage": "https://github.com/arangodb/arangodb-php/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"description": "ArangoDB PHP client",
|
||||
"homepage": "https://github.com/arangodb/arangodb-php",
|
||||
"keywords": [
|
||||
"Arango",
|
||||
"ArangoDb",
|
||||
"database",
|
||||
"distributed",
|
||||
"document store",
|
||||
"graph database",
|
||||
"multi-model",
|
||||
"nosql"
|
||||
],
|
||||
"time": "2019-12-02T13:11:34+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "1.1.0"
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
$server = '';
|
||||
$dbuser = '';
|
||||
$passwd = '';
|
||||
$database = '';
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
/*use ArangoDBClient\CollectionHandler;
|
||||
use ArangoDBClient\Connection;
|
||||
use ArangoDBClient\ConnectionOptions;
|
||||
use ArangoDBClient\DocumentHandler;
|
||||
use ArangoDBClient\UpdatePolicy;*/
|
||||
|
||||
namespace ArangoDBClient;
|
||||
|
||||
include "config.php";
|
||||
require "vendor/autoload.php";
|
||||
|
||||
$connectionOptions = array(
|
||||
// server endpoint to connect to
|
||||
//ConnectionOptions::OPTION_ENDPOINT => 'tcp://10.16.17.154:8529',
|
||||
ConnectionOptions::OPTION_ENDPOINT => 'tcp://' . $server . ':8529',
|
||||
// authorization type to use (currently supported: 'Basic')
|
||||
ConnectionOptions::OPTION_AUTH_TYPE => 'Basic',
|
||||
// user for basic authorization
|
||||
ConnectionOptions::OPTION_AUTH_USER => $dbuser,
|
||||
// password for basic authorization
|
||||
ConnectionOptions::OPTION_AUTH_PASSWD => $passwd,
|
||||
// connection persistence on server. can use either 'Close' (one-time connections) or 'Keep-Alive' (re-used connections)
|
||||
ConnectionOptions::OPTION_CONNECTION => 'Close',
|
||||
// connect timeout in seconds
|
||||
ConnectionOptions::OPTION_TIMEOUT => 3,
|
||||
// whether or not to reconnect when a keep-alive connection has timed out on server
|
||||
ConnectionOptions::OPTION_RECONNECT => true,
|
||||
// optionally create new collections when inserting documents
|
||||
ConnectionOptions::OPTION_CREATE => true,
|
||||
// optionally create new collections when inserting documents
|
||||
ConnectionOptions::OPTION_UPDATE_POLICY => UpdatePolicy::LAST,
|
||||
ConnectionOptions::OPTION_DATABASE => 'database',
|
||||
);
|
||||
|
||||
// open connection
|
||||
$connection = new Connection($connectionOptions);
|
||||
$collectionHandler = new CollectionHandler($connection);
|
||||
$documentHandler = new DocumentHandler($connection);
|
||||
|
||||
/*
|
||||
$input = 0;
|
||||
while($input != 99){
|
||||
$input = readline("Frage: ");
|
||||
if ($input != 99){
|
||||
$question = new Document();
|
||||
$question->set('question', $input);
|
||||
$question->set('type', 'schülerawards');
|
||||
$documentHandler->insert($collectionHandler->get("questions"), $question);
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
use ArangoDBClient\Collection;
|
||||
use ArangoDBClient\CollectionHandler;
|
||||
use ArangoDBClient\Connection;
|
||||
use ArangoDBClient\ConnectionOptions;
|
||||
use ArangoDBClient\DocumentHandler;
|
||||
use ArangoDBClient\UpdatePolicy;
|
||||
|
||||
require "vendor/autoload.php";
|
||||
include "config.php";
|
||||
|
||||
$connectionOptions = array(
|
||||
// server endpoint to connect to
|
||||
//ConnectionOptions::OPTION_ENDPOINT => 'tcp://10.16.17.154:8529',
|
||||
ConnectionOptions::OPTION_ENDPOINT => 'tcp://' . $server . ':8529',
|
||||
// authorization type to use (currently supported: 'Basic')
|
||||
ConnectionOptions::OPTION_AUTH_TYPE => 'Basic',
|
||||
// user for basic authorization
|
||||
ConnectionOptions::OPTION_AUTH_USER => $dbuser,
|
||||
// password for basic authorization
|
||||
ConnectionOptions::OPTION_AUTH_PASSWD => $passwd,
|
||||
// connection persistence on server. can use either 'Close' (one-time connections) or 'Keep-Alive' (re-used connections)
|
||||
ConnectionOptions::OPTION_CONNECTION => 'Close',
|
||||
// connect timeout in seconds
|
||||
ConnectionOptions::OPTION_TIMEOUT => 3,
|
||||
// whether or not to reconnect when a keep-alive connection has timed out on server
|
||||
ConnectionOptions::OPTION_RECONNECT => true,
|
||||
// optionally create new collections when inserting documents
|
||||
ConnectionOptions::OPTION_CREATE => true,
|
||||
// optionally create new collections when inserting documents
|
||||
ConnectionOptions::OPTION_UPDATE_POLICY => UpdatePolicy::LAST,
|
||||
ConnectionOptions::OPTION_DATABASE => 'database',
|
||||
);
|
||||
|
||||
// open connection
|
||||
$connection = new Connection($connectionOptions);
|
||||
$collectionHandler = new CollectionHandler($connection);
|
||||
$documentHandler = new DocumentHandler($connection);
|
||||
|
||||
$collections = array(
|
||||
"users" => Collection::TYPE_DOCUMENT,
|
||||
"questions" => Collection::TYPE_DOCUMENT,
|
||||
"answers" => Collection::TYPE_DOCUMENT,
|
||||
"answered" => Collection::TYPE_EDGE,
|
||||
"answeredQuestion" => Collection::TYPE_EDGE
|
||||
);
|
||||
|
||||
foreach (array_keys($collections) as $c) {
|
||||
$collection = new Collection($c);
|
||||
$collection->setType($collections[$c]);
|
||||
try {
|
||||
$collectionHandler->create($collection);
|
||||
echo 'creating collection ' . $c . "\n";
|
||||
} catch (\Exception $e) {
|
||||
echo 'collection ' . $c . " already exists\n";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,185 @@
|
|||
<?php
|
||||
|
||||
use ArangoDBClient\CollectionHandler;
|
||||
use ArangoDBClient\Connection;
|
||||
use ArangoDBClient\ConnectionOptions;
|
||||
use ArangoDBClient\DocumentHandler;
|
||||
use ArangoDBClient\Statement;
|
||||
use ArangoDBClient\UpdatePolicy;
|
||||
|
||||
require "vendor/autoload.php";
|
||||
require "Seite.php";
|
||||
include "config.php";
|
||||
|
||||
session_start();
|
||||
|
||||
$connectionOptions = array(
|
||||
// server endpoint to connect to
|
||||
//ConnectionOptions::OPTION_ENDPOINT => 'tcp://10.16.17.154:8529',
|
||||
ConnectionOptions::OPTION_ENDPOINT => 'tcp://' . $server . ':8529',
|
||||
// authorization type to use (currently supported: 'Basic')
|
||||
ConnectionOptions::OPTION_AUTH_TYPE => 'Basic',
|
||||
// user for basic authorization
|
||||
ConnectionOptions::OPTION_AUTH_USER => $dbuser,
|
||||
// password for basic authorization
|
||||
ConnectionOptions::OPTION_AUTH_PASSWD => $passwd,
|
||||
// connection persistence on server. can use either 'Close' (one-time connections) or 'Keep-Alive' (re-used connections)
|
||||
ConnectionOptions::OPTION_CONNECTION => 'Close',
|
||||
// connect timeout in seconds
|
||||
ConnectionOptions::OPTION_TIMEOUT => 3,
|
||||
// whether or not to reconnect when a keep-alive connection has timed out on server
|
||||
ConnectionOptions::OPTION_RECONNECT => true,
|
||||
// optionally create new collections when inserting documents
|
||||
ConnectionOptions::OPTION_CREATE => true,
|
||||
// optionally create new collections when inserting documents
|
||||
ConnectionOptions::OPTION_UPDATE_POLICY => UpdatePolicy::LAST,
|
||||
ConnectionOptions::OPTION_DATABASE => 'database',
|
||||
);
|
||||
|
||||
// open connection
|
||||
$connection = new Connection($connectionOptions);
|
||||
$collectionHandler = new CollectionHandler($connection);
|
||||
$documentHandler = new DocumentHandler($connection);
|
||||
|
||||
if (!isset($_SESSION['name'])){
|
||||
$statement = new Statement($connection, [
|
||||
'query' => 'for question in questions filter question.type=="aux" return question',
|
||||
'count' => true,
|
||||
'batchSize' => 1000,
|
||||
'bindVars' => null,
|
||||
'sanitize' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$cursor = $statement->execute();
|
||||
$questions = array();
|
||||
foreach ($cursor->getAll() as $doc) {
|
||||
$questions[] = json_decode(json_encode($doc));
|
||||
}
|
||||
|
||||
$seite = new \goeranh\Seite("Abiturumfrage");
|
||||
|
||||
$inhalt = '
|
||||
<form action="answers.php" method="post">
|
||||
<table>
|
||||
';
|
||||
foreach ($questions as $question){
|
||||
$inhalt .= '<tr><td><label for="'.$question->_key.'">'.$question->question.'</label></td>
|
||||
<td><input type="text" name="'.$question->_key.'" placeholder="'.$question->question.'"></td></tr>';
|
||||
}
|
||||
$inhalt .= '
|
||||
<tr><td></td><td><button onerror="submit" style="width: 100%">Weiter</button></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
';
|
||||
|
||||
$seite->addInhalt($inhalt);
|
||||
$seite->augeben();
|
||||
}elseif(!isset($_SESSION['personal'])){
|
||||
$statement = new Statement($connection, [
|
||||
'query' => 'for question in questions filter question.type=="personal" return question',
|
||||
'count' => true,
|
||||
'batchSize' => 1000,
|
||||
'bindVars' => null,
|
||||
'sanitize' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$cursor = $statement->execute();
|
||||
$questions = array();
|
||||
foreach ($cursor->getAll() as $doc) {
|
||||
$questions[] = json_decode(json_encode($doc));
|
||||
}
|
||||
|
||||
$seite = new \goeranh\Seite("Abiturumfrage");
|
||||
|
||||
$inhalt = '
|
||||
<form action="answers.php" method="post">
|
||||
<table>
|
||||
';
|
||||
foreach ($questions as $question){
|
||||
$inhalt .= '<tr><td><label for="'.$question->_key.'">'.$question->question.'</label></td>
|
||||
<td width="100%"><input type="text" name="'.$question->_key.'" placeholder="'.$question->question.'"></td></tr>';
|
||||
}
|
||||
$inhalt .= '
|
||||
<tr><td></td><td><button onerror="submit" style="width: 100%">Weiter</button></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
';
|
||||
|
||||
$seite->addInhalt($inhalt);
|
||||
$seite->augeben();
|
||||
}elseif(!isset($_SESSION['schueler'])){
|
||||
$statement = new Statement($connection, [
|
||||
'query' => 'for question in questions filter question.type=="schülerawards" return question',
|
||||
'count' => true,
|
||||
'batchSize' => 1000,
|
||||
'bindVars' => null,
|
||||
'sanitize' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$cursor = $statement->execute();
|
||||
$questions = array();
|
||||
foreach ($cursor->getAll() as $doc) {
|
||||
$questions[] = json_decode(json_encode($doc));
|
||||
}
|
||||
|
||||
$seite = new \goeranh\Seite("Abiturumfrage");
|
||||
|
||||
$inhalt = '
|
||||
<form action="answers.php" method="post">
|
||||
<table>
|
||||
';
|
||||
foreach ($questions as $question){
|
||||
$inhalt .= '<tr><td><label for="'.$question->_key.'">'.$question->question.'</label></td>
|
||||
<td width="100%"><input type="text" name="'.$question->_key.'" placeholder="'.$question->question.'"></td></tr>';
|
||||
}
|
||||
$inhalt .= '
|
||||
<tr><td></td><td><button onerror="submit" style="width: 100%">Weiter</button></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
';
|
||||
|
||||
$seite->addInhalt($inhalt);
|
||||
$seite->augeben();
|
||||
}elseif(!isset($_SESSION['lehrer'])){
|
||||
$statement = new Statement($connection, [
|
||||
'query' => 'for question in questions filter question.type=="lehrerawards" return question',
|
||||
'count' => true,
|
||||
'batchSize' => 1000,
|
||||
'bindVars' => null,
|
||||
'sanitize' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$cursor = $statement->execute();
|
||||
$questions = array();
|
||||
foreach ($cursor->getAll() as $doc) {
|
||||
$questions[] = json_decode(json_encode($doc));
|
||||
}
|
||||
|
||||
$seite = new \goeranh\Seite("Abiturumfrage");
|
||||
|
||||
$inhalt = '
|
||||
<form action="answers.php" method="post">
|
||||
<table>
|
||||
';
|
||||
foreach ($questions as $question){
|
||||
$inhalt .= '<tr><td><label for="'.$question->_key.'">'.$question->question.'</label></td>
|
||||
<td width="100%"><input type="text" name="'.$question->_key.'" placeholder="'.$question->question.'"></td></tr>';
|
||||
}
|
||||
$inhalt .= '
|
||||
<tr><td></td><td><button onerror="submit" style="width: 100%">Weiter</button></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
';
|
||||
|
||||
$seite->addInhalt($inhalt);
|
||||
$seite->augeben();
|
||||
}else{
|
||||
$seite = new \goeranh\Seite('Danke fürs Mitmachen!');
|
||||
$inhalt = '<h1>Danke, dass deine Daten angegeben hast.</h1>';
|
||||
$seite->addInhalt($inhalt);
|
||||
$seite->augeben();
|
||||
}
|
Loading…
Reference in New Issue