Initial Commit

This commit is contained in:
Daniel Mason 2016-12-30 18:16:13 +13:00
commit 391177596e
41 changed files with 1233 additions and 0 deletions

60
404.html Executable file
View File

@ -0,0 +1,60 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Page Not Found</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
line-height: 1.2;
margin: 0;
}
html {
color: #888;
display: table;
font-family: sans-serif;
height: 100%;
text-align: center;
width: 100%;
}
body {
display: table-cell;
vertical-align: middle;
margin: 2em auto;
}
h1 {
color: #555;
font-size: 2em;
font-weight: 400;
}
p {
margin: 0 auto;
width: 280px;
}
@media only screen and (max-width: 280px) {
body, p {
width: 95%;
}
h1 {
font-size: 1.5em;
margin: 0 0 0.3em;
}
}
</style>
</head>
<body>
<h1>Page Not Found</h1>
<p>Sorry, but the page you were trying to view does not exist.</p>
</body>
</html>
<!-- IE needs 512+ bytes: http://blogs.msdn.com/b/ieinternals/archive/2010/08/19/http-error-pages-in-internet-explorer.aspx -->

BIN
apple-touch-icon.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

12
browserconfig.xml Executable file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Please read: https://msdn.microsoft.com/en-us/library/ie/dn455106.aspx -->
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="tile.png"/>
<square150x150logo src="tile.png"/>
<wide310x150logo src="tile-wide.png"/>
<square310x310logo src="tile.png"/>
</tile>
</msapplication>
</browserconfig>

15
crossdomain.xml Executable file
View File

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<!-- Read this: https://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html -->
<!-- Most restrictive policy: -->
<site-control permitted-cross-domain-policies="none"/>
<!-- Least restrictive policy: -->
<!--
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" to-ports="*" secure="false"/>
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>
-->
</cross-domain-policy>

182
css/main.css Executable file
View File

@ -0,0 +1,182 @@
html, body, #container {
width: 100%;
height: 100%;
background-color: #EEEEEE;
}
#header {
text-align: center;
border-bottom: 1px solid #333333;
}
#body {
width: 960px;
margin-bottom:10px;
margin-top:10px;
}
#footer {
text-align: center;
width: 100%;
}
.center {
margin: 0 auto 0 auto;
}
html {
color: #222;
font-size: 1em;
line-height: 1.4;
}
::-moz-selection {
background: #b3d4fc;
text-shadow: none;
}
::selection {
background: #b3d4fc;
text-shadow: none;
}
hr {
display: block;
height: 1px;
border: 0;
border-top: 1px solid #ccc;
margin: 1em 0;
padding: 0;
}
audio,
canvas,
iframe,
img,
svg,
video {
vertical-align: middle;
}
fieldset {
border: 0;
margin: 0;
padding: 0;
}
textarea {
resize: vertical;
}
.hidden {
display: none !important;
}
.visuallyhidden {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
.visuallyhidden.focusable:active,
.visuallyhidden.focusable:focus {
clip: auto;
height: auto;
margin: 0;
overflow: visible;
position: static;
width: auto;
}
.invisible {
visibility: hidden;
}
.clearfix:before,
.clearfix:after {
content: " "; /* 1 */
display: table; /* 2 */
}
.clearfix:after {
clear: both;
}
@media only screen and (min-width: 35em) {
/* Style adjustments for viewports that meet the condition */
}
@media print,
(-webkit-min-device-pixel-ratio: 1.25),
(min-resolution: 1.25dppx),
(min-resolution: 120dpi) {
/* Style adjustments for high resolution devices */
}
@media print {
*,
*:before,
*:after,
*:first-letter,
*:first-line {
background: transparent !important;
color: #000 !important; /* Black prints faster:
http://www.sanbeiji.com/archives/953 */
box-shadow: none !important;
text-shadow: none !important;
}
a,
a:visited {
text-decoration: underline;
}
a[href]:after {
content: " (" attr(href) ")";
}
abbr[title]:after {
content: " (" attr(title) ")";
}
a[href^="#"]:after,
a[href^="javascript:"]:after {
content: "";
}
pre,
blockquote {
border: 1px solid #999;
page-break-inside: avoid;
}
thead {
display: table-header-group;
}
tr,
img {
page-break-inside: avoid;
}
img {
max-width: 100% !important;
}
p,
h2,
h3 {
orphans: 3;
widows: 3;
}
h2,
h3 {
page-break-after: avoid;
}
}

424
css/normalize.css vendored Executable file
View File

@ -0,0 +1,424 @@
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
/**
* 1. Set default font family to sans-serif.
* 2. Prevent iOS and IE text size adjust after device orientation change,
* without disabling user zoom.
*/
html {
font-family: sans-serif; /* 1 */
-ms-text-size-adjust: 100%; /* 2 */
-webkit-text-size-adjust: 100%; /* 2 */
}
/**
* Remove default margin.
*/
body {
margin: 0;
}
/* HTML5 display definitions
========================================================================== */
/**
* Correct `block` display not defined for any HTML5 element in IE 8/9.
* Correct `block` display not defined for `details` or `summary` in IE 10/11
* and Firefox.
* Correct `block` display not defined for `main` in IE 11.
*/
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
menu,
nav,
section,
summary {
display: block;
}
/**
* 1. Correct `inline-block` display not defined in IE 8/9.
* 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.
*/
audio,
canvas,
progress,
video {
display: inline-block; /* 1 */
vertical-align: baseline; /* 2 */
}
/**
* Prevent modern browsers from displaying `audio` without controls.
* Remove excess height in iOS 5 devices.
*/
audio:not([controls]) {
display: none;
height: 0;
}
/**
* Address `[hidden]` styling not present in IE 8/9/10.
* Hide the `template` element in IE 8/9/10/11, Safari, and Firefox < 22.
*/
[hidden],
template {
display: none;
}
/* Links
========================================================================== */
/**
* Remove the gray background color from active links in IE 10.
*/
a {
background-color: transparent;
}
/**
* Improve readability of focused elements when they are also in an
* active/hover state.
*/
a:active,
a:hover {
outline: 0;
}
/* Text-level semantics
========================================================================== */
/**
* Address styling not present in IE 8/9/10/11, Safari, and Chrome.
*/
abbr[title] {
border-bottom: 1px dotted;
}
/**
* Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
*/
b,
strong {
font-weight: bold;
}
/**
* Address styling not present in Safari and Chrome.
*/
dfn {
font-style: italic;
}
/**
* Address variable `h1` font-size and margin within `section` and `article`
* contexts in Firefox 4+, Safari, and Chrome.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/**
* Address styling not present in IE 8/9.
*/
mark {
background: #ff0;
color: #000;
}
/**
* Address inconsistent and variable font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` affecting `line-height` in all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
/* Embedded content
========================================================================== */
/**
* Remove border when inside `a` element in IE 8/9/10.
*/
img {
border: 0;
}
/**
* Correct overflow not hidden in IE 9/10/11.
*/
svg:not(:root) {
overflow: hidden;
}
/* Grouping content
========================================================================== */
/**
* Address margin not present in IE 8/9 and Safari.
*/
figure {
margin: 1em 40px;
}
/**
* Address differences between Firefox and other browsers.
*/
hr {
box-sizing: content-box;
height: 0;
}
/**
* Contain overflow in all browsers.
*/
pre {
overflow: auto;
}
/**
* Address odd `em`-unit font size rendering in all browsers.
*/
code,
kbd,
pre,
samp {
font-family: monospace, monospace;
font-size: 1em;
}
/* Forms
========================================================================== */
/**
* Known limitation: by default, Chrome and Safari on OS X allow very limited
* styling of `select`, unless a `border` property is set.
*/
/**
* 1. Correct color not being inherited.
* Known issue: affects color of disabled elements.
* 2. Correct font properties not being inherited.
* 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
*/
button,
input,
optgroup,
select,
textarea {
color: inherit; /* 1 */
font: inherit; /* 2 */
margin: 0; /* 3 */
}
/**
* Address `overflow` set to `hidden` in IE 8/9/10/11.
*/
button {
overflow: visible;
}
/**
* Address inconsistent `text-transform` inheritance for `button` and `select`.
* All other form control elements do not inherit `text-transform` values.
* Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
* Correct `select` style inheritance in Firefox.
*/
button,
select {
text-transform: none;
}
/**
* 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
* and `video` controls.
* 2. Correct inability to style clickable `input` types in iOS.
* 3. Improve usability and consistency of cursor style between image-type
* `input` and others.
*/
button,
html input[type="button"], /* 1 */
input[type="reset"],
input[type="submit"] {
-webkit-appearance: button; /* 2 */
cursor: pointer; /* 3 */
}
/**
* Re-set default cursor for disabled elements.
*/
button[disabled],
html input[disabled] {
cursor: default;
}
/**
* Remove inner padding and border in Firefox 4+.
*/
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
/**
* Address Firefox 4+ setting `line-height` on `input` using `!important` in
* the UA stylesheet.
*/
input {
line-height: normal;
}
/**
* It's recommended that you don't attempt to style these elements.
* Firefox's implementation doesn't respect box-sizing, padding, or width.
*
* 1. Address box sizing set to `content-box` in IE 8/9/10.
* 2. Remove excess padding in IE 8/9/10.
*/
input[type="checkbox"],
input[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
}
/**
* Fix the cursor style for Chrome's increment/decrement buttons. For certain
* `font-size` values of the `input`, it causes the cursor style of the
* decrement button to change from `default` to `text`.
*/
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* 1. Address `appearance` set to `searchfield` in Safari and Chrome.
* 2. Address `box-sizing` set to `border-box` in Safari and Chrome.
*/
input[type="search"] {
-webkit-appearance: textfield; /* 1 */
box-sizing: content-box; /* 2 */
}
/**
* Remove inner padding and search cancel button in Safari and Chrome on OS X.
* Safari (but not Chrome) clips the cancel button when the search input has
* padding (and `textfield` appearance).
*/
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* Define consistent border, margin, and padding.
*/
fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
}
/**
* 1. Correct `color` not being inherited in IE 8/9/10/11.
* 2. Remove padding so people aren't caught out if they zero out fieldsets.
*/
legend {
border: 0; /* 1 */
padding: 0; /* 2 */
}
/**
* Remove default vertical scrollbar in IE 8/9/10/11.
*/
textarea {
overflow: auto;
}
/**
* Don't inherit the `font-weight` (applied by a rule above).
* NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
*/
optgroup {
font-weight: bold;
}
/* Tables
========================================================================== */
/**
* Remove most spacing between table cells.
*/
table {
border-collapse: collapse;
border-spacing: 0;
}
td,
th {
padding: 0;
}

BIN
favicon.ico Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

15
humans.txt Executable file
View File

@ -0,0 +1,15 @@
# humanstxt.org/
# The humans responsible & technology colophon
# TEAM
<name> -- <role> -- <twitter>
# THANKS
<name>
# TECHNOLOGY COLOPHON
CSS3, HTML5
Apache Server Configs, jQuery, Modernizr, Normalize.css

0
img/.gitignore vendored Executable file
View File

BIN
img/CWTX.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
img/DIGISTA.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
img/DIPOLE.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 666 B

BIN
img/FMRX.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
img/FMTX.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
img/HFSTA.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
img/JFET.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

BIN
img/MOSFET.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 B

BIN
img/NPN.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 B

BIN
img/PNP.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

BIN
img/REGPS.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
img/SSBRX.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
img/SSBTX.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
img/TETRODE.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

BIN
img/YAGI.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

1
includes/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
config.php

View File

@ -0,0 +1,31 @@
<?php
/**
* Created by PhpStorm.
* User: daniel
* Date: 12/30/16
* Time: 2:09 PM
*/
class Answer extends DataItem
{
public static function _getClass()
{
return "Answer";
}
public static function _getType()
{
return "answer";
}
public function getAnswer()
{
return $this->answerdata_content;
}
public function isCorrect()
{
return $this->answerdata_correct;
}
}

View File

@ -0,0 +1,82 @@
<?php
class DataItem {
protected $_db;
function __construct() {
$this->_db = new db(); //Will optimise this to get existing conn at some point.
}
public function getById($id) {
$this->_db->query("SELECT * FROM `".static::_getType()."` WHERE ".static::_getType()."_id = :id");
$this->_db->bind(":id", $id);
return $this->_db->getObject();
}
private function _getAllWhere($where = false, $orderBy = false, $join = false, $limit = false) {
$Objarr = array();
$typeName = static::_getType();
$className = static::_getClass();
$this->_db->query("SELECT * FROM `".$typeName."` ".($join?$join:"").($where?" WHERE ".$where."":"")." ".($orderBy?" ".$orderBy." ":" ").($limit?"LIMIT ".$limit:""));
$results = $this->_db->resultset();
if(!$results) return false;
foreach ($results as $result) {
$obj = new $className();
foreach ($result as $key=>$val) {
$obj->$key = $val;
}
$Objarr[] = $obj;
}
return $Objarr;
}
public static function getAllWhere($where = false, $orderBy = false, $join = false, $limit = false) {
$me = new static();
return $me->_getAllWhere($where, $orderBy, $join, $limit);
}
private function _getWhere($where = false, $orderBy = false, $join = false, $limit = false) {
$typeName = static::_getType();
$className = static::_getClass();
$this->_db = new db();
$this->_db->query("SELECT * FROM `".$typeName."` ".($join?$join:"").($where?" WHERE ".$where."":"")." ".($orderBy?" ".$orderBy."":"").($limit?"LIMIT ".$limit:""));
$result = $this->_db->single();
if(!$result) return false;
$obj = new $className();
foreach ($result as $key=>$val) {
$obj->$key = $val;
}
return $obj;
}
public static function getWhere($where = false, $orderBy = false, $join = false, $limit = false) {
$me = new static();
return $me->_getWhere($where, $orderBy, $join, $limit);
}
public function getId() {
$typeName = static::_getType();
$id = $typeName."_id";
return $this->$id;
}
public static function create($PDOobj)
{
$className = static::_getClass();
$obj = new $className();
foreach ($PDOobj as $key=>$val) {
$obj->$key = $val;
}
return $obj;
}
protected function _getTime() {
return static::_getType()."_time";
}
public function getTime() {
$timeColumn = static::_getCreationTime();
return $this->$timeColumn;
}
}

96
includes/classes/class.db.php Executable file
View File

@ -0,0 +1,96 @@
<?php
class db {
private $host = DB_HOSTNAME;
private $user = DB_USERNAME;
private $pass = DB_PASSWORD;
private $dbname = DB_DATABASE;
private $stmt;
private $dbh;
public function __construct(){
$dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->dbname;
$options = array(
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
);
try {
$this->dbh = new PDO($dsn, $this->user, $this->pass, $options);
} catch (PDOException $e) {
error_log($e->getMessage());
}
}
public function query($query){
$this->stmt = $this->dbh->prepare($query);
}
public function bind($param, $value, $type = null){
if (is_null($type)) {
switch (true) {
case is_int($value):
$type = PDO::PARAM_INT;
break;
case is_bool($value):
$type = PDO::PARAM_BOOL;
break;
case is_null($value):
$type = PDO::PARAM_NULL;
break;
default:
$type = PDO::PARAM_STR;
}
}
$this->stmt->bindValue($param, $value, $type);
}
public function execute(){
return $this->stmt->execute();
}
public function resultSet(){
$this->execute();
return $this->stmt->fetchAll(PDO::FETCH_ASSOC);
}
public function single(){
$this->execute();
return $this->stmt->fetch(PDO::FETCH_ASSOC);
}
public function getObject() {
$this->execute();
return $this->stmt->fetchObject();
}
public function rowCount(){
return $this->stmt->rowCount();
}
public function lastInsertId(){
return $this->dbh->lastInsertId();
}
public function beginTransaction(){
return $this->dbh->beginTransaction();
}
public function endTransaction(){
return $this->dbh->commit();
}
public function cancelTransaction(){
return $this->dbh->rollBack();
}
public function debugDumpParams(){
return $this->stmt->debugDumpParams();
}
public function kill(){
$this->dbh = null;
}
}

View File

@ -0,0 +1,40 @@
<?php
/**
* Created by PhpStorm.
* User: daniel
* Date: 12/30/16
* Time: 2:09 PM
*/
class Question extends DataItem {
public static function _getClass()
{
return "Question";
}
public static function _getType()
{
return "question";
}
public static function getQuestions($count = false)
{
$questions = static::getAllWhere(false, false, false, $count);
foreach ($questions as $q) {
$q->answers = $q->getAnswers();
shuffle($q->answers);
}
return $questions;
}
public function getQuestion()
{
return $this->questiondata_content;
}
public function getAnswers()
{
return Answer::getAllWhere("answerdata_question = ".$this->getId());
}
}

64
includes/classes/class.user.php Executable file
View File

@ -0,0 +1,64 @@
<?php
class User extends DataItem {
public $user_id;
public $userdata_username;
public $userdata_password;
public static function _getClass() {
return "User";
}
public static function _getType() {
return "user";
}
public static function login($userName = false, $password = false)
{
if(isset($_SESSION['userName']) && isset($_SESSION['userId'])) return true;
if(isset($userName) && isset($password)) {
return self::_login($userName, $password, false);
}
return false;
}
private static function _login($userName = false, $password = false, $token = false) {
if($token && !$password) {
//query token
} else if ($userName && $password) {
$user = User::getWhere("userdata_username = '".$userName."'");
if (is_object($user)) {
if (password_verify($password, $user->_getHash())) {
setcookie("userName", $user->getUserName(), COOKIE_EXPIRY);
$_SESSION['username'] = $user->getUserName();
$_SESSION['userId'] = $user->getId();
return true;
}
}
}
return false;
}
public static function getUserFromSession()
{
return self::getWhere("user_id = '".$_SESSION['userId']."'");
}
public static function register()
{
}
public function _getHash()
{
return $this->userdata_password;
}
public function getUserName()
{
return $this->userdata_username;
}
}

5
includes/config.php.example Executable file
View File

@ -0,0 +1,5 @@
<?php
define("DB_HOSTNAME", "mysqlserver");
define("DB_DATABASE", "databasename");
define("DB_USERNAME", "mysqlusername");
define("DB_PASSWORD", "mysqlpassword");

30
includes/createDb.sql Executable file
View File

@ -0,0 +1,30 @@
-- base sql
CREATE TABLE IF NOT EXISTS `user` (
`user_id` INT(11) NOT NULL AUTO_INCREMENT,
`user_time` INT(11) NOT NULL,
`userdata_username` varchar(256) NOT NULL,
`userdata_password` varchar(256) NOT NULL,
PRIMARY KEY (`user_id`),
UNIQUE KEY `user_id_UNIQUE` (`user_id`),
UNIQUE KEY `userdata_username_UNIQUE` (`userdata_username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `question` (
`question_id` INT(11) NOT NULL AUTO_INCREMENT,
`question_time` INT(11) NOT NULL,
`questiondata_number` VARCHAR(10) DEFAULT NULL,
`questiondata_content` TEXT DEFAULT NULL,
`questiondata_image` TEXT DEFAULT NULL,
PRIMARY KEY (`question_id`),
UNIQUE KEY `question_id_UNIQUE` (`question_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `answer` (
`answer_id` INT(11) NOT NULL AUTO_INCREMENT,
`answer_time` INT(11) NOT NULL,
`answerdata_question` INT(11) NOT NULL,
`answerdata_content` MEDIUMTEXT DEFAULT NULL,
`answerdata_correct` INT(1) DEFAULT 0,
PRIMARY KEY (`answer_id`),
UNIQUE KEY `answer_id_UNIQUE` (`answer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

8
includes/include.php Executable file
View File

@ -0,0 +1,8 @@
<?php
require_once('config.php'); //DB CREDENTIALS
require_once('classes/class.db.php');
require_once('classes/class.dataitem.php');
require_once('classes/class.user.php');
require_once('classes/class.question.php');
require_once('classes/class.answer.php');

55
index.php Executable file
View File

@ -0,0 +1,55 @@
<?php
require_once('includes/include.php');
define('QUESTION_COUNT', 60); //How many questions to ask.
$questions = Question::getQuestions(QUESTION_COUNT);
?><!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>NZART - Practice Exam</title>
<meta name="description" content="Unofficial NZART Practice Exam">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<div id="container">
<div id="header"><h1>Unofficial NZART Practice Exam</h1></div>
<div id="body" class="center">
60 Questions
<table>
<tbody>
<?php
$letters = range('A', 'Z');
foreach($questions as $i=>$q) {
echo "<tr>";
echo "<td>".($i+1)."</td>";
echo "<td>".$q->getQuestion()."</td>";
echo "</tr>";
foreach($q->answers as $x=>$ans) {
echo "<tr>";
echo "<td style='padding-left:10px'>".$letters[$x]."</td>";
echo "<td style='padding-left:10px'>".$ans->getAnswer()."</td>";
echo "</tr>";
}
}
?>
</tbody>
</table>
</div>
<div id="footer">
All Questions and images from NZART question bank located
<a href="http://www.nzart.org.nz/exam/download-examination-files/">Here</a>
</div>
</div>
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.12.0.min.js"><\/script>')</script>
<script src="js/plugins.js"></script>
<script src="js/main.js"></script>
</body>
</html>

79
insert.php Normal file
View File

@ -0,0 +1,79 @@
<?php
die("nonononono");
require_once("includes/include.php");
if (isset($_REQUEST['raw'])) {
$questions = [];
$data = explode("%", $_REQUEST['raw']);
$data = array_map('trim', $data);
foreach($data as $i=>$d) {
if(empty($d)) continue;
if (strpos($d, 'Question') !== false) {
$fullQuestion = substr(preg_replace('/^.+\n/', '', $d),1); //Strip useless firstline.
$numbers = explode(" ", $fullQuestion);
$questions[$i]['questionNumber'] = $numbers[0]; // Get # of question
$lengthOfNumber = strlen($questions[$i]['questionNumber']); //Get length of #
$splitNewLine = explode("\n", trim($fullQuestion)); //Split rest into lines.
$questions[$i]['question'] = trim(substr($splitNewLine[0], $lengthOfNumber));
$x=$b=1;
foreach ($splitNewLine as $a=>$line) {
if($a==0) continue;
if(empty(trim($line))) continue;
if(strpos($line, 'totallines') !== false) continue;
if(strpos($line, '<img') !== false) {
preg_match('/".*?"/', $line, $matches);
$questions[$i]['image'] = strtoupper($matches[0]);
continue;
}
$questions[$i]['answers'][$b] = trim($line);
$b++;
}
} elseif (strpos($d, 'ans ') !== false) {
$questions[$i-1]['correctAnswer'] = substr($d, 3);
}
}
$i = $b = $d = $a = 0; //Clear the useless stuff from above.
if(isset($_REQUEST['insert']) && $_REQUEST['insert'] == 1 && count($questions)) {
$count = 0;
foreach($questions as $q) {
$db = new db();
$db->query("INSERT INTO question(question_time, questiondata_number, questiondata_content, questiondata_image)
VALUES(:qTime, :qNumber, :qContent, :qImage)");
$db->bind("qTime",time());
$db->bind("qNumber", $q['questionNumber']?:0);
$db->bind("qContent",$q['question']);
$db->bind("qImage",$q['image']?:"");
$db->execute();
$lastRow = $db->lastInsertId();
$db->kill(); //IS THIS EVEN NEEDED?
$row = 1;
foreach($q['answers'] as $a) {
$db = new db();
$db->query("INSERT INTO answer(answer_time, answerdata_content, answerdata_question, answerdata_correct)
VALUES(:aTime, :aContent, :aQuestion, :aCorrect)");
$db->bind("aTime", time());
$db->bind("aContent", $a);
$db->bind("aQuestion", $lastRow);
$db->bind("aCorrect",($q['correctAnswer']==$row?"1":"0"));
$db->execute();
$db->kill();
$row++;
}
$db = null;
}
echo "Inserted ".$count." questions.";
} else {
var_dump($questions);
}
}?>
<h1>Question inserter thingy.</h1>
<h3>RAW DATA</h3>
<form action="/insert.php" method="POST">
Raw Data: <label>
Actually insert: <input type="checkbox" name="insert" value="1">
<textarea cols="200" rows="20" name="raw" required><?=$_REQUEST['raw']?:""?></textarea>
</label><br/><br/>
<button type="submit">Submit</button>
</form>

0
js/main.js Executable file
View File

24
js/plugins.js Executable file
View File

@ -0,0 +1,24 @@
// Avoid `console` errors in browsers that lack a console.
(function() {
var method;
var noop = function () {};
var methods = [
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
'timeline', 'timelineEnd', 'timeStamp', 'trace', 'warn'
];
var length = methods.length;
var console = (window.console = window.console || {});
while (length--) {
method = methods[length];
// Only stub undefined methods.
if (!console[method]) {
console[method] = noop;
}
}
}());
// Place any jQuery/helper plugins in here.

5
js/vendor/jquery-1.12.0.min.js vendored Executable file

File diff suppressed because one or more lines are too long

5
robots.txt Executable file
View File

@ -0,0 +1,5 @@
# www.robotstxt.org/
# Allow crawling of all content
User-agent: *
Disallow:

BIN
tile-wide.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
tile.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB