enrollment.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. $cidReset = true;
  4. require_once __DIR__.'/../../main/inc/global.inc.php';
  5. api_block_anonymous_users(true);
  6. $userId = api_get_user_id();
  7. $plugin = WhispeakAuthPlugin::create();
  8. $plugin->protectTool();
  9. $isEnrolledAlready = WhispeakAuthPlugin::checkUserIsEnrolled($userId);
  10. if ($isEnrolledAlready) {
  11. api_not_allowed(
  12. true,
  13. Display::return_message($plugin->get_lang('SpeechAuthAlreadyEnrolled'), 'warning')
  14. );
  15. }
  16. try {
  17. $sampleText = WhispeakAuthRequest::enrollmentSentence($plugin);
  18. } catch (Exception $exception) {
  19. api_not_allowed(
  20. true,
  21. Display::return_message($exception->getMessage(), 'error')
  22. );
  23. }
  24. ChamiloSession::write(WhispeakAuthPlugin::SESSION_SENTENCE_TEXT, $sampleText);
  25. $htmlHeadXtra[] = api_get_js('rtc/RecordRTC.js');
  26. $htmlHeadXtra[] = api_get_js_simple(api_get_path(WEB_PLUGIN_PATH).'whispeakauth/assets/js/RecordAudio.js');
  27. $template = new Template();
  28. $template->assign('action', 'enrollment');
  29. $template->assign('sample_text', $sampleText);
  30. $content = $template->fetch('whispeakauth/view/record_audio.html.twig');
  31. $template->assign('header', $plugin->get_title());
  32. $template->assign('content', $content);
  33. $template->display_one_col_template();