javascriptcursus/opdrachten.php
<?php
// Includes:
require_once 'php/page.php';
// Page:
$assignment = false;
$page = null;
$error = null;
if(isset($_GET['id']))
{
$client = new assignmentsClient();
$assignment = $client->getAssignment($_GET['id'], true);
if(!$assignment)
$error = '<div class="error">De opgegeven opdracht kon niet gevonden worden!</div>';
}
if(!$assignment)
{
$page = new page("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, true);
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\" /> Opdracht {$assignment->nr}".
'</a>'.
' '.$page->generateLinkToH($assignment->chapter, $assignment->subChapter, "(H{$assignment->chapter}.{$assignment->subChapter})").
"<div id=\"assignment-{$assignment->id}-details\" class=\"assignment-details\">".
$assignment->assignment;
if($assignment->viewAnswer || $assignment->exampleCode != null)
{
$buffer .= '<div class="align-right">';
if($assignment->exampleCode != null)
$buffer .= "<a href=\"voorbeeld.php?id={$assignment->id}\">Voorbeeld</a>".($assignment->viewAnswer ? ' - ' : null);
if($assignment->viewAnswer)
$buffer .= "<a href=\"opdrachten.php?id={$assignment->id}\">Bekijk antwoord</a>";
$buffer .= '</div>';
}
$buffer.='</div></li>';
}
$buffer.='</ol>';
}
$page->addContent($page->createWhiteBlock($buffer).'<br />');
}
}
else
{
$page = new page("Hoofdstuk {$assignment->chapter} - Opdracht {$assignment->nr}");
$page->addContent($page->createWhiteBlock("<h3>De opdracht:</h3>{$assignment->assignment}").'<br />');
if($assignment->viewAnswer)
{
$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);
}
else
$page->addContent($page->createWhiteBlock("<h3>Het antwoord:</h3>Het antwoord is (nog) niet beschikbaar, de docent kan namelijk kiezen wanneer de antwoorden vrijgegeven worden in verband met eventueel huiswerk."));
}
$page->printAll();
?>
Resultaat
Made by Thijs Aarnoudse