vendredi 29 novembre 2019

Laravel 5.8 - Online Quiz System similar to google classroom Quiz Assignment using laravel

I am developing a learning management system application in laravel. In this system a student can enroll in multiple subjects, Each subject has many excercises which in-turn has many lectures.

I want to make an online quiz system similar to google classroom QuizAssignment but confused regarding the structure of database . The quiz will be connected with excercises in such a way that each excercise can have many quizes.

Student -> BelongToMany -> Subject -> hasMany -> Excercise-> hasMany -> Lecture

Student Model

 public function enrolledcourses(){
    return $this->belongsToMany(Subject::class,'course_student','student_id','subject_id')->withPivot('teacher_id','status');
}

Subject Model

 public function students(){
    return $this->belongsToMany(User::class,'course_student','subject_id','student_id')->withPivot('teacher_id','status');
}
 public function excercises()
{
    return $this->hasMany(Excercise::class);
}

Excercise Model

 public function subject()
{
    return $this->belongsTo(Subject::class);
}

public function lectures()
{
    return $this->hasMany(Lecture::class);
}


public function quizes()
{
    return $this->hasMany(Quiz::class);
}

Quiz Model

 public function excercise(){
    return $this->belongsTo(Excercise::class);
}

Quiz migration

public function up()
    {
        Schema::create('quizzes', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('excercise_id')->unsigned();
            $table->string('title');
            $table->integer('obtained_marks');
            $table->integer('total_marks');
            $table->integer('passing_marks');
            $table->string('remarks');
            $table->integer('attempted')->default(0);
            $table->timestamps();
        });
    }

Now i want each excercise to have many quizes as well like :

Excercise ->hasMany -> Quiz and Lecture

But I want Quiz to be connected with the student as well so that i could record the performance of each student in a specific quiz .In other words , I want student to select subject, then select an excercise and then select any quiz and then after conducting the quiz his data should be saved in a table . Can anyone brief how do i structure the database so that i may solve the above stated problem .



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/33xOeSh
via IFTTT

Aucun commentaire:

Enregistrer un commentaire