test_question_api.php 638 B

123456789101112131415161718
  1. <?php
  2. require __DIR__ . '/vendor/autoload.php';
  3. $app = require_once __DIR__ . '/bootstrap/app.php';
  4. $kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
  5. $kernel->bootstrap();
  6. $service = app(App\Services\QuestionServiceApi::class);
  7. $result = $service->listQuestions(1, 5);
  8. echo "Total: " . ($result['meta']['total'] ?? 0) . PHP_EOL;
  9. echo "Questions: " . count($result['data'] ?? []) . PHP_EOL;
  10. if (!empty($result['data'])) {
  11. echo "First question: " . substr($result['data'][0]['stem'] ?? '', 0, 80) . PHP_EOL;
  12. echo "Has LaTeX: " . (str_contains($result['data'][0]['stem'] ?? '', '$') ? 'Yes' : 'No') . PHP_EOL;
  13. }