public function lesson(Lesson $Lesson, $id) { if (!($lesson = $Lesson->student()->with(['elements' => function ($query) { $query->where('state', 'نشط')->orderBy('element_order', 'asc'); }])->findOrFail($id))) { return redirect()->route('students.profile.subjects.index'); } $lessons_arr = Lesson::where('subject_subject_id', $lesson->subject_subject_id)->orderBy('lesson_order', 'ASC')->get()->toArray(); $this->makeSubjectLessonsMenu($lesson->subject_subject_id, $lessons_arr); return view('students::profile.subjects.lesson', compact('lesson')); }
public function deleteBulk($id, Request $req, Lesson $UserModel) { // if the table_records is empty we redirect to the users index if (!$req->has('table_records')) { return redirect()->route('lessons.index'); } // we get all the ids and put them in a variable $ids = $req->input('table_records'); // we delete all the lessons with the ids $ids $UserModel->destroy($ids); // we redirect to the user index view with a success message return redirect()->route('lessons.index', $id)->with('success'); }
/** * Register the service provider. * * @return void */ public function register() { Subject::saving(function ($subject) { $subject->pre_request = empty($subject->pre_request) ? null : $subject->pre_request; }); Element::created(function ($element) { UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'element', 'reference_id' => $element->id]); }); Element::updated(function ($element) { UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'element', 'reference_id' => $element->id]); }); Element::deleted(function ($element) { UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'element', 'reference_id' => $element->id]); }); Subject::created(function ($subject) { UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'subject', 'reference_id' => $subject->id]); }); Subject::updated(function ($subject) { UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'subject', 'reference_id' => $subject->id]); }); Subject::deleted(function ($subject) { UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'subject', 'reference_id' => $subject->id]); }); Lesson::created(function ($lesson) { UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'lesson', 'reference_id' => $lesson->id]); }); Lesson::updated(function ($lesson) { UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'lesson', 'reference_id' => $lesson->id]); }); Lesson::deleted(function ($lesson) { UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'lesson', 'reference_id' => $lesson->id]); }); }
public function index() { $user = Auth::guard('api_student')->user(); $lessons = Lesson::select('sl.id', 'sl.name', 'sl.subject_subject_id', 'sl.lesson_order', 'sl.type', 'sl.state')->join('subject_subjects as ss', 'ss.id', '=', 'sl.subject_subject_id')->join('student_subjects as stusub', function ($j) use($user) { $j->on('stusub.subject_id', '=', 'ss.id')->where('student_id', '=', $user->id)->where('semester_id', '=', semester()->id); })->from('subject_lessons as sl')->groupBy('sl.id')->get(); return response()->json($lessons, 200, [], JSON_NUMERIC_CHECK); }
public function createfromsub($subjectid) { $type = config('questionbank.types'); $difficulty = config('questionbank.difficulty'); $level = config('questionbank.level'); $lesson = Lesson::where('subject_subject_id', $subjectid)->lists('name', 'id')->toArray(); return view('questionbank::questionsub.create', compact('subjectid', 'lesson', 'type', 'difficulty', 'level')); }
public function lesson_report(Request $req, Lesson $UserModel, $subid) { $lessons = $UserModel::with('elements')->where('subject_subject_id', $subid)->paginate(20); $subjects = Subject::where('id', $subid)->first(); if ($req->has('title')) { $lessons = Lesson::where('subject_subject_id', $subid)->where('name', $req->input('title'))->paginate(20); } return view('subject::reports.lesson_report', compact('lessons', 'subid', 'subjects')); }
public function index($lessonid, Request $req) { $elements = Element::where('subject_lesson_id', $lessonid)->orderBy('element_order')->paginate(20); if ($req->has('title')) { $elements = Element::where('title', 'LIKE', "%" . $req->input('title') . "%")->where('subject_lesson_id', $lessonid)->paginate(20); } $lessons = Lesson::where('id', $lessonid)->get()->first(); return view('subject::elements.index_element', compact('elements', 'lessonid', 'lessons')); }
public function deletequestion($id, $activity_id) { $question = Question::findOrFail($id); $lesson = Lesson::findOrFail($question->lesson_id); $question = Question::with('exam')->findOrFail($id); /* if(!$question->exam->isEmpty()) { return redirect()->back()->with('error', 'لا يمكن حذف السؤال لانه مستخدم في اختبار'); }*/ $question->delete(); //$exam = Exam::findOrFail($activity_id); //$exam->questions()->detach([$question_id]); $message = "تم حذف السؤال بنجاح"; return redirect()->route('teachers.profile.questions', $activity_id)->with('success', $message); }
public function index($lessonid) { $elements = Element::where('subject_lesson_id', $lessonid)->paginate(20); $lesson_name = Lesson::findOrFail($lessonid)->toArray(); return view('subject::elements.index_element', compact('elements', 'lessonid', 'lesson_name')); }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); DB::statement('SET FOREIGN_KEY_CHECKS=0;'); // $this->call("OthersTableSeeder"); // if (Subject::count()) { // return; // } // Subject::where('id', 31)->delete(); // $lessons_ids = Lesson::where('subject_subject_id', 31) // ->pluck('id'); // Lesson::where('subject_subject_id', 31)->delete(); // Element::whereIn('subject_lesson_id', $lessons_ids) // ->delete(); Element::truncate(); Lesson::truncate(); $subjects = DB::connection('old')->table('subjects')->get(); $new_lessons = []; // $new_subjects = []; $intro_lesson_id = 689998765; $lessons = DB::connection('old')->table('lessons')->select('lessons.*')->where('les_sort', '>', 0)->join('subjects', 'les_subjectid', '=', 'sub_id')->get(); foreach ($subjects as $subject) { $new_subject['id'] = $subject->sub_id; $new_subject['name'] = $subject->sub_name; $new_subject['code'] = $subject->sub_code; $new_subject['hour'] = $subject->sub_hours; $new_subject['is_quran'] = str_contains($subject->sub_name, 'الكريم') ? 1 : 0; $new_subject['description'] = $subject->sub_details; $new_subject['created_at'] = new DateTime(); $new_subject['updated_at'] = new DateTime(); $new_subject['type'] = 'نظري'; $new_subjects[] = $new_subject; //for intro if (!empty($subject->sub_details)) { $new_lesson['id'] = $intro_lesson_id; $new_lesson['name'] = 'عن المادة'; $new_lesson['subject_subject_id'] = $subject->sub_id; $new_lesson['lesson_order'] = 0; $new_lesson['created_at'] = new DateTime(); $new_lesson['updated_at'] = new DateTime(); $new_lesson['state'] = 'نشط'; $new_lesson['type'] = 'مقدمة'; $new_lessons[] = $new_lesson; $new_element = new Element(); $new_element->subject_lesson_id = $intro_lesson_id; $new_element->title = 'الملخص'; $new_element->element_order = 0; $new_element->state = 'نشط'; $new_element->type = 'نص'; $new_element->value = $subject->sub_details; $new_element->created_at = new DateTime(); $new_element->updated_at = new DateTime(); $new_element->save(); $intro_lesson_id++; } } foreach ($lessons as $lesson) { $new_lesson['id'] = $lesson->les_id; $new_lesson['name'] = $lesson->les_name; $new_lesson['subject_subject_id'] = $lesson->les_subjectid; $new_lesson['lesson_order'] = $lesson->les_sort; $new_lesson['created_at'] = new DateTime(); $new_lesson['updated_at'] = new DateTime(); $new_lesson['type'] = 'درس'; $new_lesson['state'] = $lesson->les_active; $new_lessons[] = $new_lesson; if ($lesson->les_video) { $new_element = new Element(); $new_element->subject_lesson_id = $lesson->les_id; $new_element->title = 'المحاضرة المرئية'; $new_element->element_order = 1; $new_element->state = 'نشط'; $new_element->type = 'فيديو'; $new_element->value = $lesson->les_video; $new_element->created_at = new DateTime(); $new_element->updated_at = new DateTime(); $new_element->save(); if ($new_element->file->size() < 600) { // $new_element->delete(); } } if ($lesson->les_proceduralgoals) { $new_element = new Element(); $new_element->subject_lesson_id = $lesson->les_id; $new_element->title = 'الاهداف الاجرائية'; $new_element->element_order = 2; $new_element->state = 'نشط'; $new_element->type = 'PDF'; $new_element->file = "https://el-css.edu.om/" . $lesson->les_proceduralgoals; $new_element->created_at = new DateTime(); $new_element->updated_at = new DateTime(); $new_element->save(); if ($new_element->file->size() < 600) { // $new_element->delete(); } } if ($lesson->les_mapconcepts) { $new_element = new Element(); $new_element->subject_lesson_id = $lesson->les_id; $new_element->title = 'خريطة المفاهيم'; $new_element->element_order = 3; $new_element->state = 'نشط'; $new_element->type = 'PDF'; $new_element->file = "https://el-css.edu.om/" . $lesson->les_mapconcepts; $new_element->created_at = new DateTime(); $new_element->updated_at = new DateTime(); $new_element->save(); if ($new_element->file->size() < 600) { // $new_element->delete(); } } if ($lesson->les_lecturecontent) { $new_element = new Element(); $new_element->subject_lesson_id = $lesson->les_id; $new_element->title = 'المحتوى'; $new_element->element_order = 4; $new_element->state = 'نشط'; $new_element->type = 'PDF'; $new_element->file = "https://el-css.edu.om/" . $lesson->les_lecturecontent; $new_element->created_at = new DateTime(); $new_element->updated_at = new DateTime(); $new_element->save(); if ($new_element->file->size() < 600) { $new_element->delete(); } } if ($lesson->les_summary) { $new_element = new Element(); $new_element->subject_lesson_id = $lesson->les_id; $new_element->title = 'الملخص'; $new_element->element_order = 5; $new_element->state = 'نشط'; $new_element->type = 'PDF'; $new_element->file = "https://el-css.edu.om/" . $lesson->les_summary; $new_element->created_at = new DateTime(); $new_element->updated_at = new DateTime(); $new_element->save(); if ($new_element->file->size() < 600) { $new_element->delete(); } } if ($lesson->les_pdf) { $new_element = new Element(); $new_element->subject_lesson_id = $lesson->les_id; $new_element->title = 'نسخة للطباعة'; $new_element->element_order = 10; $new_element->state = 'نشط'; $new_element->type = 'PDF'; $new_element->file = "https://el-css.edu.om/" . $lesson->les_summary; $new_element->created_at = new DateTime(); $new_element->updated_at = new DateTime(); $new_element->save(); if ($new_element->file->size() < 600) { $new_element->delete(); } } } // foreach(array_chunk($new_subjects, 1000) as $chunk) { // DB::table('subject_subjects')->insert($chunk); // } foreach (array_chunk($new_lessons, 1000) as $chunk) { DB::table('subject_lessons')->insert($chunk); } }
public function lessonlevel($subjectid, Lesson $lesson) { $lessons = $lesson->where('subject_subject_id', $subjectid)->get(); foreach ($lessons as &$lesson) { //config('questionbank.types')[0] $lesson->lessons_understand = Question::where('lesson_id', $lesson->id)->where('level', config('questionbank.level')['الفهم'])->count(); $lesson->lessons_memory = Question::where('lesson_id', $lesson->id)->where('level', config('questionbank.level')['التذكر'])->count(); $lesson->lessons_conclusion = Question::where('lesson_id', $lesson->id)->where('level', config('questionbank.level')['الاستنتاج'])->count(); $lesson->lessons_application = Question::where('lesson_id', $lesson->id)->where('level', config('questionbank.level')['تطبيق'])->count(); $lesson->lessons_analysis = Question::where('lesson_id', $lesson->id)->where('level', config('questionbank.level')['تحليل'])->count(); } return view('questionbank::report.lessonlevel', compact('lessons')); }
public function delete($id) { $question = Question::findOrFail($id); $lesson = Lesson::findOrFail($question->lesson_id); $question = Question::with('exam')->findOrFail($id); if (!$question->exam->isEmpty()) { return redirect()->back()->with('error', 'لا يمكن حذف السؤال لانه مستخدم في اختبار'); } $question->delete(); $message = "تم حذف السؤال بنجاح"; return redirect()->route('questionbank.question', $lesson->subject_subject_id)->with('success', $message); }