Esempio n. 1
0
 public function getSchedule(\DOMElement $context)
 {
     // TODO: Schedule should be a class by itself, this is too big.
     $calendar = new Calendar();
     $begin = clone $this->timestamp;
     $holidays = $calendar->holidays;
     $now = new \DateTime();
     $week = new \DateInterval('P7D');
     $out = [];
     $index = 0;
     $course = $context['@course'];
     $section = $context['@id'];
     while ($begin < $calendar->semester['end']) {
         $interval = $now->diff($begin);
         \bloc\application::instance()->log();
         $key = $index;
         $date = ['section' => $section, 'course' => $course, 'date' => $begin->format('M d'), 'datetime' => $begin->format(\DateTime::RFC3339), 'status' => $now->format('U') > $begin->format('U') - 1000 ? 'transpired' : 'pending', 'index' => $index++, 'ticker' => $interval->format('%r') === '-' ? $interval->format('%a days ago') : $interval->format('%a days')];
         foreach ($holidays as $idx => $holiday) {
             if ($holiday['start'] <= $begin && $holiday['end'] >= $begin) {
                 $date['index'] = 'Break';
                 unset($date['section']);
                 $date['status'] = 'holiday';
                 $index--;
                 $key = 'holiday' . $idx;
                 break;
             }
         }
         $out[$key] = $date;
         $begin->add($week);
     }
     return $out;
 }
Esempio n. 2
0
 protected function POSTevaluate(Admin $instructor, $request, $topic, $index, $sid)
 {
     $student = new Student($sid);
     $item = Data::FACTORY($topic, $student->evaluation($topic, $index), $_POST);
     if ($item->save()) {
         \bloc\router::redirect("/records/student/{$sid}");
     } else {
         \bloc\application::instance()->log($item);
         $view = new View(self::layout);
         $view->content = "views/layouts/error.html";
         return $view->render($this(['message' => "did not save"]));
     }
 }
Esempio n. 3
0
    $app->session('COLUM');
});
$app->prepare('clean-up', function ($app) {
    session_write_close();
});
# main page deal
$app->prepare('http-request', function ($app, $params) {
    $request = new Request($params);
    $response = new Response($request);
    $app->setExchanges($request, $response);
    // Provide a namespace (also a directory) to load objects that can respond to controller->action
    $router = new Router('controllers', $request);
    try {
        $output = $router->delegate('lecture', 'index');
    } catch (\Exception $e) {
        \bloc\application::instance()->log($e->getTrace());
        $view = new View(\controllers\records::layout);
        $view->content = 'views/layouts/error.html';
        $output = $view->render(['message' => $e->getMessage()]);
    }
    // default controller and action as arguments, in case nothin doin in the request
    $response->setBody($output);
    if (getenv('MODE') === 'local' && count($app->log()) > 0) {
        $app->execute('debug', $response);
    }
    echo $response;
});
$app->prepare('debug', function ($app, $response) {
    $app::instance()->log('Peak Memory: ' . round(memory_get_peak_usage() / pow(1024, 2), 4) . "Mb");
    $app::instance()->log('Executed in: ' . round(microtime(true) - $app->benchmark, 4) . "s");
    $output = $response->getBody();