src/Controller/ExamRegistrationController.php line 102

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Service\EventService;
  4. use App\Service\ExamRegistrationsService;
  5. use App\Service\ExamRegistrationsTransactionsService;
  6. use App\Service\ExamsService;
  7. use App\Service\ExamVendorService;
  8. use App\Service\PckPackagesService;
  9. use App\Service\ProctorService;
  10. use App\Service\PurchaseService;
  11. use App\Service\SchoolInvoiceDetailsService;
  12. use App\Service\SchoolPaymentsService;
  13. use App\Service\TalService;
  14. use App\Service\TestSessionsService;
  15. use App\Util\ParameterUtil;
  16. use Psr\Log\LoggerInterface;
  17. use Symfony\Component\Config\Definition\Exception\Exception;
  18. use Symfony\Component\HttpFoundation\Request;
  19. use Symfony\Component\HttpFoundation\Response;
  20. use Symfony\Component\Routing\Annotation\Route;
  21. use Symfony\Component\HttpFoundation\StreamedResponse;
  22. class ExamRegistrationController extends BaseController
  23. {
  24. /**
  25. * @var ExamRegistrationsService
  26. */
  27. private $examRegistrationsService;
  28. /**
  29. * @var ExamsService
  30. */
  31. private $examsService;
  32. /**
  33. * @var TalService
  34. */
  35. private $talService;
  36. /**
  37. * @var ExamVendorService
  38. */
  39. private $examVendorService;
  40. /**
  41. * @var EventService
  42. */
  43. private $eventService;
  44. /**
  45. * @var PurchaseService
  46. */
  47. private $purchaseService;
  48. /**
  49. * @var ProctorService
  50. */
  51. private $proctorService;
  52. /**
  53. * @var TestSessionsService
  54. */
  55. private $testSessionsService;
  56. /**
  57. * @var PckPackagesService
  58. */
  59. private $pckPackagesService;
  60. /**
  61. * @var SchoolInvoiceDetailsService
  62. */
  63. private SchoolInvoiceDetailsService $schoolInvoiceDetailsService;
  64. private SchoolPaymentsService $schoolPaymentsService;
  65. private ExamRegistrationsTransactionsService $examRegistrationsTransactionsService;
  66. public function __construct(
  67. ExamRegistrationsService $examRegistrationsService,
  68. ExamsService $examsService,
  69. TalService $talService,
  70. ExamVendorService $examVendorService,
  71. EventService $eventService,
  72. PurchaseService $purchaseService,
  73. ProctorService $proctorService,
  74. TestSessionsService $testSessionsService,
  75. PckPackagesService $pckPackagesService,
  76. SchoolInvoiceDetailsService $schoolInvoiceDetailsService,
  77. SchoolPaymentsService $schoolPaymentsService,
  78. ExamRegistrationsTransactionsService $examRegistrationsTransactionsService
  79. ) {
  80. $this->examRegistrationsService = $examRegistrationsService;
  81. $this->examsService = $examsService;
  82. $this->talService = $talService;
  83. $this->examVendorService = $examVendorService;
  84. $this->eventService = $eventService;
  85. $this->purchaseService = $purchaseService;
  86. $this->proctorService = $proctorService;
  87. $this->testSessionsService = $testSessionsService;
  88. $this->pckPackagesService = $pckPackagesService;
  89. $this->schoolInvoiceDetailsService = $schoolInvoiceDetailsService;
  90. $this->schoolPaymentsService = $schoolPaymentsService;
  91. $this->examRegistrationsTransactionsService = $examRegistrationsTransactionsService;
  92. }
  93. /**
  94. * @Route("/api/onlineExamRegistration")
  95. */
  96. public function examRegistration(Request $request, LoggerInterface $logger)
  97. {
  98. try {
  99. $content = $this->getContent($request);
  100. $studentId = parent::getStudentId($request);
  101. $response = $this->examRegistrationsService->examRegistration(ParameterUtil::getRequired($content->get('examId')), $studentId, null, !$this->isAdmin($logger));
  102. } catch (Exception $ex) {
  103. return $this->json($ex->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR);
  104. }
  105. return $this->json(($response));
  106. }
  107. /**
  108. * @Route("/api/forcePackageUseOnlineExamRegistration")
  109. */
  110. public function examRegistrationWithPackageId(Request $request, LoggerInterface $logger)
  111. {
  112. try {
  113. $content = $this->getContent($request);
  114. $studentId = ParameterUtil::getRequired($content->get('studentId'));
  115. $packageId = ParameterUtil::getRequired($content->get('packageId'));
  116. $response = $this->examRegistrationsService->examRegistration(ParameterUtil::getRequired($content->get('examId')), $studentId, null, !$this->isAdmin($logger),$packageId);
  117. } catch (Exception $ex) {
  118. return $this->json($ex->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR);
  119. }
  120. return $this->json(($response));
  121. }
  122. /**
  123. * @Route("/api/cancelExamRegistration")
  124. */
  125. public function cancelExamRegistration(Request $request, LoggerInterface $logger)
  126. {
  127. try {
  128. $content = $this->getContent($request);
  129. $adminCancellationReason = $content->get('adminCancelReason') ?: null;
  130. $schoolId =$content->get('schoolId');
  131. $isSchoolRegistration = $content->get('isSchoolRegistration') ? true : false;
  132. $regId = ParameterUtil::getRequired($content->get('registrationId'));
  133. $response = $this->examRegistrationsTransactionsService->cancelExamRegistration($regId,$isSchoolRegistration,$schoolId,$this->isAdmin($logger), $adminCancellationReason);
  134. } catch (Exception $ex) {
  135. return $this->json($ex->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR);
  136. } catch (\Exception $e) {
  137. return $this->json($e->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR);
  138. }
  139. return $this->json($response);
  140. }
  141. /**
  142. * @Route("/api/changeRegistrationToOnline")
  143. */
  144. public function changeRegistrationToOnline(Request $request)
  145. {
  146. try {
  147. $content = $this->getContent($request);
  148. $adminCancellationReason = $content->get('adminCancelReason') ?: null;
  149. $regId = ParameterUtil::getRequired($content->get('registrationId'));
  150. $registration = $this->examRegistrationsService->findById($regId);
  151. if (!$registration) {
  152. throw new Exception("Registration not found $regId.");
  153. }
  154. $cancelSessionResponse = $this->examRegistrationsService->cancelSession($regId, true, $adminCancellationReason);
  155. $exam = $cancelSessionResponse['exam'];
  156. if (!$exam) {
  157. throw new Exception("Exam not found " . $cancelSessionResponse['exam']['id']);
  158. }
  159. if(!$exam['program_content_code']){
  160. $response = $this->examVendorService->getStartLink(
  161. $registration->getStudentid(),
  162. $registration->getExamid(),
  163. $regId
  164. );
  165. // $proctorUuid = $this->proctorService->addRPNowExamRegistration(
  166. // $registration->getStudentid(),
  167. // $registration->getExamid(),
  168. // $regId
  169. // );
  170. $exam['onlineAccess'] = $response['onlineAccess'];
  171. $exam['proctorUuid'] = null;
  172. }
  173. } catch (Exception $ex) {
  174. return $this->json($ex->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR);
  175. }
  176. return $this->json(array('exam' => $exam));
  177. }
  178. /**
  179. * @Route("/api/getExamRegistrations")
  180. */
  181. public function getExamRegistrations(Request $request)
  182. {
  183. try {
  184. $content = $this->getContent($request);
  185. $response = $this->examRegistrationsService->getExamRegistrations(
  186. ParameterUtil::getRequired($content->get('dateType'), 'dateType'),
  187. ParameterUtil::getRequired($content->get('startDate'), 'startDate'),
  188. ParameterUtil::getRequired($content->get('endDate'), 'endDate'),
  189. $content->get('schoolId')
  190. // $content->get('sessionTypeId'),
  191. // $content->get('sessionTypeValueId'),
  192. // $content->get('vendorId'),
  193. // $content->get('examId'),
  194. // $content->get('packageTypesId'),
  195. // $content->get('schoolCohort'),
  196. // $content->get('schoolId')
  197. );
  198. } catch (Exception $ex) {
  199. return $this->json($ex->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR);
  200. }
  201. return $this->json($response);
  202. }
  203. /**
  204. * @Route("/api/admin/makeVendorApprovedExamRetakeRegistration")
  205. */
  206. public function makeVendorApprovedExamRetakeRegistration(Request $request, LoggerInterface $logger)
  207. {
  208. $content = $this->getContent($request);
  209. $studentId= ParameterUtil::getRequired($content->get('student_id'));
  210. $examId = ParameterUtil::getRequired($content->get('examId'));
  211. $vendorApprovalReasonId = ParameterUtil::getRequired($content->get('vendorApprovalReasonId'));
  212. try{
  213. $response = $this->examRegistrationsTransactionsService->makeVendorApprovedExamRetakeRegistration($studentId,$examId,$vendorApprovalReasonId);
  214. }
  215. catch (\Exception $ex) {
  216. return $this->json($ex->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR);
  217. }
  218. return $this->json($response);
  219. }
  220. /**
  221. * @Route("/api/admin/changeExamToCourse")
  222. */
  223. public function changeExamToCourse(Request $request, LoggerInterface $logger)
  224. {
  225. $content = $this->getContent($request);
  226. $studentId= ParameterUtil::getRequired($content->get('student_id'));
  227. $examId = ParameterUtil::getRequired($content->get('examId'));
  228. try{
  229. $response = $this->examRegistrationsTransactionsService->changeExamToCourse($studentId,$examId);
  230. }
  231. catch (\Exception $ex) {
  232. return $this->json($ex->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR);
  233. }
  234. return $this->json($response);
  235. }
  236. /**
  237. * @Route("/api/cancelSession")
  238. */
  239. public function cancelSession(Request $request, LoggerInterface $logger)
  240. {
  241. try {
  242. $content = $this->getContent($request);
  243. $response = $this->examRegistrationsService->cancelSession(ParameterUtil::getRequired($content->get('registrationId')), $this->isAdmin($logger), $content->get('adminCancelReason'));
  244. } catch (Exception $ex) {
  245. return $this->json($ex->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR);
  246. }
  247. //the response is the sessionId that we're cancelling, we need to return it to update duration
  248. return $this->json($response);
  249. }
  250. /**
  251. * @Route("/api/cancelExamRegistrationWithFee")
  252. */
  253. public function cancelExamRegistrationWithFee(Request $request)
  254. {
  255. try {
  256. $content = $this->getContent($request);
  257. $response = $this->examRegistrationsService->cancelExamRegistrationWithFee(
  258. ParameterUtil::getRequired($content->get('registrationId')),
  259. ParameterUtil::getRequired($content->get('ccLast4')),
  260. ParameterUtil::getRequired($content->get('ccExo')),
  261. ParameterUtil::getRequired($content->get('fee')),
  262. ParameterUtil::getRequired($content->get('authResponse')),
  263. ParameterUtil::getRequired($content->get('authTransId'))
  264. );
  265. } catch (Exception $ex) {
  266. return $this->json(array('error' => $ex->getMessage()));
  267. }
  268. return $this->json(array('success' => $response));
  269. }
  270. /**
  271. * @Route("/api/completeExamRegistration")
  272. */
  273. public function completeExamRegistration(Request $request)
  274. {
  275. try {
  276. $content = $this->getContent($request);
  277. $response = $this->examRegistrationsService->completeExamRegistration(ParameterUtil::getRequired($content->get('registrationId')), 'from api');
  278. } catch (Exception $ex) {
  279. return $this->json(array('error' => $ex->getMessage()));
  280. }
  281. return $this->json(array('success' => $response));
  282. }
  283. /**
  284. * @Route("/api/updateGradesForCoopersmithExams")
  285. */
  286. public function updateGradesForCoopersmithExams()
  287. {
  288. try {
  289. $response = $this->examRegistrationsService->updateGradesForCoopersmithExams();
  290. } catch (Exception $ex) {
  291. return $this->json(array('error' => $ex->getMessage()));
  292. }
  293. return $this->json(array('success' => $response));
  294. }
  295. /**
  296. * @Route("/api/startExamProgram")
  297. */
  298. public function startExamProgram(Request $request, LoggerInterface $logger)
  299. {
  300. try {
  301. $content = $this->getContent($request);
  302. // $studentId = ParameterUtil::getRequired($content->get('studentId'));
  303. $studentId = parent::getStudentId($request);
  304. $examId = ParameterUtil::getRequired($content->get('examId'));
  305. $registrationId = ParameterUtil::getRequired($content->get('registrationId'));
  306. $logger->info("in start program");
  307. $response = $this->examVendorService->getStartLink(
  308. $studentId,
  309. $examId,
  310. $registrationId,
  311. true
  312. );
  313. } catch (Exception $e) {
  314. $logger->error('start exam error' . $e->getMessage());
  315. return $this->json(array('error' => $e->getMessage()), 500);
  316. }
  317. return $this->json(array('url' => $response['startExamLink']));
  318. }
  319. /**
  320. * @Route("/api/cancelUnusedRegistrations")
  321. */
  322. public function cancelUnusedExamRegistrations(Request $request) {
  323. try {
  324. $content = $this->getContent($request);
  325. $studentId = ParameterUtil::getRequired($content->get("studentId"),'studentId');
  326. $response = $this->examRegistrationsService->cancelUnusedExamRegistrations($studentId);
  327. } catch (Exception $ex) {
  328. return $this->json(array('error' => $ex->getMessage()));
  329. }
  330. return $this->json($response);
  331. }
  332. /**
  333. * @Route("/api/scheduleSessionForRegistration")
  334. */
  335. public function scheduleSessionForRegistration(Request $request, LoggerInterface $logger)
  336. {
  337. try {
  338. $content = $this->getContent($request);
  339. $studentId = parent::getStudentId($request);
  340. $response = $this->examRegistrationsService->scheduleSessionForRegistration(ParameterUtil::getRequired($content->get('registrationId')), ParameterUtil::getRequired($content->get('sessionId')), $studentId,false,$this->isAdmin($logger));
  341. $exam = $this->examsService->find($response['examId']);
  342. if ($this->examsService->isTalExam($exam)) {
  343. try {
  344. $this->talService->addStudent($studentId);
  345. } catch (Exception $e) {
  346. $logger->error('Error adding student to TAL ' . $e->getMessage());
  347. }
  348. }
  349. } catch (Exception $ex) {
  350. return $this->json(array('error' => $ex->getMessage()));
  351. }
  352. return $this->json($response);
  353. }
  354. /**
  355. * @Route("/api/setProctorReserved")
  356. */
  357. public function setProctorReserved(Request $request)
  358. {
  359. try {
  360. $content = $this->getContent($request);
  361. $this->examRegistrationsService->setProctorReserved(ParameterUtil::getRequired($content->get('registrationId')));
  362. } catch (Exception $ex) {
  363. return $this->json(array('error' => $ex->getMessage()));
  364. }
  365. return $this->json(array('success'));
  366. }
  367. /**
  368. * @Route("/api/cron/registerStudentsForExams", name="app_cron_register_students_for_exams")
  369. */
  370. public function registerStudentsForExams(Request $request)
  371. {
  372. $auth = $request->headers->get('token-auth');
  373. if ($auth == $_ENV['TTI_REQUEST_AUTH']) {
  374. try {
  375. $response = $this->examRegistrationsService->registerStudentsForExams();
  376. } catch (Exception $ex) {
  377. return new Response($ex->getMessage(), 500);
  378. }
  379. } else {
  380. return new Response('false authentication', 401);
  381. }
  382. return new Response($response);
  383. }
  384. /**
  385. * @Route("/api/cron/checkGradeForIncompleteExams")
  386. */
  387. public function checkGradeForIncompleteExam(Request $request)
  388. {
  389. $auth = $request->headers->get('token-auth');
  390. if ($auth == $_ENV['TTI_REQUEST_AUTH']) {
  391. try {
  392. $response = $this->examRegistrationsService->checkGradeForIncompleteExam();
  393. } catch (Exception $ex) {
  394. return new Response($ex->getMessage(), 500);
  395. }
  396. } else {
  397. return new Response('false authentication', 401);
  398. }
  399. return new Response($response);
  400. }
  401. /**
  402. * @Route("/api/cron/getGrades")
  403. */
  404. public function getGrades(Request $request)
  405. {
  406. $auth = $request->headers->get('token-auth');
  407. if ($auth == $_ENV['TTI_REQUEST_AUTH']) {
  408. try {
  409. $response = $this->examRegistrationsService->getGradesForTalCisExams();
  410. } catch (Exception $ex) {
  411. return new Response($ex->getMessage(), 500);
  412. }
  413. } else {
  414. return new Response('false authentication', 401);
  415. }
  416. return new Response($response);
  417. }
  418. /**
  419. * @Route("/api/reGradeRegistration")
  420. */
  421. public function reGradeRegistration(Request $request){
  422. $content = $this->getContent($request);
  423. $secularNumber = ParameterUtil::getRequired($content->get('courseNumber'));
  424. $tal_guid = ParameterUtil::getRequired($content->get('tal_guid'));
  425. try {
  426. $response = $this->examRegistrationsService->reGradeRegistration($secularNumber,$tal_guid);
  427. } catch (Exception $ex) {
  428. return new Response($ex->getMessage(), 500);
  429. }
  430. return new Response($response);
  431. }
  432. /**
  433. * @Route("/api/cron/getCoopersmithGrades")
  434. */
  435. public function getCoopersmithGrades(Request $request)
  436. {
  437. $auth = $request->headers->get('token-auth');
  438. if ($auth == $_ENV['TTI_REQUEST_AUTH']) {
  439. try {
  440. $this->examRegistrationsService->getGradesForCoopersmithExams(false);
  441. } catch (Exception $ex) {
  442. return new Response($ex->getMessage(), 500);
  443. }
  444. } else {
  445. return new Response('false authentication', 401);
  446. }
  447. return new Response('Success.');
  448. }
  449. /**
  450. * @Route("/api/cron/getCoopersmithGradesAll")
  451. */
  452. public function getCoopersmithGradesAll(Request $request)
  453. {
  454. $auth = $request->headers->get('token-auth');
  455. if ($auth == $_ENV['TTI_REQUEST_AUTH']) {
  456. $content = $this->getContent($request);
  457. $startDate = $content->get('startDate');
  458. $endDate = $content->get('endDate');
  459. try {
  460. $this->examRegistrationsService->
  461. getGradesForCoopersmithExams(true, $startDate, $endDate);
  462. } catch (Exception $ex) {
  463. return new Response($ex->getMessage(), 500);
  464. }
  465. } else {
  466. return new Response('false authentication', 401);
  467. }
  468. return new Response('Success');
  469. }
  470. /**
  471. * @Route("/api/cron/updateCoopersmithGrades")
  472. */
  473. public function updateCoopersmithGrades(Request $request)
  474. {
  475. $auth = $request->headers->get('token-auth');
  476. if ($auth == $_ENV['TTI_REQUEST_AUTH']) {
  477. try {
  478. $response = $this->examRegistrationsService->updateGradesForCoopersmithExams();
  479. } catch (Exception $ex) {
  480. return new Response($ex->getMessage(), 500);
  481. }
  482. } else {
  483. return new Response('false authentication', 401);
  484. }
  485. return new Response($response);
  486. }
  487. /**
  488. * @Route("/api/cron/dailyReportOnCoopersmithExamFromWoodmontPackage")
  489. */
  490. public function dailyReportOnCoopersmithExamFromWoodmontPackage(Request $request)
  491. {
  492. $auth = $request->headers->get('token-auth');
  493. if ($auth == $_ENV['TTI_REQUEST_AUTH']) {
  494. try {
  495. $response = $this->examRegistrationsService->reportOnCoopersmithExamFromWoodmontPackage();
  496. } catch (Exception $ex) {
  497. return new Response($ex->getMessage(), 500);
  498. }
  499. } else {
  500. return new Response('false authentication', 401);
  501. }
  502. return new Response($response);
  503. }
  504. /**
  505. * @Route("/api/getGradesByDates")
  506. */
  507. public function getGradesByDates(Request $request)
  508. {
  509. $auth = $request->headers->get('token-auth');
  510. $content = $this->getContent($request);
  511. $startDate = $content->get('startDate');
  512. $endDate = $content->get('endDate');
  513. if ($auth == $_ENV['TTI_REQUEST_AUTH']) {
  514. try {
  515. $response = $this->examRegistrationsService->getGradesForTalCisExamsByDates($startDate, $endDate);
  516. } catch (Exception $ex) {
  517. return new Response($ex->getMessage(), 500);
  518. }
  519. } else {
  520. return new Response('false authentication', 401);
  521. }
  522. return new Response($response);
  523. }
  524. /**
  525. * @Route("/api/getGradesByDatesForClosedBatchedRegistrations")
  526. */
  527. public function getGradesByDatesForClosedBatchedRegistrations(Request $request)
  528. {
  529. $auth = $request->headers->get('token-auth');
  530. $content = $this->getContent($request);
  531. $startDate = $content->get('startDate');
  532. $endDate = $content->get('endDate');
  533. if ($auth == $_ENV['TTI_REQUEST_AUTH']) {
  534. try {
  535. $response = $this->examRegistrationsService->getGradesByDatesForClosedBatchedRegistrations($startDate, $endDate);
  536. } catch (Exception $ex) {
  537. return new Response($ex->getMessage(), 500);
  538. }
  539. } else {
  540. return new Response('false authentication', 401);
  541. }
  542. return new Response($response);
  543. }
  544. //we updated registration with grades but without a specific exam taken date,
  545. // here we go over those registrations and set the online exam started date
  546. // to be TAL's examTakenDate - this way we'll have a date to show in the front end
  547. /**
  548. * @Route("/api/getExamTakenDateForAlreadyGradedRegistrations")
  549. */
  550. public function getExamTakenDateForAlreadyGradedRegistrations(Request $request)
  551. {
  552. $auth = $request->headers->get('token-auth');
  553. $content = $this->getContent($request);
  554. if ($auth == $_ENV['TTI_REQUEST_AUTH']) {
  555. try {
  556. $response = $this->examRegistrationsService->getExamTakenDateForAlreadyGradedRegistrations();
  557. } catch (Exception $ex) {
  558. return new Response($ex->getMessage(), 500);
  559. }
  560. } else {
  561. return new Response('false authentication', 401);
  562. }
  563. return new Response($response);
  564. }
  565. /**
  566. * @Route("/api/getGradesForOldRegistrationsMarkedAs01")
  567. */
  568. public function getGradesForOldRegistrationsMarkedAs01(Request $request)
  569. {
  570. $auth = $request->headers->get('token-auth');
  571. $content = $this->getContent($request);
  572. $limit = $content->get('limit');
  573. if ($auth == $_ENV['TTI_REQUEST_AUTH']) {
  574. try {
  575. $response = $this->examRegistrationsService->getGradesForOldRegistrationsMarkedAs01($limit);
  576. } catch (Exception $ex) {
  577. return new Response($ex->getMessage(), 500);
  578. }
  579. } else {
  580. return new Response('false authentication', 401);
  581. }
  582. return new Response($response);
  583. }
  584. /**
  585. * @Route("/api/cleanupOldIncompleteRegistrations")
  586. */
  587. public function cleanupOldIncompleteRegistrations(Request $request)
  588. {
  589. $auth = $request->headers->get('token-auth');
  590. $content = $this->getContent($request);
  591. if ($auth == $_ENV['TTI_REQUEST_AUTH']) {
  592. try {
  593. $registrationIds = $content->get('registrationIds');
  594. $response = $this->examRegistrationsService->cleanupOldIncompleteRegistrations($registrationIds);
  595. } catch (Exception $ex) {
  596. return new Response($ex->getMessage(), 500);
  597. }
  598. } else {
  599. return new Response('false authentication', 401);
  600. }
  601. return new Response($response);
  602. }
  603. /**
  604. * @Route("/api/event/checkOnlineAccess")
  605. */
  606. public function eventCheckOnlineAccess(Request $request, LoggerInterface $logger)
  607. {
  608. $regId = $request->query->get('regId');
  609. $logger->info('got into checkOnlineAccess');
  610. if (!$regId) {
  611. throw new Exception("Missing required parameter.");
  612. }
  613. $this->eventService->checkOnlineAccess($regId);
  614. }
  615. /**
  616. * @Route("/api/event/checkProgramCompleted")
  617. */
  618. public function eventCheckProgramCompleted(Request $request, LoggerInterface $logger)
  619. {
  620. $regId = $request->query->get('regId');
  621. $logger->info("into checkProgramCompletedEvent");
  622. if (!$regId) {
  623. throw new Exception("Missing required parameter.");
  624. }
  625. $this->eventService->checkOnlineProgramCompleted($regId);
  626. }
  627. /**
  628. * @Route("/api/checkProgramCompleted")
  629. */
  630. public function checkProgramCompleted(Request $request, LoggerInterface $logger)
  631. {
  632. $content = $this->getContent($request);
  633. $regId = $content->get('regId');
  634. $logger->info("into checkProgramCompletedEvent");
  635. if (!$regId) {
  636. throw new Exception("Missing required parameter.");
  637. }
  638. $registration = $this->examRegistrationsService->findById($regId);
  639. $response = $registration->getOnlineProgramCompleted() ? $registration->getOnlineProgramCompleted()->format('Y-m-d') : '';
  640. return new Response($response);
  641. }
  642. /**
  643. * @Route("/api/checkOnlineAccess")
  644. */
  645. public function checkOnlineAccess(Request $request, LoggerInterface $logger)
  646. {
  647. $content = $this->getContent($request);
  648. $regId = $content->get('regId');
  649. $logger->info("into checkProgramCompletedEvent");
  650. if (!$regId) {
  651. throw new Exception("Missing required parameter.");
  652. }
  653. $registration = $this->examRegistrationsService->findById($regId);
  654. $response = $registration->getOnlineaccess() ? $registration->getOnlineaccess()->format('Y-m-d') : '';
  655. return new Response($response);
  656. }
  657. /**
  658. * @Route("/api/getExamRegistrationsForStudent")
  659. */
  660. public function getExamRegistrationsForStudent(Request $request) {
  661. $content = $this->getContent($request);
  662. $studentId = $content->get('studentId');
  663. if (!$studentId) {
  664. throw new Exception("Missing studentId.");
  665. }
  666. $vendorId = $content->get('vendorId');
  667. if (!$vendorId) {
  668. throw new Exception("Missing vendorId.");
  669. }
  670. $registrations = $this->examRegistrationsService->getRegistrations($studentId, $vendorId);
  671. return new Response($registrations);
  672. }
  673. }