public function addGroup() { $sectionCode = SectionCode::find(new MongoId(Input::get('section'))); if (isset($sectionCode->_id)) { $section = Subject::find($sectionCode->subject_id)->sections()->find($sectionCode->section_id); if (strcasecmp($section->current_code, $sectionCode->code) === 0) { $group = new Group(); $group->name = trim(ucfirst(Input::get('name'))); $group->teamleader_id = Auth::id(); $group->section_code_id = new MongoId($sectionCode->_id); $group->students_id = array(Auth::id()); $group->project_name = trim(strtolower(Input::get('project_name'))); $message = ""; if (Input::hasFile('avatar_file')) { $data = Input::get('avatar_data'); $image = new CropImage(null, $data, $_FILES['avatar_file']); $group->logo = $image->getURL(); } else { $group->logo = null; } try { $group->save(); } catch (MongoDuplicateKeyException $e) { return Redirect::back()->withErrors(array('error' => Lang::get('register_group.duplicated'))); } return Redirect::to(Lang::get('routes.add_group'))->with('message', Lang::get('register_group.success')); } else { $message = Lang::get('register_group.code_expired'); } } else { $message = Lang::get('register_group.code_fail'); } return Redirect::back()->withErrors(array('error' => $message)); }
public function update($id) { $subject = Subject::find($id); $subject->name = Input::get('name'); $subject->save(); Session::flash('message', 'Sukses menambahkan bidang studi baru!'); }
public function addSectionCode() { $section_code = new SectionCode(); $teacher = Teacher::find(Auth::Id()); $subject_id = Input::get('subject'); $section_id = Input::get('section'); $current_period = Input::get('current_period'); $section_code->teacher_id = new MongoId($teacher->_id); $section_code->subject_id = new MongoId($subject_id); $section_code->section_id = new MongoId($section_id); $section_code->current_period = $current_period; $section_code->teamleaders_id = array(); $section_code->students_id = array(); $section_code->status = true; $subject = Subject::find($subject_id); $section = $subject->sections()->find($section_id); $code = $this->getInitialLetters($subject->name) . '-' . $section->code . '-' . $current_period; $section_code->code = $code; if (!is_null($section->current_code)) { $sectionCode = SectionCode::where('code', $section->current_code)->first(); if (isset($sectionCode->_id)) { $sectionCode->status = false; $sectionCode->save(); } } try { $section_code->save(); $section->current_code = $code; $section->save(); } catch (MongoDuplicateKeyException $e) { return Redirect::back()->withErrors(array('error' => Lang::get('section_codes.duplicate_code'))); } return Redirect::to(Lang::get('routes.section_codes'))->with(array('message' => Lang::get('section_codes.success_message'))); }
public function enrollSection() { $sectionCode = SectionCode::where('code', Input::get('code'))->first(); if (isset($sectionCode->_id)) { $section = Subject::find($sectionCode->subject_id)->sections()->find($sectionCode->section_id); $message = ""; if (strcasecmp($section->current_code, $sectionCode->code) === 0) { $codes = SectionCode::where('code', Input::get('code'))->whereIn('students_id', array(Auth::id()))->first(); if (!isset($codes->_id)) { $pending = new PendingEnrollment(); $pending->section_code_id = new MongoId($sectionCode->_id); $pending->student_id = Auth::id(); $pending->teacher_id = new MongoId($sectionCode->teacher_id); try { $pending->save(); } catch (MongoDuplicateKeyException $e) { return Redirect::back()->withErrors(array('error' => Lang::get('register_group.enroll_pending'))); } return Redirect::to(Lang::get('routes.enroll_section'))->with('message', Lang::get('register_group.enroll_sucess')); } else { $message = Lang::get('register_group.user_register'); } } else { $message = Lang::get('register_group.code_expired'); } } else { $message = Lang::get('register_group.code_fail'); } return Redirect::back()->withErrors(array('error' => $message)); }
public static function format($data) { $uids = $sids = []; $users = $subjects = []; foreach ($data as $d) { $uids[] = $d->userid; $sids[] = $d->subject_id; } $uids = array_unique($uids); $ret = \User::find([['userid' => ['$in' => $uids]]]); foreach ($ret as $u) { $users[$u->userid] = $u->attrs(); } $sids = array_unique($sids); $ret = \Subject::find([['id' => ['$in' => $sids]]]); foreach ($ret as $s) { $subjects[$s->id] = $s->attrs(); } $ret = []; foreach ($data as $d) { $ret[] = ['id' => $d->id, 'saying' => $d->saying, 'imgs' => $d->imgs, 'author' => $users[$d->userid], 'subject' => $subjects[$d->subject_id], 'created_at' => $d->created_at]; } return $ret; print_r($users); print_r($subjects); print_r($uids); print_r($sids); return []; }
public function getTopicList() { $currentchapterid = Session::get('chapterid'); $currentchapter = Chapter::find($currentchapterid); $subjectid = $currentchapter->getSubjectID(); $subject = Subject::find($subjectid); return Response::json($subject->getTopics()); }
public function showJoinToGroupView() { $sectionCodes = SectionCode::where('status', true)->whereIn('students_id', array(Auth::id()))->get(); $sections = array(); $pending = PendingGroup::where('student_id', Auth::id())->get(); foreach ($sectionCodes as $sectionCode) { $subject = Subject::find($sectionCode->subject_id); if (isset($subject->_id)) { $section = $subject->sections()->find($sectionCode->section_id); $sections[$sectionCode->code] = $subject->name . ' - ' . $section->code; } } return View::make('student.join_to_group')->with(array('sections' => $sections, 'pending' => $pending)); }
/** * Unlink a section with a teacher * * @return JSON Ajax */ public function unlink() { if (Request::ajax()) { $subject = Subject::find(Input::get('subject_id')); $teacher = Teacher::find(Input::get('teacher_id')); $teacher->pull('sections_id', new MongoId(Input::get('section_id'))); $section = $subject->sections()->find(Input::get('section_id')); $section->is_free = true; $section->save(); if ($subject->sections()->whereIn('_id', $teacher->sections_id)->count() === 0) { $teacher->pull('subjects_id', new MongoId(Input::get('subject_id'))); } return Response::json("00"); } }
public function getsubjectsAction() { try { $subjects = Subject::find(array("conditions" => "status = ?0", "bind" => array(1))); $array = array(); foreach ($subjects as $subject) { $obj = new stdClass(); $obj->id = $subject->idSubject; $obj->text = $subject->name; $array[] = $obj; } return $this->setJsonResponse($array, 200); } catch (InvalidArgumentException $ex) { return $this->setJsonResponse($ex->getMessage(), 400); } catch (Exception $ex) { $this->logger->log("Exception while getting subjects: " . $ex->getMessage()); $this->logger->log($ex->getTraceAsString()); return $this->setJsonResponse("Ha ocurrido un error, por favor contacta al administrador", 500); } }
@if(count($groups) > 0) @foreach ($groups as $index => $group) <div class="col-lg-6 col-md-6"> <div class="panel" style="background-color: {{ $colors[$index] }}; color: white;"> <div class="panel-heading"> <div class="row"> <div class="col-xs-3"> <i class="fa fa-group fa-5x"></i> <input type="hidden" value="{{storage_path()}}" id="url"> </div> <div class="col-xs-9 text-right"> <div class="huge"> <a href="#" id="{{$group->_id}}" class="group_name" style="text-transform: none; color: white;">{{$group->name}}</a></div> <?php $sectionCode = SectionCode::find($group->section_code_id); $subject = Subject::find($sectionCode->subject_id); $section = $subject->sections()->find($sectionCode->section_id); $name = $subject->name . ' - ' . $section->code; ?> <div> <span style="text-transform: uppercase;">{{$name}}</span> </div> </div> </div> </div> <div class="panel-footer" style="color: #000000;"> <?php $students = Student::whereIn('_id', $group->students_id)->get(); ?> @foreach ($students as $user) @if(strcmp($group->teamleader_id, $user->_id) === 0)
/** * Remove the subjects of an University * * @return JSON Ajax */ public function drop() { if (Request::ajax()) { $subject = Subject::find(Input::get('subject_id')); foreach (Teacher::where('university_id', Auth::id())->get() as $teacher) { if ($teacher->whereIn('subjects_id', array(new MongoId($subject->_id)))->count() > 0) { return Response::json(Lang::get('add_subject.subject_used')); } } $subject->delete(); return Response::json($subject->trashed() ? "00" : "99"); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function delete($id) { $subject = Subject::find($id); $subject->delete(); return Redirect::to('/subject/list')->with("success", "Subject Deleted Succesfully."); }
public function showGenerateReportView() { $subject = Subject::find(Input::get('subject')); if (isset($subject->_id)) { $tags = Input::get('tags'); $array = array(); if (in_array('all', $tags)) { $tags = null; } if (strcasecmp(Input::get('group'), 'all') === 0) { $sectionCode = SectionCode::where('code', Input::get('section'))->first(); $groups = Group::where('section_code_id', new MongoId($sectionCode->_id))->get(); if (is_null($tags)) { $array['groups'] = $this->getStatGroups($groups, $subject->name, Input::get('section'), Input::get('attach')); } else { $array['groups'] = $this->getStatGroupByTags($groups, $tags, $subject->name, Input::get('section'), Input::get('attach')); } } else { $group = Group::find(Input::get('group')); $students = Input::get('students'); if (in_array('all', $students)) { $students = $group->students_id; } if (is_null($tags)) { $array['students'] = $this->getStatStudents($students, $group->_id, $subject->name, Input::get('section'), Input::get('attach')); } else { $array['students'] = $this->getStatStudentsByTags($students, $group->_id, $tags, $subject->name, Input::get('section'), Input::get('attach')); } } return View::make('teacher.view_report')->with(array('report' => $array)); } else { return Redirect::back(); } }
<th>Subject</th> <th>Grade</th> <th>Created Date</th> <th>Modified Date</th> <th>Created By</th> <th>Status</th> <th>Actions</th> </tr> </thead> <tbody> <?php $tutorial_list = Cache::remember('tutorial_listing_dash' . Sentry::getUser()->id, 20, function () { $tutorials = Tutorials::all(); $out = ''; foreach ($tutorials as $tutorial) { $subject = Subject::find($tutorial->subjectid); $teacher = User::find($tutorial->createdby); $username = Sentry::findUserByLogin($teacher->email); if (Sentry::getUser()->inGroup(Sentry::findGroupByName('admin')) || Sentry::getUser()->id == $tutorial->createdby) { $out .= "<tr>"; $out .= "<td>"; $out .= $tutorial->id; $out .= "</td>"; $out .= "<td>"; $out .= $tutorial->name; $out .= "</td>"; $out .= "<td>"; $out .= $subject->subjectname; $out .= "</td>"; $out .= "<td>"; $out .= $subject->grade;
public function update() { $id = Input::get('id'); $tabla = Input::get('tabla'); switch ($tabla) { case '0': $clave = Input::get('clave'); $appat = Input::get('ap_pat'); $apmat = Input::get('ap_mat'); $nombre = Input::get('nombre'); $segnombre = Input::get('seg_nombre'); $tipo = Input::get('tipo'); $grado = Input::get('grado'); $tutorias = Input::get('tutorias'); $gestion = Input::get('gestion'); $investigacion = Input::get('investigacion'); $dependencias = Input::get('dependencias'); $edit = Professor::find($id); $edit->clave = $clave; $edit->ap_pat = $appat; $edit->ap_mat = $apmat; $edit->nombre = $nombre; $edit->seg_nombre = $segnombre; $edit->tipo = $tipo; $edit->id_grado = $grado; $edit->tutorias = $tutorias; $edit->gestion = $gestion; $edit->investigacion = $investigacion; $edit->dependencias = $dependencias; $edit->save(); return View::make('crud.crudMaestros')->with('professors', Professor::all()); break; case '1': $nombre = Input::get('nombre'); $semestre = Input::get('semestre'); $plan = Input::get('idPlan'); $edit = Subject::find($id); $edit->nombre = $nombre; $edit->semestre = $semestre; $edit->id_plan = $plan; $edit->save(); return View::make('crud.crudMaterias')->with('subjects', Subject::all()); break; case '2': $nombre = Input::get('nombre'); $edit = Aula::find($id); $edit->nombre = $nombre; $edit->save(); return View::make('crud.crudAulas')->with('aulas', Aula::all()); break; case '3': $nombre = Input::get('nombre'); $edit = Plan::find($id); $edit->nombre = $nombre; $edit->save(); return View::make('crud.crudPlanes')->with('plans', Plan::all()); break; default: //aqui me redirecciona a una pagina vacia solo con un mensaje 404 return View::make('landing'); break; } }
public function generatePaper($id) { $rules = array('subCode' => 'required', 'session' => 'required', 'date' => 'required'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to('generate/' . $id)->withErrors($validator)->withInput(Input::all()); } $questionUnits = Input::except('date', 'time', 'subCode', 'session', 'internal', 'sec'); $questions = array(); $nl2brQuestions = array(); $subject = Subject::find($id); $ques = array(); $retryCount = 0; retry: $retryCount++; if ($retryCount >= 20) { Session::flash('flash_error', 'Error Occured ! Not Enough Questions To Match !'); return Redirect::to('main/' . $subject->sem); } //Part A $noQuestionCount = 0; $repeatQuestionCount = 0; for ($i = 1; $i <= 2; $i++) { noQuestionA: $noQuestionCount++; if ($noQuestionCount >= 10) { goto retry; } $ques[$i] = array(); $partA = 20; $j = 1; do { questionRepeatedA: $repeatQuestionCount++; if (($testQuestion = $subject->questions()->where('unit', '=', $questionUnits['choice' . $i])->where('marks', '<=', $partA)->orderBy(DB::raw('RAND()'))->take(1)->first()) != NULL) { foreach ($ques as $questions) { foreach ($questions as $question) { if ($testQuestion->id == $question->id) { if ($repeatQuestionCount >= 10) { $repeatQuestionCount = 0; goto noQuestionA; } goto questionRepeatedA; } } } $ques[$i][$j] = $testQuestion; $partA = $partA - $ques[$i][$j]->marks; $j++; } else { if ($noQuestionCount >= 10) { goto retry; } goto noQuestionA; } } while ($partA != 0); $noQuestionCount = 0; } // Not-To-Club $noQuestionCount = 0; $repeatQuestionCount = 0; if (strcmp($questionUnits['choice3'], 'club')) { noQuestion3: $noQuestionCount++; if ($noQuestionCount >= 10) { goto retry; } $ques[$i] = array(); $partA = 20; $j = 1; do { questionRepeated3: $repeatQuestionCount++; if (($testQuestion = $subject->questions()->where('unit', '=', $questionUnits['choice3'])->where('marks', '<=', $partA)->orderBy(DB::raw('RAND()'))->take(1)->first()) != NULL) { foreach ($ques as $questions) { foreach ($questions as $question) { if ($testQuestion->id == $question->id) { if ($repeatQuestionCount >= 10) { $repeatQuestionCount = 0; goto noQuestion3; } goto questionRepeated3; } } } $ques[$i][$j] = $testQuestion; $partA = $partA - $ques[$i][$j]->marks; $j++; } else { if ($noQuestionCount >= 10) { goto retry; } goto noQuestion3; } } while ($partA != 0); $noQuestionCount = 0; } else { noQuestionClub: $noQuestionCount++; if ($noQuestionCount >= 10) { goto retry; } $ques[$i] = array(); $partA = 20; $j = 1; do { questionRepeatedClub: $repeatQuestionCount++; if (($testQuestion = $subject->questions()->where('unit', '=', rand($questionUnits['choice1'], $questionUnits['choice2']))->where('marks', '<=', $partA)->orderBy(DB::raw('RAND()'))->take(1)->first()) != NULL) { foreach ($ques as $questions) { foreach ($questions as $question) { if ($testQuestion->id == $question->id) { if ($repeatQuestionCount >= 10) { $repeatQuestionCount = 0; goto noQuestionClub; } goto questionRepeatedClub; } } } $ques[$i][$j] = $testQuestion; $partA = $partA - $ques[$i][$j]->marks; $j++; } else { if ($noQuestionCount >= 10) { goto retry; } goto noQuestionClub; } } while ($partA != 0); $noQuestionCount = 0; } //Part B $noQuestionCount = 0; $repeatQuestionCount = 0; for ($i = 4; $i <= 5; $i++) { noQuestionB: $noQuestionCount++; if ($noQuestionCount >= 10) { goto retry; } $ques[$i] = array(); $partB = 10; $j = 1; do { questionRepeatedB: $repeatQuestionCount++; if (($testQuestion = $subject->questions()->where('unit', '=', $questionUnits['choice' . $i])->where('marks', '<=', $partB)->orderBy(DB::raw('RAND()'))->take(1)->first()) != NULL) { foreach ($ques as $questions) { foreach ($questions as $question) { if ($testQuestion->id == $question->id) { if ($repeatQuestionCount >= 10) { $repeatQuestionCount = 0; goto noQuestionB; } goto questionRepeatedB; } } } $ques[$i][$j] = $testQuestion; $partB = $partB - $ques[$i][$j]->marks; $j++; } else { if ($noQuestionCount >= 10) { goto retry; } goto noQuestionB; } } while ($partB != 0); $noQuestionCount = 0; } $i = 1; $j = 1; foreach ($ques as $questions) { foreach ($questions as $question) { $nl2brQuestions[$i][$j] = nl2br($question->question); $j++; } $i++; } return View::make('generate.checkQuestions')->with('questions', $ques)->with('nl2brQuestions', $nl2brQuestions)->with('club', $questionUnits['choice3'])->with('date', Input::get('date'))->with('time', Input::get('time'))->with('subCode', Input::get('subCode'))->with('session', Input::get('session'))->with('internal', Input::get('internal'))->with('sec', Input::get('sec')); }
public function index() { $theme = Theme::uses('site')->layout('default'); $theme->setTitle('Home'); Cache::forget('latest_tr_slides'); Cache::forget('tutorials'); Cache::forget('latest_tutorials'); Cache::forget('latest_tutes'); Cache::forget('topstudents'); Cache::forget('topstudentlist'); $tutorialslides = Cache::remember('latest_tr_slides', 1, function () { $tutorials = Cache::remember('tutorials', 1, function () { return DB::select(DB::raw('SELECT tutorialid FROM assessments GROUP BY tutorialid HAVING(COUNT(*)) ORDER BY COUNT(*) DESC LIMIT 5 ;')); }); $out = ''; if ($tutorials == null) { return $out; } foreach ($tutorials as $tutorial_t) { $out .= "<div>"; $tutorial = Tutorials::find($tutorial_t->tutorialid); $string = $tutorial->content; $string = strlen($string) > 753 ? substr($string, 0, 750) . '...' : $string; $string = wordwrap($string, 200, "<br>\n"); $out .= '<h2 class="title">' . $tutorial->name . '</h2>'; $out .= '<label class="label label-success">Subject </label>' . Subject::find($tutorial->subjectid)->subjectname . ' <label class="label label-success">Grade</label> :- ' . Subject::find($tutorial->subjectid)->grade; $out .= " <br> <br>" . $string; $out .= " <br><a class='btn btn-large' href='/tutorial/" . $tutorial->id . "/'>Read More ...</a> <br> <br> <br>"; $out .= '</div>'; } return $out; }); $latest_tutorials = Cache::remember('latest_tutorials', 20, function () { $tutorials = Cache::remember('latest_tutes', 20, function () { return DB::select(DB::raw('SELECT id from tutorials WHERE published= 1 ORDER BY `created_at` DESC LIMIT 5;')); }); $out = ''; if ($tutorials == null) { return $out; } foreach ($tutorials as $tutorial_t) { $tutorial = Tutorials::find($tutorial_t->id); $string = $tutorial->content; $string = preg_replace("/<img[^>]+\\>/i", "", $string); $images = self::getTutorialImages($tutorial->content); if ($images == null) { // continue; } $string = strlen($string) > 753 ? substr($string, 0, 750) . '...' : $string; $string = wordwrap($string, 200, "<br>\n"); $out .= "<div>"; $out .= '<h2 class="title">' . $tutorial->name . '</h2>'; $out .= '<p style="display:inline-block;"> <label class="label label-success">Subject </label>' . Subject::find($tutorial->subjectid)->subjectname . ' <label class="label label-success">Grade</label> :- ' . Subject::find($tutorial->subjectid)->grade . '</p>'; $out .= " <br> <br>" . $string; $out .= "<img src='" . $images[rand(0, count($images) - 1)] . "' class='' style='height:100%;'/>"; $out .= " <br><a class='btn btn-large' href='/tutorial/" . $tutorial->id . "/'>Read More ...</a> <br> <br> <br>"; $out .= '</div>'; } return $out; }); $topstudents = Cache::remember('topstudents', 20, function () { $out = ''; $topstudentlist = Cache::remember('topstudentlist', 20, function () { return DB::select(DB::raw('SELECT studentid as sid,AVG(marks) as average FROM assessments WHERE `created_at` >= CURDATE() - INTERVAL 7 DAY GROUP BY studentid ORDER BY average DESC LIMIT 0,5;')); }); if ($topstudentlist == null) { return $out; } foreach ($topstudentlist as $student) { $user = User::find($student->sid); $url = Gravatarer::make(['email' => $user->email, 'size' => 200, 'defaultImage' => 'mm', 'rating' => 'g'])->url(); $out .= "<div>"; $out .= "<img style='clear:left;' class='avatar' alt='" . $user->email . "' src='" . $url . "'/>\n\t\t<br><strong>Name:</strong>" . $user->first_name . ' ' . $user->last_name . ''; $out .= "<br><label class='label label-success'>Average Score</label> is " . (int) $student->average . ""; $out .= "</div>"; } return $out; }); $add = ['tutorialslides' => $tutorialslides, 'latesttutorialslides' => $latest_tutorials, 'topstudents' => $topstudents]; return $theme->scope('index', $add)->content(); }
</thead> <tbody> <?php $assessments = Assessments::all(); foreach ($assessments as $assessment) { $tutorialid = $assessment->tutorialid; $teacherid = $assessment->teacherid; $teacher = User::find($teacherid); $admin = Sentry::getUser()->inGroup(Sentry::findGroupByName('admin')); if (Sentry::getUser()->id == $teacherid || $admin) { $tutorial = DB::select(DB::raw('SELECT * FROM `tutorials` WHERE `id` = ' . $tutorialid)); $tutorial = array_dot(objectToArray($tutorial)); $tutorial = Tutorials::find((int) $assessment->tutorialid); $studentid = $assessment->studentid; $student = User::find($studentid); $subject = Subject::find($assessment->subjectid); echo "<tr>"; echo "<td>"; echo $assessment->id; echo "</td>"; echo "<td>"; echo "<a href='/assessment/" . $assessment->id . "/'>" . $assessment->title . '</a>'; echo "</td>"; echo "<td>"; echo "<a href='/tutorial/view/" . $tutorialid . "'>"; echo $tutorial->name; unset($tutorial); echo "</a>"; echo "</td>"; echo "<td>"; echo $subject->subjectname;
public function find() { if (Request::ajax()) { if (!is_null(Input::get('section')) && !is_null(Input::get('subject'))) { $section = Subject::find(Input::get('subject'))->sections()->find(Input::get('section')); if (isset($section->current_code)) { $sectionCode = SectionCode::where('code', $section->current_code)->first(); $students = Student::whereIn('_id', $sectionCode->students_id)->whereNotIn('_id', $sectionCode->teamleaders_id)->orderBy('id_number', 'asc')->get(); $code = count($students) > 0 ? '00' : '99'; return Response::json(array('students' => $students, 'code' => $code)); } else { return Response::json(""); } } else { if (!is_null(Input::get('group_id'))) { $group = Group::find(Input::get('group_id')); $students = Student::whereIn('_id', $group->students_id)->get(); return Response::json($students); } else { if (!is_null(Input::get('id'))) { return Response::json(Student::find(Input::get('id'))); } } } } }
<th>#ID</th> <th>Title</th> <th>Subject</th> <th>Submitted To</th> <th>Related Tutorial</th> <th>Submitted On</th> <th>Last Updated</th> <th>Marks</th> </tr> </thead> <tbody> <?php $assessments = Assessments::where('studentid', '=', Sentry::getUser()->id)->get(); foreach ($assessments as $assessment) { $subjectid = $assessment->subjectid; $subject = Subject::find($subjectid); $teacherid = $assessment->teacherid; $teacher = User::find($teacherid); $tutorialid = $assessment->tutorialid; $tutorial = Tutorials::find($tutorialid); echo "<tr>"; echo "<td>"; echo $assessment->id; echo "</td>"; echo "<td>"; echo "<a href='/assessment/update/" . $assessment->id . "'>{$assessment->title}"; echo "</td>"; echo "<td>"; echo $subject->subjectname; echo "</td>"; echo "<td>";
private function delete($id) { $subject = Subject::find($id); $subject->delete(); }
<?php if ($errors->first()) { echo "<div class='alert alert-error alert-block fade in'>"; echo '<button type="button" class="close" data-dismiss="alert">×</button>'; echo $errors->first(); echo "</div>"; } echo Form::open(array('url' => '/exam/edit/' . $id, 'method' => 'post', 'class' => 'form-horizontal')); echo "<fieldset>"; echo Form::label('id', 'id', array('class' => 'pull-left', 'style' => 'clear:left;padding:15px;')); echo Form::text('id', $id, array('disabled' => '', 'class' => 'disabled pull-right', 'style' => 'margin:10px;')); echo Form::label('title', 'Title', array('class' => 'pull-left', 'style' => 'clear:left;margin:15px;')); echo Form::text("title", $exam->title, array('placeholder' => 'Title of the Tutorial', 'class' => 'pull-right', 'style' => 'clear:right;margin:10px;')); echo Form::label('subject', 'Subject', array('class' => 'pull-left', 'style' => 'clear:left;margin:15px;')); $subject = Subject::find(Exams::find($id)->subjectid); $subjectlist[$subject->id] = $subject->subjectname; echo Form::select('subject', $subjectlist, $subject->id, array('class' => 'pull-right', 'style' => 'clear:right;margin:10px;')); echo '<div class="control-group" style="clear:left;">'; echo "<div id='exams'>"; $hash = $exam->hash; $examdata_encoded = File::get(app_path() . '/files/exam-' . $id . '/' . $hash . '.json'); Session::put('questiondata_key', 1); $examdata = json_decode($examdata_encoded); $examdata = objectToArray($examdata); foreach ($examdata['questiondata']['questions'] as $question) { $qc = Session::get('questiondata_key', 1); $checked1 = ''; $checked2 = ''; $checked3 = ''; $checked4 = '';
<?php $exams = Exams::all(); foreach ($exams as $exam) { if ($exam->createdby == Sentry::getUser()->id || Sentry::getUser()->inGroup(Sentry::findGroupByName('admin'))) { echo "<tr>"; echo "<td>"; echo $exam->id; echo "</td>"; echo "<td>"; echo $exam->title; echo "</td>"; echo "<td>"; echo Subject::find($exam->subjectid)->subjectname; echo "</td>"; echo "<td>"; echo Subject::find($exam->subjectid)->grade; echo "</td>"; echo '<td class="center"> <a class="btn btn-success" href="/exam/view/' . $exam->id . '/"> <i class="icon-zoom-in icon-white"></i> View </a> <a class="btn btn-info" href="/exam/edit/' . $exam->id . '"> <i class="icon-edit icon-white"></i> Edit </a>'; $cuser = Sentry::getUser(); $admingroup = Sentry::findGroupByName('admin'); if ($cuser->inGroup($admingroup)) { echo '<a class="btn btn-danger" href="/exam/delete/' . $exam->id . '/"> <i class="icon-trash icon-white"></i>