}
$this->mixDirectories['assets'] = 'dist/assets';
$this->data['theme'] = new Data($themeData);
+ $this->data['env'] = config('app.env');
}
protected function writeData()
{
-
$json = $this->data->asJSON();
$dataSource = $this->compilePath . '/js/quiz.js';
file_put_contents($dataSource, str_replace('this.data = data;', 'this.data = ' . $json . ';', file_get_contents($dataSource)));
{
protected function setupLogRoutes($segment, $routeName, $controller)
{
- Route::match(['post','get'], $segment . '/{id}/log', $controller . '@log')->withoutMiddleware([VerifyCsrfToken::class, Authenticate::class, CheckIfAdmin::class]);
+ Route::match(['post', 'get'], $segment . '/{id}/log', $controller . '@log')->withoutMiddleware([VerifyCsrfToken::class, Authenticate::class, CheckIfAdmin::class]);
}
protected function log($id)
{
$request = request();
+ if ($request->getContentTypeFormat() === 'json') {
+ $passed = $request->get('passed') ? '1' : '0';
+ } else {
+ $passed = $request->get('passed') !== 'false' ? '1' : '0';
+ }
+
$log = new QuizAttempt();
$log->quiz = $id;
$log->score = $request->get('score');
- $log->passed = $request->get('passed') !== 'false' ? '1' : '0';
+ $log->passed = $passed;
$log->answers = json_encode($request->get('questions'));
$log->save();
if (null === $answers || !is_array($answers)) {
continue;
}
+
foreach ($answers as $aid => $answer) {
if (null === $answer) {
continue;
}
$a[] = is_array($aa) ? implode(', ', $aa) : $aa;
if ($quiz->display_score && in_array($aid - 1, $countForScore, true)) {
- $a[] = $answer['score'];
+ $a[] = $answer['score'] ? (int)$answer['score'] : '0';
}
}
$attemptsList[] = $a;
}
-
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();