javascriptcursus/php/admin/assignments.php

<?php $assignment = false; $page = null; $error = null; if(isset($_GET['id'])) { $client = new assignmentsClient(); $assignment = $client->getAssignment($_GET['id']); if(!$assignment) $error = '<div class="error">De opgegeven opdracht kon niet gevonden worden!</div>'; } if($assignment == false) { $page = new adminpage("Opdrachten"); if($error != null) $page->addContent($page->createWhiteBlock($error).'<br />'); $client = new assignmentsClient(); for($i = 1; $i < count($GLOBALS['chapter_titles']); ++$i) { $buffer="<h3>H$i - {$GLOBALS['chapter_titles'][$i][0]}</h3>"; $assignments = $client->getAssignmentsByChapter($i); if(count($assignments) == 0) $buffer .= '<p><i>Er zijn (nog) geen opdrachten voor dit hoofdstuk!</i></p>'; else { $buffer.='<ol class="assignment-list">'; foreach($assignments as $assignment) { $buffer.='<li>'. "<a href=\"javascript:void 0;\" class=\"expand-assignment\" id=\"assignment-{$assignment->id}\">". "<img id=\"assignment-{$assignment->id}-img\" src=\"img/arrow-right.png\" alt=\"Geef opdracht weer\" title=\"Geef opdracht weer\" /> ".($assignment->display ? "Opdracht {$assignment->nr}" : "Verborgen opdracht"). '</a>'. ' '.$page->generateLinkToH($assignment->chapter, $assignment->subChapter, "(H{$assignment->chapter}.{$assignment->subChapter})"). ($assignment->display ? null : ' - <i>verborgen voor bezoekers</i>'). "<span class=\"float-right\">". "<a href=\"admin.php?page=edit_assignment&amp;id={$assignment->id}\"><img src=\"img/edit.png\" alt=\"Bewerk opdracht\" title=\"Bewerk opdracht\" /></a> ". "<a href=\"admin.php?page=delete_assignment&amp;id={$assignment->id}\"><img src=\"img/delete.png\" alt=\"Verwijder opdracht\" title=\"Verwijder opdracht\" /></a>". '</span>'. "<div id=\"assignment-{$assignment->id}-details\" class=\"assignment-details\">". $assignment->assignment; $buffer .= '<div class="align-right">'; if($assignment->exampleCode != null) $buffer .= "<a href=\"voorbeeld.php?id={$assignment->id}\">Voorbeeld</a> - "; $buffer .= "<a href=\"admin.php?page=assignments&amp;id={$assignment->id}\">Bekijk antwoord</a>"; $buffer .= '</div>'; $buffer.='</div></li>'; } $buffer.='</ol>'; } $page->addContent($page->createWhiteBlock($buffer).'<br />'); } } else { $page = new adminpage("Hoofdstuk {$assignment->chapter} - ".($assignment->display ? "Opdracht {$assignment->nr}" : "Verborgen opdracht")); $page->addContent($page->createWhiteBlock("<h3>De opdracht:</h3>{$assignment->assignment}").'<br />'); if(!$assignment->viewAnswer) $page->addContent($page->createWhiteBlock('Merk op dat dit antwoord momenteel <b>niet</b> voor gewone bezoekers te zien is. U kunt het wel bekijken omdat u ingelogd bent als admin').'<br />'); $page->addContent($page->createWhiteBlock("<h3>Het antwoord:</h3>{$assignment->answer->text}")); if($assignment->answer->js != null || $assignment->answer->html != null) $page->addContent('<br />'); if($assignment->answer->js != null) $page->addJS($assignment->answer->js); if($assignment->answer->html != null) $page->addHTML($assignment->answer->html, $assignment->answer->htmlPlace == codePlace_head); } $page->printAll(); ?>

Resultaat

Made by Thijs Aarnoudse