Compare commits
8 Commits
feature/ap
...
master
Author | SHA1 | Date |
---|---|---|
|
f3dd0fb4e8 | 5 hours ago |
|
a05e86d7a7 | 5 hours ago |
|
1e9e7405b1 | 7 hours ago |
|
11b4605861 | 4 days ago |
|
9de6862c04 | 4 days ago |
|
f4766c00a6 | 5 days ago |
|
7552a45e67 | 5 days ago |
|
b2f449b7f0 | 1 week ago |
15 changed files with 9709 additions and 35 deletions
@ -0,0 +1,24 @@ |
||||
<?php |
||||
|
||||
namespace App\Http\Resources; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use Illuminate\Http\Resources\Json\JsonResource; |
||||
|
||||
class BlankResource extends JsonResource |
||||
{ |
||||
/** |
||||
* Transform the resource into an array. |
||||
* |
||||
* @return array<string, mixed> |
||||
*/ |
||||
public function toArray(Request $request): array |
||||
{ |
||||
return [ |
||||
'id' => $this->id, |
||||
'position' => $this->position, |
||||
'correct_answer' => $this->correct_answer, |
||||
'other_answers' => $this->other_answers, |
||||
]; |
||||
} |
||||
} |
@ -0,0 +1,24 @@ |
||||
<?php |
||||
|
||||
namespace App\Http\Resources; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use Illuminate\Http\Resources\Json\JsonResource; |
||||
|
||||
class ChoiceResource extends JsonResource |
||||
{ |
||||
/** |
||||
* Transform the resource into an array. |
||||
* |
||||
* @return array<string, mixed> |
||||
*/ |
||||
public function toArray(Request $request): array |
||||
{ |
||||
return [ |
||||
'id' => $this->id, |
||||
'content' => $this->content, |
||||
'is_correct' => $this->is_correct, |
||||
'position' => $this->position, |
||||
]; |
||||
} |
||||
} |
@ -0,0 +1,27 @@ |
||||
<?php |
||||
|
||||
namespace App\Http\Resources; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use Illuminate\Http\Resources\Json\JsonResource; |
||||
|
||||
class ExerciseResource extends JsonResource |
||||
{ |
||||
/** |
||||
* Transform the resource into an array. |
||||
* |
||||
* @return array<string, mixed> |
||||
*/ |
||||
public function toArray(Request $request): array |
||||
{ |
||||
return [ |
||||
'id' => $this->id, |
||||
'name' => $this->lesson_name, |
||||
'description' => $this->description, |
||||
'level' => $this->level_label, |
||||
'year' => $this->year, |
||||
'skills' => SkillResource::collection($this->whenLoaded('skills')), |
||||
'question_groups' => QuestionGroupResource::collection($this->whenLoaded('questionGroups')), |
||||
]; |
||||
} |
||||
} |
@ -0,0 +1,23 @@ |
||||
<?php |
||||
|
||||
namespace App\Http\Resources; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use Illuminate\Http\Resources\Json\JsonResource; |
||||
|
||||
class QuestionGroupResource extends JsonResource |
||||
{ |
||||
/** |
||||
* Transform the resource into an array. |
||||
* |
||||
* @return array<string, mixed> |
||||
*/ |
||||
public function toArray(Request $request): array |
||||
{ |
||||
return [ |
||||
'id' => $this->id, |
||||
'content' => $this->content, |
||||
'questions' => QuestionResource::collection($this->whenLoaded('questions')), |
||||
]; |
||||
} |
||||
} |
@ -0,0 +1,25 @@ |
||||
<?php |
||||
|
||||
namespace App\Http\Resources; |
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource; |
||||
|
||||
class QuestionResource extends JsonResource |
||||
{ |
||||
public function toArray($request) |
||||
{ |
||||
return [ |
||||
'id' => $this->id, |
||||
'content' => $this->content, |
||||
'score' => $this->score, |
||||
'explanation' => $this->explanation, |
||||
'hint' => $this->hint, |
||||
'type' => [ |
||||
'code' => $this->type->code ?? null, |
||||
'name' => $this->type->name ?? null, |
||||
], |
||||
'choices' => $this->when($this->type->code === 'multiple_choice', ChoiceResource::collection($this->choices)), |
||||
'blanks' => $this->when($this->type->code !== 'multiple_choice', BlankResource::collection($this->blanks)), |
||||
]; |
||||
} |
||||
} |
@ -0,0 +1,22 @@ |
||||
<?php |
||||
|
||||
namespace App\Http\Resources; |
||||
|
||||
use Illuminate\Http\Request; |
||||
use Illuminate\Http\Resources\Json\JsonResource; |
||||
|
||||
class SkillResource extends JsonResource |
||||
{ |
||||
/** |
||||
* Transform the resource into an array. |
||||
* |
||||
* @return array<string, mixed> |
||||
*/ |
||||
public function toArray(Request $request): array |
||||
{ |
||||
return [ |
||||
'id' => $this->id, |
||||
'name' => $this->name |
||||
]; |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue