Example #1
0
//get exceptions
$now = time() + $previewshift;
$exceptions = array();
if (!isset($teacherid) && !isset($tutorid)) {
    $query = "SELECT items.id,ex.startdate,ex.enddate,ex.islatepass,ex.waivereqscore FROM ";
    $query .= "imas_exceptions AS ex,imas_items as items,imas_assessments as i_a WHERE ex.userid='{$userid}' AND ";
    $query .= "ex.assessmentid=i_a.id AND (items.typeid=i_a.id AND items.itemtype='Assessment') ";
    // $query .= "AND (($now<i_a.startdate AND ex.startdate<$now) OR ($now>i_a.enddate AND $now<ex.enddate))";
    //$query .= "AND (ex.startdate<$now AND $now<ex.enddate)";
    $result = mysql_query($query) or die("Query failed : {$query} " . mysql_error());
    while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $exceptions[$line['id']] = array($line['startdate'], $line['enddate'], $line['islatepass'], $line['waivereqscore']);
    }
}
if (count($exceptions) > 0) {
    upsendexceptions($items);
}
//if ($_GET['folder']!='0') {
if (strpos($_GET['folder'], '-') !== false) {
    $now = time() + $previewshift;
    $blocktree = explode('-', $_GET['folder']);
    $backtrack = array();
    for ($i = 1; $i < count($blocktree); $i++) {
        $backtrack[] = array($items[$blocktree[$i] - 1]['name'], implode('-', array_slice($blocktree, 0, $i + 1)));
        if (!isset($teacherid) && !isset($tutorid) && $items[$blocktree[$i] - 1]['avail'] < 2 && $items[$blocktree[$i] - 1]['SH'][0] != 'S' && ($now < $items[$blocktree[$i] - 1]['startdate'] || $now > $items[$blocktree[$i] - 1]['enddate'] || $items[$blocktree[$i] - 1]['avail'] == '0')) {
            $_GET['folder'] = 0;
            $items = unserialize($line['itemorder']);
            unset($backtrack);
            unset($blocktree);
            break;
        }
Example #2
0
function upsendexceptions(&$items)
{
    global $exceptions;
    $minsdate = 9999999999.0;
    $maxedate = 0;
    foreach ($items as $k => $item) {
        if (is_array($item)) {
            $hasexc = upsendexceptions($items[$k]['items']);
            if ($hasexc != FALSE) {
                if ($hasexc[0] < $items[$k]['startdate']) {
                    $items[$k]['startdate'] = $hasexc[0];
                }
                if ($hasexc[1] > $items[$k]['enddate']) {
                    $items[$k]['enddate'] = $hasexc[1];
                }
                //return ($hasexc);
                if ($hasexc[0] < $minsdate) {
                    $minsdate = $hasexc[0];
                }
                if ($hasexc[1] > $maxedate) {
                    $maxedate = $hasexc[1];
                }
            }
        } else {
            if (isset($exceptions[$item])) {
                // return ($exceptions[$item]);
                if ($exceptions[$item][0] < $minsdate) {
                    $minsdate = $exceptions[$item][0];
                }
                if ($exceptions[$item][1] > $maxedate) {
                    $maxedate = $exceptions[$item][1];
                }
            }
        }
    }
    if ($minsdate < 9999999999.0 || $maxedate > 0) {
        return array($minsdate, $maxedate);
    } else {
        return false;
    }
}