public function countChapterComment(Chapter $chapter = null)
 {
     if ($chapter) {
         return $chapter->comments()->count();
     }
     $total = 0;
     foreach ($this->model->chapters as $chapter) {
         $total += $chapter->comments()->count();
     }
     return $total;
 }
 public function memberHasFinishedChapter(Chapter $chapter, $attempt = 1)
 {
     return $chapter->memberHasFinished($this->user, $attempt);
 }
 public function learnerQuizMember($chapter_id, $user = null)
 {
     if ($user) {
         $this->setUser($user);
     }
     $chapter = Chapter::find($chapter_id);
     $quiz = $chapter->quiz;
     $member = null;
     foreach ($quiz->members as $data) {
         if ($data->user_id == $this->user->id) {
             $member = $data;
             break;
         }
     }
     return $member;
 }
 public function memberHasFinishedChapter(Chapter $chapter)
 {
     return $chapter->memberHasFinished($this->user);
 }