<?php
date_default_timezone_set('America/Los_Angeles');
$CONFIG = json_decode(file_get_contents(dirname(__FILE__) . '/course.json'));
$BASENAME = file_get_contents(dirname(__FILE__) . '/basename.txt');
$TYPE = $_GET['type'];
$ID = $_GET['id'];
$DIR = $TYPE == 'homework' ? $TYPE : "{$TYPE}s";
require dirname(__FILE__) . '/lib/writeups/php/structure.php';
require dirname(__FILE__) . '/lib/writeups/php/solutions.php';
$INFO = json_decode(file_get_contents(dirname(__FILE__) . "/$DIR/$ID/info.json"));
begin_structured_page();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><?= $INFO->title ?>: <?= $INFO->name ?> – <?= $CONFIG->course->long ?> <?= $CONFIG->title->long ?> – <?= $CONFIG->quarter->long ?></title>
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Droid+Sans:400,700|Droid+Sans+Mono:400|Open+Sans:400italic,700italic,400,700">
<!-- <link rel="stylesheet" href="<?= $BASENAME ?>/lib/global/css/droid_sans.css"> -->
<!-- <link rel="stylesheet" href="<?= $BASENAME ?>/lib/global/css/open_sans.css"> -->
<link rel="stylesheet" href="<?= $BASENAME ?>/lib/global/css/video-js.css">
<link rel="stylesheet" href="<?= $BASENAME ?>/lib/global/css/prettify.css">
<link rel="stylesheet" href="<?= $BASENAME ?>/lib/writeups/css/writeups.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="<?= $BASENAME ?>/lib/global/js/video.js" type="text/javascript"></script>
<script src="<?= $BASENAME ?>/lib/global/js/prettify/prettify.js" type="text/javascript"></script>
<script src="<?= $BASENAME ?>/lib/writeups/js/writeups.js" type="text/javascript"></script>
<?php if ($TYPE == 'lab' || $TYPE == 'minilab') { ?>
<script src="<?= $BASENAME ?>/lib/writeups/js/solutions.js" type="text/javascript"></script>
<?php } ?>
</head>
<body class="<?= $TYPE ?>">
<div id="writeup">
<header>
<hgroup>
<?php if ($TYPE == 'lab') { ?>
<h1><?= $INFO->title ?>: <?= $INFO->name ?></h1>
<h1><?= $INFO->subject ?></h1>
<?php } else { ?>
<h1><?= $INFO->title ?></h1>
<h1><?= $INFO->name ?></h1>
<?php } ?>
<h1><?= $CONFIG->course->long ?> <?= $CONFIG->quarter->long ?></h1>
</hgroup>
<?php if ($INFO->credit) { ?>
<aside class="credit"><?= $INFO->credit ?></aside>
<?php } ?>
</header>
<?php if ($INFO->due) { ?>
<aside class="due">Due: <?= $INFO->due ?></aside>
<?php } ?>
<?php if ($INFO->updated) { ?>
<aside class="updated"><span>Last updated: <?= date('l, F j, g:i a', filemtime(dirname(__FILE__) . "/$DIR/$ID/writeup.php")); ?></span></aside>
<?php } ?>
<?php if ($TYPE == 'lab' || $TYPE == 'minilab') { ?>
<section id="instructions">
<h3>Instructions</h3>
<ul>
<li>This lab is worth <strong><?= $INFO->points ?> points</strong> — 2 for participation, and <?= ($INFO->points - 2) ?> graded by your TA for completeness and correctness.</li>
<li>Don’t feel rushed to finish — just submit whatever you’ve done (whether complete or not) at the end of today’s lab session for your 2 participation points, then you’ll have 72 hours to complete and submit your final lab.</li>
<li>Feel free to talk to your friends!</li>
<li>If you get stuck, you can ask your friends or your TA for help.</li>
<li>When you’re finished be sure to submit your work via the <strong>drop box</strong> on the course website to get credit!</li>
</ul>
</section>
<?php } ?>
<nav id="contents">
<h3>Contents</h3>
%%TOC%%
</nav>
<div id="content">
<?php require dirname(__FILE__) . "/$DIR/$ID/writeup.php" ?>
</div>
</div>
<?php if (file_exists(dirname(__FILE__) . "/$DIR/$ID/solutions.php")) { ?>
<div id="trailer">
<div id="reveal"> </div>
<section id="solution" style="display: none">
<header>
<h2>Solution</h2>
</header>
<?php require dirname(__FILE__) . "/$DIR/$ID/solutions.php" ?>
</section>
</div>
<?php } ?>
</body>
</html>
<?php generate_structured_page(); ?>