Пример #1
0
 public function connectionDestroy(Request $request, $lecture_id)
 {
     $goal = Goal::find($request->goal_id);
     $subject = Subject::find($request->subject_id);
     $goal->subjects()->detach($subject);
     return $request->goal_id . " -- " . $request->subject_id;
 }
Пример #2
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create($subject_id, $class_id)
 {
     $exams = \App\Exam::all();
     $subject = \App\Subject::find($subject_id);
     $class = \App\Grade::find($class_id);
     return view('reports.create')->with('title', 'SMS|REPORT')->with('class', $class)->with('subject', $subject)->with('exams', $exams);
 }
Пример #3
0
 public function store(Request $request, $lecture_id, $subject_id)
 {
     $subject = Subject::find($subject_id);
     $assignment = new Assignment();
     $assignment->due_date = $request->due_date . ' 23:59';
     $assignment->subject()->associate($subject);
     $assignment->save();
     $assignment->knowledgeunits()->attach(Input::get('knowledgeunits'));
     return redirect('/lectures/' . $lecture_id . '/assignments/subjects/' . $subject_id);
 }
Пример #4
0
 public function updateSubject(UpdateSubjectRequest $req)
 {
     $subject = Subject::find($req->id);
     $subject->catalog_no = $req->catalog_no;
     $subject->descriptive_title = $req->descriptive_title;
     $subject->lec_units = $req->lec_units;
     $subject->lab_units = $req->lab_units;
     $subject->total_units = $req->total_units;
     $subject->status = $req->status;
     $subject->save();
 }
Пример #5
0
 public function edit(Request $request, $lecture_id, $subject_id, $topic_id)
 {
     $lecture = Lecture::find($lecture_id);
     $subject = Subject::find($subject_id);
     $topic = Topic::find($topic_id);
     $data["nav"] = "<a href=\"" . url('/lectures/') . "\">" . $lecture->title . "</a> <span class=\"fa fa-chevron-right\"></span> <a href=\"" . url('/lectures/' . $lecture->id . '/subjects/') . "\">" . $subject->title . "</a>";
     $data["lecture_id"] = $lecture_id;
     $data["subject_id"] = $subject_id;
     $data["topic"] = $topic;
     return view('topic.edit', $data);
 }
Пример #6
0
 public function edit(Request $request, $lecture_id, $subject_id, $topic_id, $knowledgeunit_id, $question_id)
 {
     $lecture = Lecture::find($lecture_id);
     $subject = Subject::find($subject_id);
     $topic = Topic::find($topic_id);
     $knowledgeunit = KnowledgeUnit::find($knowledgeunit_id);
     $question = Question::find($question_id);
     $data["nav"] = "<a href=\"" . url('/lectures/') . "\">" . $lecture->title . "</a> <span class=\"fa fa-chevron-right\"></span> <a href=\"" . url('/lectures/' . $lecture->id . '/subjects/') . "\">" . $subject->title . "</a> <span class=\"fa fa-chevron-right\"></span> <a href=\"" . url('/lectures/' . $lecture->id . '/subjects/' . $subject->id . '/topics/') . "\">" . $topic->title . "</a> <span class=\"fa fa-chevron-right\"></span> <a href=\"" . url('/lectures/' . $lecture->id . '/subjects/' . $subject->id . '/topics/' . $topic->id . '/knowledgeunits') . "\">" . $knowledgeunit->title . "</a> <span class=\"fa fa-chevron-right\"></span> <a href=\"" . url('/lectures/' . $lecture->id . '/subjects/' . $subject->id . '/topics/' . $topic->id . '/knowledgeunits/' . $knowledgeunit->id . '/questions') . "\">" . $question->title . "</a>";
     $data["lecture_id"] = $lecture_id;
     $data["subject_id"] = $subject_id;
     $data["topic_id"] = $topic_id;
     $data["knowledgeunit_id"] = $knowledgeunit_id;
     $data["question"] = $question;
     return view('question.edit', $data);
 }
Пример #7
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $subject = Subject::find($this->subjects);
     switch ($this->method()) {
         case 'GET':
         case 'DELETE':
             return [];
         case 'POST':
             return ['code' => 'required|unique:subjects|max:20', 'name' => 'required|max:254', 'units' => 'integer|max:100', 'lec_hours' => 'numeric|max:999', 'lab_hours' => 'numeric|max:999'];
         case 'PUT':
         case 'PATCH':
             return ['code' => "required|unique:subjects,code,{$subject->id}|max:20", 'name' => 'required|max:254', 'units' => 'integer|max:100', 'lec_hours' => 'numeric|max:999', 'lab_hours' => 'numeric|max:999'];
         default:
             break;
     }
 }
Пример #8
0
 public function delete($id)
 {
     // Checking if subject exists
     $subject = Subject::find($id);
     // If subject exists
     if (!empty($subject)) {
         // Finding related books
         $books = $this->booksService->getAllWithSubject($id);
         if (!empty($books['data'])) {
             // Delete related books
             foreach ($books['data'] as $book) {
                 $this->booksService->delete($book->id);
             }
         }
         // Delete subject
         $subject->delete();
         // Returning success message
         return $this->responseService->returnSuccess();
     } else {
         // Subject not found
         // Returning error message
         return $this->responseService->errorMessage('Subject was not Found.');
     }
 }
Пример #9
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  array $grade_id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $grade_id)
 {
     $subjects = Subject::find($request->subject);
     $subjects->grades()->sync($request->input('grade_id'));
     return redirect('principal/create#subject-tab')->withInput();
 }
Пример #10
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Subject::find($id)->delete();
     return redirect('admin/subject');
 }
Пример #11
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function assignSubject(Request $request, $id)
 {
     $staffData = User::findOrFail($request->name);
     foreach ($request->subjectCreate as $k => $v) {
         $subjects = Subject::find($v);
         $staffData->subjects()->attach($subjects);
     }
     return Redirect::route('staff.show', ['staff' => $staffData]);
 }
Пример #12
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle(Subject $model)
 {
     $model->find($this->id)->update($this->request->only(['name', 'code', 'abbreviation']));
     $model->category()->associate($request->get('category_id'));
     $model->save();
 }
Пример #13
0
 public function postSaveQuestionResult($id, Request $req)
 {
     //save result
     $subject = Subject::find($id);
     $question = Question::find($req->get('question_id'));
     if ($req->get('option') != null) {
         //save the answer into table
         $duration = $subject->duration * 60;
         $time_taken = $req->get('time_taken' . $question->id);
         $time_per_question = $duration - $time_taken;
         //dd($time_taken);
         Answer::create(['user_id' => Auth::user()->id, 'question_id' => $req->get('question_id'), 'subject_id' => $id, 'user_answer' => $req->get('option'), 'question' => $question->question, 'option1' => $question->option1, 'option2' => $question->option2, 'option3' => $question->option3, 'option4' => $question->option4, 'right_answer' => $question->answer, 'time_taken' => $time_per_question]);
     }
     $next_question_id = $subject->questions()->where('id', '>', $req->get('question_id'))->min('id');
     if ($next_question_id != null) {
         return Response::json(['next_question_id' => $next_question_id]);
     }
     return redirect()->route('result', [$id]);
 }
Пример #14
0
 public function destroy(Request $request, $lecture_id, $subject_id)
 {
     $subject = Subject::find($subject_id);
     $subject->delete();
     return redirect('/lectures/' . $lecture_id . '/subjects');
 }
Пример #15
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $subject = Subject::find($id);
     $subject->delete();
     return $this->index();
 }
Пример #16
0
 public function delete($id)
 {
     $subject = Subject::find($id);
     return view('admin.subject.delete', compact('subject'));
 }
Пример #17
0
 public function subjectUpdate($id)
 {
     $subject = Subject::find($id);
     return view('admin.update-subject', compact('subject'));
 }
Пример #18
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $data = Subject::find($id);
     return view('admin.subject.edit', ['data' => $data]);
 }