예제 #1
0
<?php

require_once 'common.inc.php';
use Battis\SimpleCache;
use smtech\StMarksSmarty\StMarksSmarty;
$smarty->assign('name', 'Generate Standards Map');
$smarty->assign('category', 'CurricUplan');
$cache = new Battis\SimpleCache($sql, basename(__FILE__, '.php'));
$cache->setLifetime(Battis\SimpleCache::IMMORTAL_LIFETIME);
/* have we been given a map ID to generate from cached data? */
if (!empty($_REQUEST['map'])) {
    /* initialize our containers empty */
    $courses = array();
    $map = array();
    $level = array();
    /* parse the HTML we've cached */
    $dom = DOMDocument::loadHTML(tidy_parse_string($cache->getCache($_REQUEST['map']), array('output-xhtml' => true)));
    /* walk through the parsed html, table row by table row */
    $xpath = new DOMXpath($dom);
    $parsingCourses = 0;
    $standard = '';
    foreach ($xpath->query("//tr[@class[contains(.,'stds')]]") as $node) {
        /* pull out standards and courses at that standard level and their coverage of that standard */
        $nextStandard = $xpath->query(".//th[@class[contains(.,'hier')]]", $node);
        $nextStandard = trim($nextStandard->length > 0 ? $nextStandard->item(0)->nodeValue : false);
        $course = $xpath->query(".//th[@class='rowgrouplabel']", $node);
        $course = trim($course->length > 0 ? $course->item(0)->nodeValue : false);
        $total = $xpath->query(".//span[@class='spanLevelMatches']", $node);
        $total = trim($total->length > 0 ? $total->item(0)->nodeValue : false);
        /* if we're still parsing courses (between standard title and first standard group)... */
        if ($parsingCourses !== false) {