Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quiz question soft delete #26

Closed
alex1897 opened this issue Aug 14, 2022 · 0 comments · Fixed by #27
Closed

Quiz question soft delete #26

alex1897 opened this issue Aug 14, 2022 · 0 comments · Fixed by #27
Assignees

Comments

@alex1897
Copy link
Contributor

I found that in the quiz_questions a unique constraint is set on quiz_id and question_id.

2021_05_22_053359_create_quizzes_table.php

// Quiz Questions Table
Schema::create($this->tableNames['quiz_questions'], function (Blueprint $table) {
    $table->id();
    $table->foreignId('quiz_id')->nullable()->constrained($this->tableNames['quizzes'])->cascadeOnDelete();
    $table->foreignId('question_id')->nullable()->constrained($this->tableNames['questions'])->cascadeOnDelete();
    $table->unsignedFloat('marks')->default(0); //0 means no marks
    $table->unsignedFloat('negative_marks')->default(0); //0 means no negative marks in case of wrong answer
    $table->boolean('is_optional')->default(false); //0 means not optional, 1 means optional
    $table->unsignedInteger('order')->default(0);
    $table->timestamps();
    $table->softDeletes();
    $table->unique(['quiz_id', 'question_id']);
});

When a question is deleted by mistake it cannot be added anymore. I guess it would make sense to remove the unique constraint and handle this also with the validation. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants