Add bootstrap/jquery when exporting a SCORM package, adding oral question type

See BT#11321
pull/2487/head
Julio 9 years ago
parent 63c0c3759e
commit 8e340ef510
  1. 6
      main/document/record_audio.php
  2. 101
      main/exercise/export/scorm/scorm_classes.php
  3. 2
      main/inc/lib/exercise.lib.php
  4. 14
      main/lp/learnpath.class.php
  5. 0
      main/lp/packaging/assets/api_wrapper.js
  6. 6
      main/lp/packaging/assets/bootstrap/bootstrap.min.css
  7. 5
      main/lp/packaging/assets/jquery/jquery.min.js
  8. 2
      main/template/default/document/record_audio.tpl

@ -29,9 +29,9 @@ $document_id = $document_data['id'];
$dir = $document_data['path'];
//make some vars
$wamidir=$dir;
if($wamidir=="/"){
$wamidir="";
$wamidir = $dir;
if ($wamidir == "/") {
$wamidir = "";
}
$wamiurlplay = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$wamidir."/";
$groupId = api_get_group_id();

@ -166,18 +166,27 @@ class ScormQuestion extends Question
/**
* Return the JavaScript code bound to the question
*/
function getQuestionJS()
public function getQuestionJS()
{
$w = $this->selectWeighting();
$s = 'questions.push('.$this->js_id.');'."\n";
if ($this->type == HOT_SPOT) {
//put the max score to 0 to avoid discounting the points of
//non-exported quiz types in the SCORM
$w = 0;
$weight = $this->selectWeighting();
$js = 'questions.push('.$this->js_id.');'."\n";
switch ($this->type) {
case ORAL_EXPRESSION:
$script = file_get_contents(api_get_path(LIBRARY_PATH) . 'javascript/rtc/RecordRTC.js');
$script .= file_get_contents(api_get_path(LIBRARY_PATH) . 'wami-recorder/recorder.js');
$script .= file_get_contents(api_get_path(LIBRARY_PATH) . 'wami-recorder/gui.js');
$js .= $script;
break;
case HOT_SPOT:
//put the max score to 0 to avoid discounting the points of
//non-exported quiz types in the SCORM
$weight = 0;
break;
}
$s .= 'questions_score_max['.$this->js_id.'] = '.$w.";";
$js .= 'questions_score_max['.$this->js_id.'] = '.$weight.";";
return $s;
return $js;
}
}
@ -215,7 +224,7 @@ class ScormAnswerMultipleChoice extends Answer
<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />
</td>
<td width="95%">
<label for="'.$identifier.'">' . $this->answer[$i] . '</label>
<label for="'.$identifier.'">' . Security::remove_XSS($this->answer[$i]) . '</label>
</td>
</tr>';
@ -243,7 +252,7 @@ class ScormAnswerMultipleChoice extends Answer
<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />
</td>
<td width="95%">
<label for="'.$identifier.'">' . $this->answer[$i] . '</label>
<label for="'.$identifier.'">' . Security::remove_XSS($this->answer[$i]) . '</label>
</td>
</tr>';
@ -271,7 +280,7 @@ class ScormAnswerMultipleChoice extends Answer
<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="checkbox"/>
</td>
<td width="95%">
<label for="'.$identifier.'">' . $this->answer[$i] . '</label>
<label for="'.$identifier.'">' . Security::remove_XSS($this->answer[$i]) . '</label>
</td>
</tr>';
$jstmp .= $i.',';
@ -539,6 +548,18 @@ class ScormAnswerFree extends Answer
$identifier = 'question_'.$this->questionJSId.'_free';
// currently the free answers cannot be displayed, so ignore the textarea
$html = '<tr><td colspan="2">';
$type = $this->getQuestionType();
if ($type == ORAL_EXPRESSION) {
$template = new Template('');
$template->assign('directory', '/tmp/');
$template->assign('user_id', api_get_user_id());
$layout = $template->get_template('document/record_audio.tpl');
$html .= $template->fetch($layout);
}
$html .= '<textarea minlength="20" name="'.$identifier.'" id="'.$identifier.'" ></textarea>';
$html .= '</td></tr>';
$js .= 'questions_answers['.$this->questionJSId.'] = new Array();';
@ -679,12 +700,13 @@ class ScormAssessmentItem
*/
function start_page()
{
$charset = 'UTF-8';
$head = '';
if ($this->standalone) {
$charset = 'UTF-8';
$head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?>';
$head .= '<html>';
}
return $head;
}
@ -729,6 +751,7 @@ class ScormAssessmentItem
$css .= '/*]]>*/'."\n";
$css .= '</style>';
}
return $css;
}
@ -749,10 +772,11 @@ class ScormAssessmentItem
*/
function start_js()
{
$js = '<script type="text/javascript" src="assets/api_wrapper.js"></script>';
if ($this->standalone) {
return '<script>';
}
return '';
return $js;
}
/**
@ -760,7 +784,6 @@ class ScormAssessmentItem
*/
function common_js()
{
$js = file_get_contents('../lp/js/api_wrapper.js');
$js .= 'var questions = new Array();';
$js .= 'var questions_answers = new Array();';
$js .= 'var questions_answers_correct = new Array();';
@ -842,7 +865,7 @@ class ScormAssessmentItem
function end_body()
{
if ($this->standalone) {
return '<br /><input type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>';
return '<br /><input class="btn" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>';
}
return '';
@ -858,8 +881,7 @@ class ScormAssessmentItem
*/
function export()
{
$js = $html = '';
list($js,$html) = $this->question->export();
list($js, $html) = $this->question->export();
if ($this->standalone) {
$res = $this->start_page()
. $this->start_header()
@ -934,7 +956,7 @@ class ScormSection
*/
function start_page()
{
global $charset;
$charset = 'UTF-8';
$head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?><html>';
return $head;
@ -960,24 +982,15 @@ class ScormSection
/**
* Print CSS inclusion
*/
function css()
private function css()
{
$css = '<style type="text/css" media="screen, projection">';
$css .= '/*<![CDATA[*/'."\n";
$css .= '/*]]>*/'."\n";
$css .= '</style>'."\n";
$css .= '<style type="text/css" media="print">';
$css .= '/*<![CDATA[*/'."\n";
$css .= '/*]]>*/'."\n";
$css .= '</style>';
return $css;
return '';
}
/**
* End document header
*/
function end_header()
private function end_header()
{
return '</head>';
}
@ -986,7 +999,7 @@ class ScormSection
* Start the itemBody
*
*/
function start_js()
private function start_js()
{
return '<script>';
}
@ -994,11 +1007,10 @@ class ScormSection
/**
* Common JS functions
*/
function common_js()
public function common_js()
{
$js = "\n";
$js .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js');
$js .= file_get_contents('../lp/js/api_wrapper.js');
$js = file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js');
$js .= 'var questions = new Array();' . "\n";
$js .= 'var questions_answers = new Array();' . "\n";
$js .= 'var questions_answers_correct = new Array();' . "\n";
@ -1078,7 +1090,7 @@ class ScormSection
*/
function end_body()
{
return '</table><br /><input type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>';
return '</table><br /><input class="btn btn-primary" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>';
}
/**
@ -1103,6 +1115,7 @@ class ScormSection
$res = $this->start_page()
. $this->start_header()
. $this->css()
. $this->globalAssets()
. $this->start_js()
. $this->common_js()
. $js
@ -1116,6 +1129,18 @@ class ScormSection
return $res;
}
/**
* @return string
*/
private function globalAssets()
{
$assets = '<script type="text/javascript" src="assets/jquery/jquery.min.js"></script>';
$assets .= '<script type="text/javascript" src="assets/api_wrapper.js"></script>';
$assets .= '<link href="assets/bootstrap/bootstrap.min.css" rel="stylesheet" media="screen" type="text/css" />';
return $assets;
}
/**
* Export the questions, as a succession of <items>
* @author Amand Tihon <amand@alrj.org>
@ -1125,7 +1150,7 @@ class ScormSection
$js = $html = "";
$js_id = 0;
foreach ($this->exercise->selectQuestionList() as $q) {
list($jstmp,$htmltmp)= ScormQuestion::export_question($q, false, $js_id);
list($jstmp, $htmltmp)= ScormQuestion::export_question($q, false, $js_id);
$js .= $jstmp."\n";
$html .= $htmltmp."\n";
++$js_id;

@ -105,7 +105,6 @@ class ExerciseLib
// suggestions here, for the sake of comprehensions, while the ones
// on the right side are called answers
$num_suggestions = 0;
if (in_array($answerType, [MATCHING, DRAGGABLE, MATCHING_DRAGGABLE])) {
if ($answerType == DRAGGABLE) {
$s .= '<div class="col-md-12 ui-widget ui-helper-clearfix">
@ -319,6 +318,7 @@ class ExerciseLib
}
$answer = Security::remove_XSS($answer, STUDENT);
$s .= Display::input(
'hidden',
'choice2[' . $questionId . ']',

@ -9955,16 +9955,10 @@ EOD;
// Add the extra files that go along with a SCORM package.
$main_code_path = api_get_path(SYS_CODE_PATH) . 'lp/packaging/';
$extra_files = scandir($main_code_path);
foreach ($extra_files as $extra_file) {
if (strpos($extra_file, '.') === 0) {
continue;
} else {
$dest_file = $archive_path.$temp_dir_short.'/'.$extra_file;
$this->create_path($dest_file);
copy($main_code_path.$extra_file, $dest_file);
}
}
$fs = new \Symfony\Component\Filesystem\Filesystem;
$fs->mirror($main_code_path, $archive_path.$temp_dir_short);
// Finalize the imsmanifest structure, add to the zip, then return the zip.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -54,7 +54,7 @@
</div>
<script>
$(document).on('ready', function () {
$(document).on('ready', function() {
function useRecordRTC() {
$('#record-audio-recordrtc').show();

Loading…
Cancel
Save