Esempio n. 1
0
 public function parse($qstr)
 {
     global $ruleSet;
     if (str_replace([" ", "\t", "\n", "\r"], '', $qstr) === '') {
         echo "Error: No text submitted/empty file.";
         return '';
     }
     //$t=microtime();
     $nMatches = preg_match_all($this->qregex(), $qstr, $qtext);
     //echo '(TIME-millis:'.(microtime()-$t).':TIME)';
     $qs = new qIO();
     for ($i = 0; $i < $nMatches; $i++) {
         try {
             //0 full match
             //1 QPart
             //2 Number
             //3 Subj
             //4 QType
             //5 QuestionText
             //6-9 W-Z
             //10 Answer
             //Indices: 0 full match, Part, Number, Subject, MCQText, ChoicesW, ChoicesX, ChoicesY, ChoicesZ, SAQText, MCa, AnswerText
             $qs->addByArray(array(array("isB" => strpos('tb', strtolower(substr($qtext[1][$i], 0, 1))), "Subject" => array_search(strtolower(substr($qtext[2][$i], 0, 1)), $ruleSet["SubjChars"]), "isSA" => $qtext[4][$i] == 'Short Answer', "Question" => str_replace(["\r", "\n"], '', $qtext[5][$i]), "MCW" => $qtext[6][$i], "MCX" => $qtext[7][$i], "MCY" => $qtext[8][$i], "MCZ" => $qtext[9][$i], "MCa" => substr($qtext[10][$i], 0, 1), "Answer" => $qtext[10][$i])));
         } catch (Exception $e) {
             echo "ERROR: " . $e->getMessage();
             //--todo-- DISPLAY ERRORS? OR JUST IGNORING? OR IDK IT SHOULDN'T EVEN HAPPEN
         }
     }
     $qs->commit();
     $parsedQIDs = $qs->getQIDs();
     /*echo "Duplicates: none<br><br>";*/
     echo "<b>Total uploaded Question-IDs: " . (count($parsedQIDs) == 0 ? "no questions entered" : arrayToRanges($parsedQIDs) . " (" . count($parsedQIDs) . " total entered)") . "</b>";
     return preg_replace($this->qregex(), '', $qstr);
     //stuff remaining after questions detected
 }
Esempio n. 2
0
<?php

define('ROOT_PATH', '');
require_once ROOT_PATH . 'functions.php';
require_class('qIO');
restrictAccess('u');
//xuca
$q = new qIO();
$q->addRand(null, null, [0], 1);
?>

<style>
body{
font-size:30pt;
background-color:black;
color:white;
font-family:Segoe UI, Segoe, Frutiger, WeblySleekUI, CartoGothic STD, Open Sans, Arial, sans-serif;
}
.anschoices button{
font-family:"Robot!Head",
transition:background-color 0.5s;
font-size:inherit;
background-color:white;
color:black;
display:block;
width:100%;
text-align:center;
border-radius:20px;
border:none;
margin-top:10px;
cursor:pointer;
Esempio n. 3
0
define('ROOT_PATH', '');
require_once ROOT_PATH . 'functions.php';
require_class('qIO');
restrictAccess('u');
//xuca
/*
randq.php
Fetches random questions.
*/
/*------------todo next-----------/
Integrate everything into this interface? With click-to-edit, etc. Hm. It should at least look *similar*.

Like protobowl - display only one at a time? Sleek CSS stuff definitely.
*/
$q = new qIO();
//docexport functionality
if (csrfVerify() && posted('getDoc', 'qidcsv', 'docexport')) {
    if ($_POST['docexport'] == 'QIDCSV') {
        sendfile('text/plain', 'txt', $_POST['qidcsv']);
    } elseif ($_POST['docexport'] == 'HTML') {
        sendfile('text/html', 'html', $q->clear()->addByQID(explode(',', $_POST['qidcsv']))->allToHTML('<div>[QID %QID%]<br><center><b>%PART%</b></center><br>%SUBJECT% <i>%TYPE%</i> %QUESTION%<br><small>%MCOPTIONS%</small><br>ANSWER: <b>%ANSWER%</b></div><br><br>'));
    } else {
        alert('Invalid format for export.', -1);
    }
}
//MarkBad functionality
if (csrfVerify() && posted("markBad", "qids")) {
    //--todo-- should be able to EDIT instead of just marking wrong. Also store history of questions viewed - "Views" table (hugeness) so can look back, mark for look back, etc.
    alert('Marked question(s) ' . arrayToRanges($q->clear()->addByQID(array_intersect_key($_POST["qids"], array_flip($_POST["markBad"])))->markBad()->getQIDs()) . ' as bad.', 1);
}
Esempio n. 4
0
input.php
Input of questions into the database.
*/
$unparsed = '';
$lastErr = error_get_clear();
if (isset($_SERVER['CONTENT_LENGTH']) && (int) $_SERVER['CONTENT_LENGTH'] > convert_to_bytes(ini_get('post_max_size'))) {
    echo 'File(s) too large.';
    $error = true;
}
if (csrfVerify() && (posted("copypaste") || filed("fileupload") || posted("directentry"))) {
    echo '<div style="font-size:0.8em;border:solid 1px #000000;display:inline-block;padding:5px;">
		<i>We are processing your questions right now...</i><br><br>';
    if (posted("directentry")) {
        $err = '';
        try {
            $q = new qIO();
            $q->addByArray($_POST["Q"]);
            $q->commit();
        } catch (Exception $e) {
            $err = "Error: " . $e->getMessage();
        }
        if ($err == '') {
            echo "Questions entered successfully, with Question-IDs <b>" . arrayToRanges($q->getQIDs()) . "</b><br><br><br>";
        } else {
            echo $err;
        }
    } else {
        require_class("qIO", "qParser");
        $qp = new qParser();
        $error = false;
        if (posted("copypaste")) {