mirror of
https://github.com/idanoo/nzart-exam-generator.git
synced 2024-12-04 22:26:58 +00:00
Added more screwerey
This commit is contained in:
parent
46db8d50cf
commit
d32379193d
33
insert.php
33
insert.php
@ -6,20 +6,43 @@ if (isset($_REQUEST['raw'])) {
|
|||||||
$data = array_map('trim', $data);
|
$data = array_map('trim', $data);
|
||||||
foreach($data as $i=>$d) {
|
foreach($data as $i=>$d) {
|
||||||
if(empty($d)) continue;
|
if(empty($d)) continue;
|
||||||
if (strpos($d, 'Question') !== false) {
|
if (strpos(strtolower($d), 'question') !== false) {
|
||||||
$fullQuestion = substr(preg_replace('/^.+\n/', '', $d),1); //Strip useless firstline.
|
$fullQuestion = substr(preg_replace('/^.+\n/', '', $d),1); //Strip useless firstline.
|
||||||
$numbers = explode(" ", $fullQuestion);
|
$numbers = explode(" ", $fullQuestion);
|
||||||
$questions[$i]['questionNumber'] = $numbers[0]; // Get # of question
|
$questions[$i]['questionNumber'] = $numbers[0]; // Get # of question
|
||||||
|
|
||||||
$lengthOfNumber = strlen($questions[$i]['questionNumber']); //Get length of #
|
$lengthOfNumber = strlen($questions[$i]['questionNumber']); //Get length of #
|
||||||
$splitNewLine = explode("\n", trim($fullQuestion)); //Split rest into lines.
|
$splitNewLine = explode("\n", trim($fullQuestion)); //Split rest into lines.
|
||||||
$questions[$i]['question'] = trim(substr($splitNewLine[0], $lengthOfNumber));
|
$twoLineQuestion = $imageFirstLine = false;
|
||||||
|
if (strpos(strtolower($splitNewLine[0]), '<img') !== false) {
|
||||||
|
preg_match('/".*?"/', $splitNewLine[0], $matches);
|
||||||
|
$questions[$i]['image'] = strtoupper($matches[0]);
|
||||||
|
$imageFirstLine = true;
|
||||||
|
}
|
||||||
|
if ($imageFirstLine) {
|
||||||
|
if (strpos($splitNewLine[1], ':') !== false || !empty(trim($splitNewLine[2]))) {
|
||||||
|
$twoLineQuestion = true;
|
||||||
|
}
|
||||||
|
$cutOutImageShit = explode(">", $splitNewLine[1]);
|
||||||
|
$trashBin = array_shift($cutOutImageShit);
|
||||||
|
$firstLine = implode(" ", $cutOutImageShit);
|
||||||
|
$questions[$i]['question'] = trim(substr(($twoLineQuestion ? $firstLine . " "
|
||||||
|
. $splitNewLine[2] : $firstLine), $lengthOfNumber));
|
||||||
|
} else {
|
||||||
|
if (strpos($splitNewLine[0], ':') !== false || !empty(trim($splitNewLine[1]))) {
|
||||||
|
$twoLineQuestion = true;
|
||||||
|
}
|
||||||
|
$questions[$i]['question'] = trim(substr(($twoLineQuestion ? $splitNewLine[0] . " "
|
||||||
|
. $splitNewLine[1] : $splitNewLine[0]), $lengthOfNumber));
|
||||||
|
}
|
||||||
$x=$b=1;
|
$x=$b=1;
|
||||||
foreach ($splitNewLine as $a=>$line) {
|
foreach ($splitNewLine as $a=>$line) {
|
||||||
if($a==0) continue;
|
if($a==0) continue;
|
||||||
|
if(($twoLineQuestion || $imageFirstLine) && $a==1) continue;
|
||||||
|
if($twoLineQuestion && $imageFirstLine && $a==2) continue;
|
||||||
if(empty(trim($line))) continue;
|
if(empty(trim($line))) continue;
|
||||||
if(strpos($line, 'totallines') !== false) continue;
|
if(strpos(strtolower($line), 'totallines') !== false) continue;
|
||||||
if(strpos($line, '<img') !== false) {
|
|
||||||
|
if(strpos(strtolower($line), '<img') !== false) {
|
||||||
preg_match('/".*?"/', $line, $matches);
|
preg_match('/".*?"/', $line, $matches);
|
||||||
$questions[$i]['image'] = strtoupper($matches[0]);
|
$questions[$i]['image'] = strtoupper($matches[0]);
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user