Skip to content

Commit

Permalink
Handle changes to the template rows better (as in, at all)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlobeltrame committed Jul 25, 2024
1 parent 90de593 commit e9be1a6
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 53 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/EvaluationGridTemplateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ protected function createNewRowTemplates(Collection $data, EvaluationGridTemplat
);

EvaluationGridRow::insert(
collect($evaluationGridTemplate->evaluation_grids)
collect($evaluationGridTemplate->evaluationGrids()->get())
->crossJoin($newRowTemplates)
->map(function ($input) {
/** @var EvaluationGrid $evaluationGrid */
/** @var EvaluationGridRowTemplate $rowTemplate */
[$evaluationGrid, $rowTemplate] = $input;
return ['evaluation_grid_id' => $evaluationGrid->id, 'evaluation_grid_row_template' => $rowTemplate->id];
return ['evaluation_grid_id' => $evaluationGrid->id, 'evaluation_grid_row_template_id' => $rowTemplate->id];
})
->all()
);
Expand Down
1 change: 0 additions & 1 deletion app/Http/Requests/EvaluationGridTemplateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public function rules() {
'row_templates' => 'required',
'row_templates.*.criterion' => 'required|max:65535',
'row_templates.*.control_type' => 'required|in:' . implode(',', EvaluationGridRowTemplate::CONTROL_TYPES),
'row_templates.*.control_config' => 'required|json' /*'required|json|validControlConfig'*/,
];
}

Expand Down
1 change: 0 additions & 1 deletion app/Models/EvaluationGridRowTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @property int $order
* @property string $criterion
* @property string $control_type
* @property string $control_config
* @property EvaluationGridTemplate $evaluation_grid_template
* @property EvaluationGridRow[] $evaluation_grid_rows
*/
Expand Down
2 changes: 0 additions & 2 deletions app/Providers/ValidationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Services\Validation\AllExistInCourse;
use App\Services\Validation\ExistsInCourse;
use App\Services\Validation\MaxEntries;
use App\Services\Validation\ValidControlConfig;
use App\Services\Validation\ValidFeedbackContent;
use App\Services\Validation\ValidFeedbackContentWithoutObservations;
use Illuminate\Support\Facades\Validator;
Expand All @@ -26,7 +25,6 @@ public function boot(): void {
Validator::extend('allExistInCourse', AllExistInCourse::class . '@validate');
Validator::extend('validFeedbackContent', ValidFeedbackContent::class . '@validate');
Validator::extend('validFeedbackContentWithoutObservations', ValidFeedbackContentWithoutObservations::class . '@validate');
Validator::extend('validControlConfig', ValidControlConfig::class . '@validate');

Validator::extend('maxEntries', MaxEntries::class . '@validate');
Validator::replacer('maxEntries', function ($message, $attribute, $rule, $parameters, $validator) {
Expand Down
37 changes: 0 additions & 37 deletions app/Services/Validation/ValidControlConfig.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public function up(): void {
$table->integer('order');
$table->text('criterion');
$table->string('control_type');
$table->json('control_config');
$table->timestamps();

$table->foreign('evaluation_grid_template_id', 'fk_egrt_grid_template')->references('id')->on('evaluation_grid_templates')->onDelete('CASCADE');
Expand Down
2 changes: 1 addition & 1 deletion lang/de/t.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"control_type" => "Typ",
"control_types" => array(
"checkbox" => "Checkbox",
"radiobuttons" => "Nicht erfüllt / erfüllt / übertroffen",
"radiobuttons" => "✘ / ✔ / ",
"slider" => "Skala von 1 - 10",
),
"criterion" => "Kriterium",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="d-flex flex-row flex-wrap" :class="{ 'is-invalid': errorMessage }">
<template v-if="type === 'slider'">
<div class="d-flex flex-column w-100">
<b-form-input type="range" min="0" max="3" :name="name" :value="currentValue || 0" />
<b-form-input type="range" min="0" max="9" :name="name" :value="currentValue || 0" />
<div class="d-flex flex-row justify-content-between font-size-larger">
<span>--</span>
<span>-</span>
Expand All @@ -29,7 +29,7 @@
:id="name | kebabCase"
:name="name"
:class="{ 'is-invalid': errorMessage }"
value="1"
value="7"
unchecked-value="0"
:state="errorMessage ? false : null"
v-model="currentValue"
Expand Down Expand Up @@ -58,11 +58,11 @@ export default {
return this.rowTemplate.control_type
},
radioButtonOptions() {
return [
this.$t('t.models.evaluation_grid_row.radio_buttons.not_fulfilled'),
this.$t('t.models.evaluation_grid_row.radio_buttons.fulfilled'),
this.$t('t.models.evaluation_grid_row.radio_buttons.expectations_surpassed'),
]
return {
'0': this.$t('t.models.evaluation_grid_row.radio_buttons.not_fulfilled'),
'7': this.$t('t.models.evaluation_grid_row.radio_buttons.fulfilled'),
'9': this.$t('t.models.evaluation_grid_row.radio_buttons.expectations_surpassed'),
}
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:aria-label="$t('t.global.remove')">
<i class="fas fa-circle-minus"></i>
</b-button>
<input-hidden :name="`${name}[id]`" :value="currentValue.id" />
<input-textarea
:name="`${name}[criterion]`"
:label="$t('t.models.evaluation_grid_row_template.criterion')"
Expand All @@ -24,7 +25,6 @@
:allow-empty="false"
narrow-form
></input-multi-select>
<input-hidden :name="`${name}[control_config]`" value="{}"></input-hidden>
</b-card>
</template>

Expand Down

0 comments on commit e9be1a6

Please sign in to comment.