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 getUsersChat($code) { $user = UserController::getUser(Auth::user()); $sectionCodes = null; if ($user instanceof Teacher) { $sectionCodes = SectionCode::where('teacher_id', new MongoId($user->_id))->where('status', true)->where('code', $code)->first(); } else { if ($user instanceof Student) { $sectionCodes = SectionCode::whereIn('students_id', array(new MongoId($user->_id)))->where('status', true)->where('code', $code)->first(); } } return $sectionCodes; }
public function joinToGroup() { $group = Group::find(new MongoId(Input::get('group'))); $pending = new PendingGroup(); $sectionCode = SectionCode::where('code', Input::get('section'))->first(); $pending->section_code_id = new MongoId($sectionCode->_id); $pending->group_id = new MongoId($group->_id); $pending->student_id = Auth::id(); $pending->teamleader_id = new MongoId($group->teamleader_id); try { $pending->save(); } catch (MongoDuplicateKeyException $e) { return Redirect::back()->withErrors(array('error' => Lang::get('register_group.join_pending'))); } return Redirect::to(Lang::get('routes.join_to_group'))->with('message', Lang::get('register_group.join_sucess')); }
public static function getLatestAssignments() { $sectionCodes = SectionCode::where('teacher_id', new MongoId(Auth::id()))->where('status', true)->get(); $arraySectionCodes = array(); $arrayGroups = array(); foreach ($sectionCodes as $sectionCode) { array_push($arraySectionCodes, new MongoId($sectionCode->_id)); } $groups = Group::whereIn('section_code_id', $arraySectionCodes)->get(); foreach ($groups as $group) { array_push($arrayGroups, new MongoId($group->_id)); } $assignments = Assignment::whereIn('group_id', $arrayGroups)->get(); $arrayAssignments = array(); foreach ($assignments as $assignment) { if ($assignment->date_assigned->sec >= Auth::user()->last_activity->sec) { array_push($arrayAssignments, $assignment); } } return $arrayAssignments; }
@include('alert') @foreach ($subjects as $item => $subject) <h3>{{Lang::get('list_section.subject').ucfirst($subject->name)}}</h3> <table id="tableOrder" class="table table-striped table-bordered table-hover tablesorter"> <thead> <tr> <th>#</th> <th>{{Lang::get('list_section.section')}}</th> <th>{{Lang::get('teamleader.section_code')}}</th> <th>{{Lang::get('teamleader.tm')}}</th> <th>{{Lang::get('list_subject.delete')}}</th> </tr> </thead> <tbody> <?php $sectionCodes = SectionCode::where('subject_id', new MongoId($subject->_id))->get(); ?> @foreach ($sectionCodes as $sectionCode) <?php $students = Student::whereIn('_id', $sectionCode->teamleaders_id)->get(); ?> @foreach ($students as $index => $student) <?php $section = $subject->sections()->find($sectionCode->section_id); ?> <tr id="{{$item.'_'.$index}}"> <td>{{$index + 1}}</td> <td>{{$section->code}}</td> <td>{{$sectionCode->code}}</td> <td>{{'('.$student->id_number.') - '.$student->name.' '.$student->last_name}}</td> <td style="width: 6%">
public function findGroupBySection() { $section_code = SectionCode::where('code', Input::get('section_code'))->first(); $groups = Group::where('section_code_id', new MongoId($section_code->_id))->get(); return View::make('teacher.subject_details')->with(array('groups' => $groups, 'colors' => $this->colors)); }
public static function confirmTeamLeader($teamleader_id, $sectionCode_id) { $sectionCode = SectionCode::where('_id', new MongoId($sectionCode_id))->whereIn('teamleaders_id', array(new MongoId($teamleader_id)))->first(); return isset($sectionCode->_id) ? true : false; //return $sectionCode; }
<thead> <tr> <th>{{Lang::get('section_codes.subject')}}</th> <th>{{Lang::get('section_codes.section')}}</th> <th>{{Lang::get('section_codes.period')}}</th> <th>{{Lang::get('section_codes.code')}}</th> </tr> </thead> <tbody> @foreach ($subjects as $subject) <?php $sections = $subject->sections()->whereIn('_id', $teacher_section_id)->whereNull('delete_at')->get(); ?> @foreach($sections as $section) <?php $section_code = SectionCode::where('code', $section->current_code)->first(); ?> <tr> <td>{{ $subject->name }}</td> <td>{{ $section->code }}</td> <td>{{ $section_code->current_period }}</td> <td>{{ $section->current_code }}</td> </tr> @endforeach @endforeach </tbody> </table> </div> </div> </div> </div>
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(); } }
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'))); } } } } }