PHP code example of goldnead / statamic-assessments
1. Go to this page and download the library: Download goldnead/statamic-assessments library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
goldnead / statamic-assessments example snippets
use Goldnead\Assessments\Facades\Assessments;
$assessment = Assessments::create([
'handle' => 'stimm-check',
'title' => 'Stimm-Check',
'published' => true,
'collect' => ['name' => 'optional'], // off | optional | Woran arbeitest du?', 'type' => 'multi', 'options' => [
['label' => 'Atmung', 'points' => 1],
['label' => 'Register', 'points' => 2],
]],
['text' => 'Wie sicher in der Höhe?', 'type' => 'scale', 'min' => 1, 'max' => 5, 'points_per_step' => 1],
],
'scoring' => [
['key' => 'anfang', 'label' => 'Am Anfang', 'min' => 1, 'max' => 5, 'text' => '…'],
['key' => 'weit', 'label' => 'Weit', 'min' => 6, 'max' => 11, 'text' => '…', 'redirect' => null],
],
]);
Assessments::find('stimm-check');
Assessments::update($assessment, ['published' => false]);
Assessments::score($assessment, $answers); // ['score' => 7, 'breakdown' => [id => points]]
Assessments::submit($assessment, $email, $name, $answers); // stores, fires AssessmentCompleted
Assessments::readableAnswers($response); // [['question', 'type', 'answer', 'points'], …]
bash
composer migrate
php artisan vendor:publish --tag=statamic-assessments
bash
php artisan vendor:publish --tag=assessments-views
bash
php artisan vendor:publish --tag=assessments-config