예제 #1
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);
 }
예제 #2
0
 function getEnableAttribute()
 {
     $enable = 0;
     $previousTopicID = Topic::where('id', '<', $this->id)->max('id');
     if (is_null($previousTopicID)) {
         $enable = 1;
     } else {
         Log::info('111 $this->id: ' . $this->id . ' $previousTopicID: ' . $previousTopicID);
         $easyKUofPreviousTopic = KnowledgeUnit::where('topic_id', '=', $previousTopicID)->where('difficulty_level', '=', '1')->pluck('id');
         $is_done_query = DB::table('users_knowledgeunits')->where('user_id', '=', Auth::user()->id)->where('knowledgeunit_id', '=', $easyKUofPreviousTopic)->first();
         if (!is_null($is_done_query)) {
             $enable = 1;
         }
     }
     return $enable;
 }
 /**
  * Get all of the knowledge units for a given topic.
  *
  * @param  Topic  $topic
  * @return Collection
  */
 public function forTopic($topic_id)
 {
     return KnowledgeUnit::with("questions")->where('knowledge_units.topic_id', $topic_id)->orderBy('created_at', 'asc')->get();
 }
 public function destroy(Request $request, $lecture_id, $subject_id, $topic_id, $knowledgeunit_id)
 {
     $knowledgeunit = KnowledgeUnit::find($knowledgeunit_id);
     $knowledgeunit->delete();
     return redirect('/lectures/' . $lecture_id . '/subjects/' . $subject_id . '/topics/' . $topic_id . '/knowledgeunits');
 }