Пример #1
0
 public function storequestion(Question $question, Request $req, $subjectid)
 {
     $question->fill($req->all())->save();
     $message = 'تم اضافة السؤال بنجاح';
     if (request('submit') == 'save') {
         return redirect()->route('choice.create', array('id' => $question->id))->with('success', $message);
     } else {
         return redirect()->route('questionbank.questionlistsub', array('id' => $subjectid))->with('success', $message);
     }
 }
Пример #2
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     //
     //
     Question::created(function ($question) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'question', 'reference_id' => $question->id]);
     });
     Question::updated(function ($question) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'question', 'reference_id' => $question->id]);
     });
     Question::deleted(function ($question) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'question', 'reference_id' => $question->id]);
     });
 }
Пример #3
0
    public function index($exam_id)
    {
        $exam = Exam::with('subject')->findOrFail($exam_id);
        $exam_questions = ExamQuestion::with(['question' => function ($query) {
            $query->orderByRaw("case\n          when questionbank_questions.type = 'true_false' then 'a'\n          when questionbank_questions.type = 'single_choice' then 'b'\n          when questionbank_questions.type = 'multiple_choice' then 'c'\n          when questionbank_questions.type = 'essay' then 'd'\n        end ASC");
        }])->select('era.id as has_been_corrected', 'exam_questions.exam_id', 'exam_questions.question_id', 'exam_questions.devide_grade')->has('question')->join('exams as e', 'e.id', '=', 'exam_questions.exam_id')->leftJoin('exam_results as er', 'er.exam_id', '=', 'e.id')->leftJoin('exam_result_answers as era', 'era.exam_result_id', '=', 'er.id')->where('exam_questions.exam_id', $exam->id)->groupBy('exam_questions.id')->get();
        $list_questions = Question::select('questionbank_questions.*')->selectRaw('CONCAT((
			CASE questionbank_questions.type
			WHEN "essay" THEN "مقالي"
			WHEN "true_false" THEN "صح أو خطأ"
			WHEN "single_choice" THEN "إختياري إجابة واحدة"
			WHEN "multiple_choice" THEN "إختياري متعدد"
			WHEN "essay" THEN "مقالي"
			END), " --- ", questionbank_questions.question) as full_question')->join('subject_lessons as sl', 'sl.id', '=', 'questionbank_questions.lesson_id')->join('subject_subjects as ss', function ($join) use($exam) {
            $join->on('ss.id', '=', 'sl.subject_subject_id')->where('ss.id', '=', $exam->subject_id);
        })->groupBy('questionbank_questions.id')->whereNotIn('questionbank_questions.id', $exam_questions->pluck('question_id'))->pluck('full_question', 'id')->toArray();
        return view('exams::questions.index', compact('exam_questions', 'list_questions', 'exam'));
    }
Пример #4
0
 public function generateQuestions(CreateExamRequest $request)
 {
     $number_of_questions = $request->input('number_of_questions');
     $questions_difficulty = $request->input('questions_difficulty');
     $questions_levels = $request->input('questions_levels');
     $questions_types = $request->input('questions_types');
     $questions_ids = [];
     foreach ($number_of_questions as $key => $number) {
         $type = $questions_types[$key];
         $level = $questions_levels[$key];
         $difficulty = $questions_difficulty[$key];
         $q_ids = Question::where('type', $type)->where('level', $level)->where('difficulty', $difficulty)->take($number)->pluck('id')->toArray();
         $questions_ids += $q_ids;
     }
     return $questions_ids;
 }
 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);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     if (Question::count()) {
         return;
     }
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     Question::truncate();
     Choice::truncate();
     // $this->call("OthersTableSeeder");
     $q_type = [1 => 'true_false', 2 => 'true_false', 7 => 'single_choice', 6 => 'multiple_choice', 5 => 'essay', 4 => 'complete'];
     ////////////////////// TRUE FALSE
     $this->command->info('connect to old database');
     $questions = DB::connection('old')->table('questions')->select('l2.les_id as l2_les_id', 'questions.*', 'questionanswers.*')->whereIn('q_typeid', [1, 2])->join('lessons', 'lessons.les_id', '=', 'questions.q_lessonid')->leftJoin('lessons as l2', function ($j) {
         $j->on('lessons.les_subjectid', '=', 'l2.les_subjectid')->where('l2.les_active', '=', 'active');
     })->join('questionanswers', 'questions.q_id', '=', 'questionanswers.qans_questionid')->groupBy('questions.q_id')->get();
     $all_q = [];
     $all_answer = [];
     $this->command->info('start first foreach');
     foreach ($questions as $question) {
         $new_question = [];
         $new_question['id'] = $question->q_id;
         $new_question['question'] = $question->q_name;
         $new_question['type'] = $q_type[$question->q_typeid];
         $new_question['lesson_id'] = $question->l2_les_id ? $question->l2_les_id : $question->q_lessonid;
         $new_question['difficulty'] = $question->q_hardlevelid;
         $new_question['created_at'] = $question->q_created;
         $new_question['updated_at'] = $question->q_modified;
         $new_question['isactive'] = $question->q_active;
         $new_answer = [];
         $new_answer['choice'] = $question->q_answer1;
         $new_answer['question_id'] = $question->q_id;
         $new_answer['istrue'] = $question->qans_correct == 0 ? 1 : 0;
         $new_answer['created_at'] = $question->qans_created;
         $new_answer['updated_at'] = $question->qans_modified;
         $all_answer[] = $new_answer;
         $new_answer['choice'] = $question->q_answer2;
         $new_answer['question_id'] = $question->q_id;
         $new_answer['istrue'] = $question->qans_correct == 1 ? 1 : 0;
         $new_answer['created_at'] = $question->qans_created;
         $new_answer['updated_at'] = $question->qans_modified;
         $all_answer[] = $new_answer;
         $all_q[] = $new_question;
     }
     foreach (array_chunk($all_q, 500) as $chunk) {
         DB::table('questionbank_questions')->insert($chunk);
     }
     foreach (array_chunk($all_answer, 500) as $chunk) {
         DB::table('questionbank_choices')->insert($chunk);
     }
     $this->command->info('Questionbank TF entered!');
     ///////////////////////other Q (MCQ + subject)
     $questions = DB::connection('old')->table('questions')->select('l2.les_id as l2_les_id', 'questions.*')->whereIn('q_typeid', [5, 6, 7, 4])->join('lessons', 'lessons.les_id', '=', 'questions.q_lessonid')->leftJoin('lessons as l2', function ($j) {
         $j->on('lessons.les_subjectid', '=', 'l2.les_subjectid')->where('l2.les_active', '=', 'active');
     })->groupBy('questions.q_id')->get();
     $all_q = [];
     foreach ($questions as $question) {
         $new_question = [];
         $new_question['id'] = $question->q_id;
         $new_question['question'] = $question->q_name;
         $new_question['type'] = $q_type[$question->q_typeid];
         $new_question['lesson_id'] = $question->l2_les_id ? $question->l2_les_id : $question->q_lessonid;
         $new_question['difficulty'] = $question->q_hardlevelid;
         $new_question['created_at'] = $question->q_created;
         $new_question['updated_at'] = $question->q_modified;
         $new_question['isactive'] = $question->q_active;
         $all_q[] = $new_question;
     }
     foreach (array_chunk($all_q, 500) as $chunk) {
         DB::table('questionbank_questions')->insert($chunk);
     }
     $this->command->info('Questionbank q 567 entered!');
     $question_ans = DB::connection('old')->table('questionanswers')->join('questions', 'questions.q_id', '=', 'questionanswers.qans_questionid')->whereIn('q_typeid', ['4', '5', '6', '7'])->get();
     $all_answer = [];
     foreach ($question_ans as $ans) {
         $new_answer = [];
         $new_answer['choice'] = $ans->qans_value;
         $new_answer['question_id'] = $ans->q_id;
         $new_answer['istrue'] = $ans->qans_correct == 1 ? 1 : 0;
         $new_answer['created_at'] = $ans->qans_created;
         $new_answer['updated_at'] = $ans->qans_modified;
         $all_answer[] = $new_answer;
     }
     foreach (array_chunk($all_answer, 500) as $chunk) {
         DB::table('questionbank_choices')->insert($chunk);
     }
     $this->command->info('Questionbank ans 567 entered!');
 }
Пример #7
0
 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'));
 }
Пример #8
0
 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);
 }