Пример #1
0
 /**
  * common tasks for all actions
  */
 function before_filter(&$action, &$args)
 {
     global $perm;
     parent::before_filter($action, $args);
     $course_id = $args[0];
     $this->course_id = Request::option('cid', $course_id);
     Navigation::activateItem('/course/admin/admission');
     if (!get_object_type($this->course_id, array('sem')) || SeminarCategories::GetBySeminarId($this->course_id)->studygroup_mode || !$perm->have_studip_perm("tutor", $this->course_id)) {
         throw new Trails_Exception(403);
     }
     $this->course = Course::find($this->course_id);
     $this->user_id = $GLOBALS['user']->id;
     PageLayout::setHelpKeyword("Basis.VeranstaltungenVerwaltenZugangsberechtigungen");
     PageLayout::setTitle($this->course->getFullname() . " - " . _("Verwaltung von Zugangsberechtigungen"));
     $lockrules = words('admission_turnout admission_type admission_endtime admission_binding passwort read_level write_level admission_prelim admission_prelim_txt admission_starttime admission_endtime_sem admission_disable_waitlist user_domain admission_binding admission_studiengang');
     foreach ($lockrules as $rule) {
         $this->is_locked[$rule] = LockRules::Check($this->course_id, $rule) ? 'disabled readonly' : '';
     }
     if (!SeminarCategories::GetByTypeId($this->course->status)->write_access_nobody) {
         $this->is_locked['write_level'] = 'disabled readonly';
     }
     update_admission($this->course->id);
     PageLayout::addSqueezePackage('admission');
     URLHelper::addLinkParam('return_to_dialog', Request::get('return_to_dialog'));
 }
Пример #2
0
 public function before_filter(&$action, &$args)
 {
     parent::before_filter($action, $args);
     $course_id = Request::option('sem_id', $args[0]);
     if (empty($course_id)) {
         checkObject();
         //wirft Exception, wenn $SessionSeminar leer ist
         $course_id = $GLOBALS['SessionSeminar'];
     }
     $this->course = Course::find($course_id);
     if (!$this->course) {
         throw new Trails_Exception(400);
     }
     $this->send_from_search_page = Request::get('send_from_search_page');
     if ($GLOBALS['SessionSeminar'] != $this->course->id && !(int) $this->course->visible && !($GLOBALS['perm']->have_perm(Config::get()->SEM_VISIBILITY_PERM) || $GLOBALS['perm']->have_studip_perm('user', $this->course->id))) {
         throw new AccessDeniedException(_('Diese Veranstaltung ist versteckt. Hier gibt es nichts zu sehen.'));
     }
     if (!preg_match('/^(' . preg_quote($GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP'], '/') . ')?([a-zA-Z0-9_-]+\\.php)([a-zA-Z0-9_?&=-]*)$/', $this->send_from_search_page)) {
         $this->send_from_search_page = '';
     }
     if ($this->course->getSemClass()->offsetGet('studygroup_mode')) {
         if ($GLOBALS['perm']->have_studip_perm('autor', $this->course->id)) {
             // participants may see seminar_main
             $link = URLHelper::getUrl('seminar_main.php', array('auswahl' => $this->course->id));
         } else {
             $link = URLHelper::getUrl('dispatch.php/course/studygroup/details/' . $this->course->id, array('send_from_search_page' => $this->send_from_search_page));
         }
         $this->redirect($link);
         return;
     }
 }
Пример #3
0
 function getTabNavigation($course_id)
 {
     $object_type = get_object_type($course_id, array('sem', 'inst'));
     if ($object_type === 'sem') {
         $course = Course::find($course_id);
         $sem_class = $GLOBALS['SEM_CLASS'][$GLOBALS['SEM_TYPE'][$course->status]['class']] ?: SemClass::getDefaultSemClass();
     } else {
         $institute = Institute::find($course_id);
         $sem_class = SemClass::getDefaultInstituteClass($institute->type);
     }
     $navigation = new Navigation(_('Übersicht'));
     $navigation->setImage(Icon::create('seminar', 'info_alt'));
     $navigation->setActiveImage(Icon::create('seminar', 'info'));
     if ($object_type !== 'sem') {
         $navigation->addSubNavigation('info', new Navigation(_('Kurzinfo'), 'dispatch.php/institute/overview'));
         $navigation->addSubNavigation('courses', new Navigation(_('Veranstaltungen'), 'show_bereich.php?level=s&id=' . $course_id));
         $navigation->addSubNavigation('schedule', new Navigation(_('Veranstaltungs-Stundenplan'), 'dispatch.php/calendar/instschedule?cid=' . $course_id));
         if ($GLOBALS['perm']->have_studip_perm('admin', $course_id)) {
             $navigation->addSubNavigation('admin', new Navigation(_('Administration der Einrichtung'), 'dispatch.php/institute/basicdata/index?new_inst=TRUE'));
         }
     } else {
         $navigation->addSubNavigation('info', new Navigation(_('Kurzinfo'), 'dispatch.php/course/overview'));
         if (!$sem_class['studygroup_mode']) {
             $navigation->addSubNavigation('details', new Navigation(_('Details'), 'dispatch.php/course/details/'));
         }
         if (!$course->admission_binding && in_array($GLOBALS['perm']->get_studip_perm($course_id), array('user', 'autor'))) {
             $navigation->addSubNavigation('leave', new Navigation(_('Austragen aus der Veranstaltung'), 'dispatch.php/my_courses/decline/' . $course_id . '?cmd=suppose_to_kill'));
         }
     }
     return array('main' => $navigation);
 }
 public static function sandbox()
 {
     // Testaa koodiasi täällä
     // echo 'Hello World!';
     // View::make('helloworld.html');
     $tali = Course::find(2);
     $courses = Course::all();
     Kint::dump($tali);
     Kint::dump($courses);
 }
 /**
  * Displays course edit page.
  *
  * @param int $id Id of course to be edited.
  */
 public static function edit($id)
 {
     $player = self::get_user_logged_in();
     if (!$player) {
         View::make('player/login.html', array('error' => 'Vain kirjautuneet käyttäjät voivat muokata ratoja.'));
     } else {
         $course = Course::find($id);
         $holes = Hole::find_by_course($id);
         View::make('course/edit.html', array('course' => $course, 'holes' => $holes));
     }
 }
Пример #6
0
 public function suggestIssue($course_id)
 {
     $course = Course::find($course_id);
     $program = Program::find($course->program->id);
     $year = date('y');
     $month = date('m');
     $counter = Issue::where('project_id', '=', Auth::user()->curr_project_id)->count();
     $counter += 1;
     $issue = substr($program->name, 0, 1) . $year . $month . str_pad($counter, 5, "0", STR_PAD_LEFT);
     return Response::json(array('issue' => $issue));
 }
 /**
  * Displays a listing of a user's list of all played rounds.
  *
  * @param int $id Id of player to be displayed.
  */
 public static function show($id)
 {
     $player = Player::find($id);
     $moderatorOf = Course::find_by_moderator($id);
     $course = Course::find($player->course);
     $scores = Score::find_by_player($player->id);
     foreach ($scores as $score) {
         $score->round = Round::find($score->roundId);
     }
     // $rounds = Round::find_by_player($player->id);
     // Kint::dump($rounds);
     View::make('player/show.html', array('player' => $player, 'scores' => $scores, 'moderatorOf' => $moderatorOf, 'course' => $course));
 }
Пример #8
0
 /**
  * Validate shopping cart input data
  * @author Anyun
  * @param  object $data
  * @return  
  */
 public static function isValid($data)
 {
     $app = \Slim\Slim::getInstance();
     $validata = $app->validata;
     $validator = $validata::key('id', $validata::numeric()->notEmpty())->key('course_id', $validata::numeric()->notEmpty())->key('name', $validata::stringType()->notEmpty())->key('price', $validata::numeric())->key('qty', $validata::digit()->notEmpty());
     if (!$validator->validate((array) $data)) {
         $app->halt(400, json_encode('Cart Info is invalid.'));
     }
     $sale = Price::find($data->id);
     if (!$sale || $sale->course_id != $data->course_id || !Course::find($data->course_id)) {
         $app->halt(400, 'Cart Info is invalid.');
     }
 }
 function testFind()
 {
     $name = "History";
     $course_number = "HIST100";
     $test_course = new Course($name, $course_number);
     $test_course->save();
     $name2 = "Math";
     $course_number2 = "MATH100";
     $test_course2 = new Course($name, $course_number);
     $test_course2->save();
     $result = Course::find($test_course->getId());
     $this->assertEquals($test_course, $result);
 }
Пример #10
0
 /**
  * Notifies the user with Stud.IP-message that/he/she was mentioned in a
  * blubber-posting.
  * @param type $posting
  */
 public function mention($posting)
 {
     $messaging = new messaging();
     setTempLanguage($this->getId());
     $url = $GLOBALS['ABSOLUTE_URI_STUDIP'] . "plugins.php/blubber/streams/thread/" . $posting['root_id'] . ($posting['context_type'] === "course" ? '?cid=' . $posting['Seminar_id'] : "");
     $body = sprintf(gettext("%s hat Sie in einem Blubber erwähnt. Zum Beantworten klicken auf Sie auf folgenen Link:\n\n%s\n"), get_fullname(), $url);
     if ($posting['context_type'] === "course" && !$GLOBALS['perm']->have_studip_perm("user", $posting['Seminar_id'], $this->getId())) {
         $body .= "\n\n" . _("Sie sind noch kein Mitglied der zugehörigen Veranstaltung. Melden Sie sich erst hier an, damit Sie den Blubber sehen können: ") . ($GLOBALS['SEM_CLASS'][$GLOBALS['SEM_TYPE'][Course::find($posting['Seminar_id'])->status]['class']]['studygroup_mode'] ? $GLOBALS['ABSOLUTE_URI_STUDIP'] . "dispatch.php/course/studygroup/details/" . $posting['Seminar_id'] : $GLOBALS['ABSOLUTE_URI_STUDIP'] . "dispatch.php/course/details?sem_id=" . $posting['Seminar_id']);
     }
     $mention_text = _("Sie wurden erwähnt.");
     restoreLanguage();
     $messaging->insert_message($body, $this['username'], $GLOBALS['user']->id, null, null, null, null, $mention_text);
 }
 function test_find()
 {
     $course_name = "History";
     $course_number = "HIST 101";
     $test_course = new Course($course_name, $course_number);
     $test_course->save();
     $course_name2 = "Biology";
     $course_number2 = "BIO 101";
     $test_course2 = new Course($course_name2, $course_number2);
     $test_course2->save();
     $result = Course::find($test_course->getId());
     $this->assertEquals($test_course, $result);
 }
 function testFind()
 {
     $course_name = "History";
     $course_code = "HIST100";
     $test_course = new Course($course_name, $course_code);
     $test_course->save();
     $course_name2 = "Gym";
     $course_code2 = "GYM100";
     $test_course2 = new Course($course_name2, $course_code2);
     $test_course2->save();
     $result = Course::find($test_course->getId());
     $this->assertEquals($test_course, $result);
 }
Пример #13
0
 /**
  * Returns the currently active course or false if none is active.
  *
  * @return mixed Course object of currently active course, false otherwise
  * @since 3.0
  */
 public static function findCurrent()
 {
     if (empty($GLOBALS['SessionSeminar'])) {
         return null;
     }
     if (isset(self::$current_course) && $GLOBALS['SessionSeminar'] === self::$current_course->id) {
         return self::$current_course;
     }
     $found = Course::find($GLOBALS['SessionSeminar']);
     if ($found) {
         self::$current_course = $found;
         Seminar::setInstance(new Seminar(self::$current_course));
         return self::$current_course;
     }
 }
Пример #14
0
 function getTabNavigation($course_id)
 {
     #$navigation = new AutoNavigation(_('Teilnehmende'));
     $navigation = new Navigation(_('Teilnehmende'));
     $navigation->setImage(Icon::create('persons', 'info_alt'));
     $navigation->setActiveImage(Icon::create('persons', 'info'));
     $navigation->addSubNavigation('view', new Navigation(_('Teilnehmende'), 'dispatch.php/course/members'));
     if (Course::find($course_id)->aux_lock_rule) {
         $navigation->addSubNavigation('additional', new Navigation(_('Zusatzangaben'), 'dispatch.php/course/members/additional'));
     }
     $navigation->addSubNavigation('view_groups', new Navigation(_('Funktionen / Gruppen'), 'statusgruppen.php?view=statusgruppe_sem'));
     if ($GLOBALS['perm']->have_studip_perm('tutor', $course_id) && !LockRules::check($course_id, 'groups')) {
         $navigation->addSubNavigation('edit_groups', new Navigation(_('Funktionen / Gruppen verwalten'), 'admin_statusgruppe.php?new_sem=TRUE&range_id=' . $course_id));
     }
     return array('members' => $navigation);
 }
Пример #15
0
 private function parseSeminar($id)
 {
     $course = Course::find($id);
     $dates = $course->getDatesWithExdates()->findBy('end_time', array($this->start, $this->start + $this->timespan), '><');
     foreach ($dates as $courseDate) {
         // Build info
         $info = array();
         if ($courseDate->dozenten[0]) {
             $info[_('Durchführende Dozenten')] = join(', ', $courseDate->dozenten->getFullname());
         }
         if ($courseDate->statusgruppen[0]) {
             $info[_('Beteiligte Gruppen')] = join(', ', $courseDate->statusgruppen->getValue('name'));
         }
         // Store for view
         $this->termine[] = array('id' => $courseDate->id, 'chdate' => $courseDate->chdate, 'title' => $courseDate->getFullname() . ($courseDate->topics[0] ? ', ' . join(', ', $courseDate->topics->getValue('title')) : ""), 'description' => $courseDate instanceof CourseExDate ? $courseDate->content : '', 'topics' => $courseDate->topics->toArray('title description'), 'room' => $courseDate->getRoomName(), 'info' => $info);
     }
 }
Пример #16
0
 /**
  * Common tasks for all actions
  *
  * @param String $action Called action
  * @param Array  $args   Possible arguments
  */
 public function before_filter(&$action, &$args)
 {
     global $perm;
     $this->current_action = $action;
     parent::before_filter($action, $args);
     $course_id = $args[0];
     $this->course_id = Request::option('cid', $course_id);
     if ($course_id != '-') {
         //Navigation in der Veranstaltung:
         Navigation::activateItem('/course/admin/room_requests');
         if (!get_object_type($this->course_id, array('sem')) || SeminarCategories::GetBySeminarId($this->course_id)->studygroup_mode || !$perm->have_studip_perm("tutor", $this->course_id)) {
             throw new Trails_Exception(400);
         }
         PageLayout::setHelpKeyword("Basis.VeranstaltungenVerwaltenAendernVonZeitenUndTerminen");
         PageLayout::setTitle(Course::find($this->course_id)->getFullname() . " - " . _("Verwaltung von Raumanfragen"));
     }
 }
Пример #17
0
 public function edit()
 {
     $adminId = Session::get('admin_id');
     if (!isset($adminId)) {
         return Redirect::to('/');
     }
     if (isset($id)) {
         $course = Course::find($id);
         if (isset($course)) {
             Session::put('courier_id', $id);
             return View::make('course.edit')->with('course', $course);
         } else {
             return Redirect::to('/');
         }
     } else {
         return Redirect::to('/');
     }
 }
Пример #18
0
 function test_find()
 {
     //Arrange
     $test_department = new Department("Biology", "346 Stupid Avenue");
     $test_department->save();
     $name = "History 0001";
     $code = "HS001";
     $test_course = new Course($name, $code, $test_department->getId());
     $test_course->save();
     $name2 = "Dogs 101";
     $code2 = "DW101";
     $test_course2 = new Course($name2, $code2, $test_department->getId());
     $test_course2->save();
     //Act
     $result = Course::find($test_course->getId());
     //Assert
     $this->assertEquals($test_course, $result);
 }
Пример #19
0
 public function update($id)
 {
     $course = Course::find($id);
     $days = implode(",", Input::get('days'));
     $costs = Input::get('costs');
     $costs = str_replace(",", ".", $costs);
     $costs = str_replace(".", "", $costs);
     $costs = substr($costs, 0, -2);
     $course->classification_id = Input::get('classification');
     $course->program_id = Input::get('program');
     $course->generation_id = Input::get('generation');
     $course->name = Input::get('name');
     $course->description = Input::get('description');
     $course->course_days = $days;
     $course->costs = $costs;
     $course->capacity = Input::get('capacity');
     $course->availability = Input::get('status');
     $course->save();
     Session::flash('message', 'Sukses mengupdate data Kelas!');
 }
Пример #20
0
 public function books($id)
 {
     if (isset($id)) {
         $course = Course::find($id);
         if (isset($course)) {
             //                $books = Book::where('status', 'active')->where('course_id', $id)->get();
             $books = Product::where('status', 'active')->where('category', 'book')->where('course_id', $id)->get();
             Session::put('course_id', $id);
             $cart = Session::get('cart');
             if (isset($books) && count($books) > 0) {
                 return View::make('book.list')->with('found', true)->with('books', $books)->with('course', $course)->with('cart', $cart);
             } else {
                 return View::make('book.list')->with('found', false)->with('course', $course);
             }
         } else {
             return Redirect::to('/');
         }
     } else {
         return Redirect::to('/');
     }
 }
Пример #21
0
/**
 * @param string $comment
 * @param array $dates SingleDate
 */
function raumzeit_send_cancel_message($comment, $dates)
{
    if (!is_array($dates)) {
        $dates = array($dates);
    }
    $course = Course::find($dates[0]->range_id);
    if ($course) {
        $subject = sprintf(_("[%s] Terminausfall"), $course->name);
        $recipients = $course->members->pluck('username');
        $lecturers = $course->members->findBy('status', 'dozent')->pluck('nachname');
        $message = sprintf(_("In der Veranstaltung %s fällt der/die folgende(n) Termine aus:"), $course->name . ' (' . join(',', $lecturers) . ') ' . $course->start_semester->name);
        $message .= "\n\n- ";
        $message .= join("\n- ", array_map(function ($a) {
            return $a->toString();
        }, $dates));
        if ($comment) {
            $message .= "\n\n" . $comment;
        }
        $msg = new messaging();
        return $msg->insert_message($message, $recipients, '____%system%____', '', '', '', '', $subject, true);
    }
}
Пример #22
0
 public static function getManufacturerCourses($idCourse, $cartArr = null)
 {
     if (is_null($cartArr)) {
         $cartArr = [$idCourse];
     }
     $app = \Slim\Slim::getInstance();
     $data = Course::find($idCourse);
     if (!$data) {
         //course not exist
         $app->halt(400, 'course not exist');
     } else {
         $result = Course::has('price')->where('manufacturer', 'like', $data->manufacturer)->whereNotIn('id', $cartArr)->get();
         $array = [];
         foreach ($result as $key => $value) {
             $course = Course::find($value->id);
             $price = Course::find($value->id)->price()->orderBy('length')->first();
             //life time is priority
             $price['type'] = $course->type;
             $price['name'] = $course->name;
             array_push($array, $price);
         }
         return json_encode($array);
     }
 }
Пример #23
0
 private function requireCourse($id)
 {
     if (!($course = \Course::find($id))) {
         $this->notFound("Course not found");
     }
     if (!$GLOBALS['perm']->have_studip_perm('user', $id, $GLOBALS['user']->id)) {
         $this->error(401);
     }
     return $course;
 }
Пример #24
0
?>
                        <?php 
echo LinkButton::create(_('Nachricht an alle Angemeldeten'), $controller->url_for('admission/courseset/applicants_message/' . $courseset->getId()), array('data-dialog' => ''));
?>
                        <? endif ?>
                </div>
            <? endif ?>
        <? else :?>
            <? if (count($courseIds) > 100) :?>
                <?php 
echo sprintf(_("%s zugewiesene Veranstaltungen"), count($courseIds));
?>
            <? else : ?>
                <? foreach ($courseIds as $course_id) : ?>
                    <?php 
echo htmlReady(Course::find($course_id)->name);
?>
                    <br>
                <?  endforeach ?>
            <? endif ?>
        <? endif ?>
    </fieldset>
    <fieldset>
        <legend><?php 
echo _('Anmelderegeln');
?>
</legend>
        <div id="rules">
            <?php 
if ($courseset) {
    ?>
Пример #25
0
 /**
  * Checks if round is ready to be saved. If not, displays round edit page with information already inputted. If yes, attempts to update selected round and related scores.
  *
  * @param int $id Id of selected round.
  */
 public static function update($id)
 {
     $player = self::get_user_logged_in();
     if (!$player) {
         View::make('player/login.html', array('error' => 'Vain kirjautuneet käyttäjät voivat muokata ratoja.'));
     }
     $params = $_POST;
     $players = Player::all();
     $course = Course::find($params['course']);
     $courses = Course::all();
     $played = $params['played'];
     $round = Round::find($id);
     $holes = Hole::find_by_course($course->id);
     $scores = Score::find_by_round($id);
     $numberOfPlayers = sizeof($scores);
     if ($params['course'] != $params['course_orig']) {
         // If course selection has changed we need to display edit page again with new information.
         $playerScores = array();
         $numberOfHoles = Hole::count_holes($params['course_orig']);
         for ($i = 1; $i <= $numberOfPlayers; $i++) {
             $holeScores = array();
             for ($j = 1; $j <= $numberOfHoles; $j++) {
                 $holeScores[] = $params['p' . $i . '_h' . $j];
             }
             $playerScores[] = array('player' => Player::find($params['player_' . $i]), 'holes' => $holeScores);
         }
         View::make('round/edit.html', array('numberOfPlayers' => $numberOfPlayers, 'players' => $players, 'course' => $course, 'holes' => $holes, 'courses' => $courses, 'playerScores' => $playerScores, 'round' => $round, 'scores' => $scores, 'played' => $played));
     } else {
         $attributes = array('courseId' => $params['course'], 'played' => $params['played']);
         $playerScores = array();
         $numberOfHoles = Hole::count_holes($params['course_orig']);
         $round = new Round(array_merge(array("id" => $round->id), $attributes));
         $errors = $round->errors();
         if (count($errors) == 0) {
             $round->update();
             for ($i = 1; $i <= $numberOfPlayers; $i++) {
                 $holeScores = array();
                 $scoreId = $params['score_' . $i];
                 for ($j = 1; $j <= $numberOfHoles; $j++) {
                     $hole = Hole::find_by_course_and_holenumber($params['course_orig'], $j);
                     $holeScores[] = array('throws' => $params['p' . $i . '_h' . $j], 'holeId' => $hole->id, 'holenumber' => $j);
                 }
                 $score = new Score(array('id' => $scoreId, 'playerId' => $params['player_' . $i], 'roundId' => $round->id, 'scores' => $holeScores));
                 $score->update();
             }
             Redirect::to('/round/' . $round->id, array('message' => 'Kierrosta muokattu.'));
         } else {
             View::make('round/new.html', array('errors' => $errors, 'attributes' => $attributes));
         }
     }
 }
 function testFind()
 {
     $course_name = "Vampires";
     $course_number = 1;
     $id = 1;
     $test_course = new Course($course_name, $course_number, $id);
     $test_course->save();
     $course_name2 = "Discrete Math";
     $course_number2 = 1;
     $id2 = 2;
     $test_course2 = new Course($course_name2, $course_number2, $id2);
     $test_course2->save();
     $find_id = $test_course->getId();
     $result = Course::find($find_id);
     $this->assertEquals($test_course, $result);
 }
 public static function update($gameid)
 {
     $rain = isset($_POST['rain']) && $_POST['rain'] ? "1" : "0";
     // checked=1, unchecked=0
     $wet_no_rain = isset($_POST['wet_no_rain']) && $_POST['wet_no_rain'] ? "1" : "0";
     // checked=1, unchecked=0
     $windy = isset($_POST['windy']) && $_POST['windy'] ? "1" : "0";
     // checked=1, unchecked=0
     $variant = isset($_POST['variant']) && $_POST['variant'] ? "1" : "0";
     // checked=1, unchecked=0
     $dark = isset($_POST['dark']) && $_POST['dark'] ? "1" : "0";
     // checked=1, unchecked=0
     $led = isset($_POST['led']) && $_POST['led'] ? "1" : "0";
     // checked=1, unchecked=0
     $snow = isset($_POST['snow']) && $_POST['snow'] ? "1" : "0";
     // checked=1, unchecked=0
     $date = $_POST['date'];
     $time = $_POST['time'];
     $comment = $_POST['comment'];
     $courseid = $_POST['courseid'];
     $gamedate = $date . " " . $time . ":00";
     $game = new Game(array('gameid' => $gameid, 'courseid' => $courseid, 'gamedate' => $gamedate, 'comment' => $comment, 'rain' => $rain, 'wet_no_rain' => $wet_no_rain, 'windy' => $windy, 'variant' => $variant, 'dark' => $dark, 'led' => $led, 'snow' => $snow));
     $errors = $game->errors();
     $course = Course::find($courseid);
     // When implementing multiple players per game, cycle through playerid's here
     $playerid = $_POST['playerid'];
     $player_scores = Score::all_game_scores($gameid);
     foreach ($player_scores as $playername => $scores) {
         foreach ($scores as $score) {
             $stroke = $_POST['hole' . $score->hole->hole_num];
             // 'holeN' will be something like 'playername-holeN'
             $ob = $_POST['obhole' . $score->hole->hole_num];
             $score->stroke = $stroke;
             $score->ob = $ob;
             $errors = array_merge($errors, $score->errors());
         }
     }
     if (count($errors) == 0) {
         // Game and scores were all valid
         $gameid = $game->update();
         foreach ($player_scores as $playername => $scores) {
             foreach ($scores as $score) {
                 $score->update();
             }
         }
         Redirect::to('/game/' . $game->gameid, array('message' => 'Peli ja sen tulokset päivitetty.'));
     } else {
         View::make('game/edit.html', array('errors' => $errors, 'game' => $game, 'date' => $date, 'time' => $time));
     }
 }
Пример #28
0
});
$app->get("/students/{id}", function ($id) use($app) {
    $student = Student::find($id);
    return $app['twig']->render('student.html.twig', array('student' => $student, 'courses' => $student->getCourses(), 'all_courses' => Course::getAll()));
});
$app->get("/students/{id}/edit", function ($id) use($app) {
    $student = Student::find($id);
    return $app['twig']->render('student_edit.html.twig', array('student' => $student));
});
$app->patch("/students/{id}", function ($id) use($app) {
    $name = $_POST['name'];
    $student = Student::find($id);
    $student->update($name);
    return $app['twig']->render('student.html.twig', array('student' => $student, 'courses' => $student->getCourses(), 'all_courses' => Course::getAll()));
});
$app->post("/add_students", function () use($app) {
    $course = Course::find($_POST['course_id']);
    $student = Student::find($_POST['student_id']);
    $course->addStudent($student);
    return $app['twig']->render('course.html.twig', array('course' => $course, 'courses' => Course::getAll(), 'students' => $course->getStudents(), 'all_students' => Student::getAll()));
});
$app->post("/delete_students", function () use($app) {
    Student::deleteAll();
    return $app['twig']->render('index.html.twig');
});
$app->delete("/students/{id}", function ($id) use($app) {
    $student = Student::find($id);
    $student->delete();
    return $app['twig']->render('students.html.twig', array('students' => Student::getAll()));
});
return $app;
Пример #29
0
         if ($validator->fails()) {
             return Redirect::to('/course')->withInput()->withErrors($validator)->with('message', '輸入錯誤,請檢查');
         } else {
             $data = Input::all();
             $course = Course::find($id);
             if ($course->update($data)) {
                 $message = '更新課程《' . $data['course_name'] . '》完成';
             } else {
                 $message = '資料寫入錯誤';
             }
             return Redirect::to('/course')->with('message', $message);
         }
     });
     // 執行刪除課程
     Route::get('/delete/{id}', function ($id) {
         $course = Course::find($id);
         $message = '刪除《' . $course->course_name . '》完成';
         $course->delete();
         return Redirect::to('/course')->with('message', $message);
     });
 });
 /**
  * 教室管理
  */
 Route::group(array('prefix' => 'classroom', 'before' => 'auth'), function () {
     // 顯示教室名稱
     Route::get('/', function () {
         $classroomList = Classroom::orderBy('classroom_name')->get();
         return View::make('classroom')->with(array('classroomList' => $classroomList, 'classroom' => null));
     });
     // 執行新增教室
Пример #30
0
">
    </div>
    <? if ($thread['context_type'] === "course") : ?>
        <a href="<?php 
echo URLHelper::getLink("plugins.php/blubber/streams/forum", array('cid' => $thread['Seminar_id']));
?>
"
            <? $title = get_object_name($thread['Seminar_id'], "sem") ?>
           title="<?php 
echo _("Veranstaltung") . " " . htmlReady($title['name']);
?>
"
           class="contextinfo"
           >
            <div class="name"><?php 
echo htmlReady(Course::find($thread['Seminar_id'])->name);
?>
</div>
        </a>
    <? elseif($thread['context_type'] === "private") : ?>
        <?
        if (count($related_users) > 20) {
            $title = _("Privat: ").sprintf(_("%s Personen"), count($related_users));
        } else {
            $title = _("Privat: ");
            foreach ($related_users as $key => $user_id) {
                if ($key > 0) {
                    $title .= ", ";
                }
                $title .= get_fullname($user_id);
            }