Language::loadLanguageFile('de', $langTemplate, 'json', dirname(__FILE__) . '/'); // load user data from the database $databaseURI = $databaseURI . "/user/user/{$uid}"; $user = http_get($databaseURI, false); $user = json_decode($user, true); if (is_null($user)) { $user = array(); } $menu = MakeNavigationElement($user, PRIVILEGE_LEVEL::STUDENT, true, true); // construct a new header $h = Template::WithTemplateFile('include/Header/Header.template.html'); $h->bind($user); $h->bind(array("name" => Language::Get('main', 'title', $langTemplate), "hideBackLink" => "true", "notificationElements" => $notifications, "navigationElement" => $menu)); // sort courses by semester if (isset($user['courses']) && is_array($user['courses'])) { foreach ($user['courses'] as &$course) { $course['semesterInt'] = substr($course['course']['semester'], -4) * 2; if (substr($course['course']['semester'], 0, 2) == 'WS') { $course['semesterInt']--; } } $user['courses'] = LArraySorter::orderBy($user['courses'], 'semesterInt', SORT_DESC, 'name', SORT_ASC); } $pageData = array('uid' => isset($user['id']) ? $user['id'] : null, 'courses' => isset($user['courses']) ? $user['courses'] : null, 'sites' => PRIVILEGE_LEVEL::$SITES, 'statusName' => PRIVILEGE_LEVEL::$NAMES); // construct a login element $courseSelect = Template::WithTemplateFile('include/CourseSelect/CourseSelect.template.html'); $courseSelect->bind($pageData); // wrap all the elements in some HTML and show them on the page $w = new HTMLWrapper($h, $courseSelect); $w->set_config_file('include/configs/config_default.json'); $w->show();
</a> </div> </div> <div class="content-body-wrapper"> <div class="content-body left"> <ol class="full-width-list lower-alpha"> <?php if (isset($exercises)) { foreach ($exercises as $key => $exercise) { if (!isset($exercise['id'])) { $exercises[$key]['id'] = null; } } $exercises = LArraySorter::orderBy($exercises, 'linkName', SORT_ASC); foreach ($exercises as $key => $exercise) { $subtask = Template::WithTemplateFile('include/CreateSheet/Subtask.template.php'); $subtask->bind($exercise); if (isset($forms)) { $exerciseForms = array(); foreach ($forms as $form) { if (!isset($form['exerciseId'])) { continue; } if ($form['exerciseId'] == $exercise['id']) { $exerciseForms[] = $form; } } if (!empty($exerciseForms)) { $subtask->bind(array('forms' => $exerciseForms));
public static function finalizeSheets($result) { $result['content'] = LArraySorter::orderBy($result['content'], 'startDate', SORT_ASC, 'id', SORT_ASC); // sets the sheet names $id = 1; reset($result['content']); $isArray = true; if (gettype(current($result['content'])) == 'object') { $isArray = false; } foreach ($result['content'] as &$sheet) { if ($isArray) { if (!isset($sheet['sheetName']) || $sheet['sheetName'] == null) { $sheet['sheetName'] = 'Serie ' . (string) $id; $id++; } } else { if ($sheet->getSheetName() == null) { $sheet->setSheetName('Serie ' . (string) $id); $id++; } } } return $result; }
/** * Returns an exercise sheet with exercises. * * Called when this component receives an HTTP GET request to * /exercisesheet/exercisesheet/$sheetid(/). * * @param int $sheetid The id of the exercise sheet that should be returned. */ public function getExerciseSheetCourseExercise($courseid) { $sheetanswer = Request::routeRequest('GET', '/exercisesheet/course/' . $courseid . '/exercise', array(), '', $this->_getExerciseSheet, 'exercisesheet'); if ($sheetanswer['status'] == 200) { $body['sampleSolution'] = json_decode($sheetanswer['content'], true); $sheets = json_decode($sheetanswer['content'], true); // latest sheets on top if (is_array($sheets)) { $sheets = LArraySorter::reverse($sheets); // sort exercises by link = exerercises and linkName = subexercise ascendingly foreach ($sheets as &$sheet) { if (isset($sheet['exercises']) && is_array($sheet['exercises'])) { $sheet['exercises'] = LArraySorter::orderBy($sheet['exercises'], 'link', SORT_ASC, 'linkName', SORT_ASC); } } } $sheets = json_encode($sheets); $this->app->response->setBody($sheets); $this->app->response->setStatus(200); } else { $this->app->response->setStatus(409); } }