Merge remote-tracking branch 'origin/1.11.x' into 1.11.x

pull/2487/head
Yannick Warnier 9 years ago
commit 9847b1dbe0
  1. 6
      main/document/record_audio.php
  2. 170
      main/exercise/export/scorm/scorm_classes.php
  3. 2
      main/inc/ajax/work.ajax.php
  4. 2
      main/inc/lib/exercise.lib.php
  5. 15
      main/inc/lib/template.lib.php
  6. 14
      main/lp/learnpath.class.php
  7. 2
      main/lp/learnpathItem.class.php
  8. 139
      main/lp/packaging/assets/api_wrapper.js
  9. 6
      main/lp/packaging/assets/bootstrap/bootstrap.min.css
  10. 5
      main/lp/packaging/assets/jquery/jquery.min.js
  11. 2
      main/template/default/document/record_audio.tpl
  12. 18
      main/work/upload.php
  13. 36
      main/work/work_list.php
  14. 8
      src/Chamilo/CourseBundle/Entity/CLp.php

@ -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;
}
}
@ -199,11 +208,12 @@ class ScormAnswerMultipleChoice extends Answer
$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();';
$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;';
$jstmpw .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();';
//not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM
//if ($type == MCMA || $type == MULTIPLE_ANSWER_COMBINATION ) {
if ($type == MCMA) {
//$questionTypeLang = get_lang('MultipleChoiceMultipleAnswers');
$id = 1;
$id = 1;
$jstmp = '';
$jstmpc = '';
foreach ($this->answer as $i => $answer) {
@ -214,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>';
@ -222,41 +232,42 @@ class ScormAnswerMultipleChoice extends Answer
if ($this->correct[$i]) {
$jstmpc .= $i.',';
}
$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n";
$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";";
$jstmpw .= 'questions_answers_correct['.$this->questionJSId.']['.$i.'] = '.$this->correct[$i].';';
$id++;
}
$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n";
$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n";
if ($type == MCMA) {
$js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n";
} else {
$js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n";
}
$js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n";
$js .= $jstmpw;
} elseif ($type == MULTIPLE_ANSWER_COMBINATION) {
//To this items we show the ThisItemIsNotExportable
$qId = $this->questionJSId;
$js = '';
$html = '<tr><td colspan="2"><table width="100%">';
// some javascript must be added for that kind of questions
$html .= '<tr>
<td>
<textarea name="question_'.$qId.'_free" id="question_'.$qId.'_exact" rows="20" cols="100"></textarea>
</td>
</tr>';
$html .= '</table></td></tr>';
// currently the exact answers cannot be displayed, so ignore the textarea
$html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>';
$js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n";
$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n";
$js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n";
$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n";
$js .= $jstmpw;
return array($js, $html);
$js = '';
$id = 1;
$jstmp = '';
$jstmpc = '';
foreach ($this->answer as $i => $answer) {
$identifier = 'question_'.$this->questionJSId.'_exact_'.$i;
$html .=
'<tr>
<td align="center" width="5%">
<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />
</td>
<td width="95%">
<label for="'.$identifier.'">' . Security::remove_XSS($this->answer[$i]) . '</label>
</td>
</tr>';
$jstmp .= $i.',';
if ($this->correct[$i]) {
$jstmpc .= $i.',';
}
$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";";
$jstmpw .= 'questions_answers_correct['.$this->questionJSId.']['.$i.'] = '.$this->correct[$i].";";
$id++;
}
$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');';
$js .= 'questions_types['.$this->questionJSId.'] = "exact";';
$js .= $jstmpw;
} else {
//$questionTypeLang = get_lang('MultipleChoiceUniqueAnswer');
$id = 1;
$jstmp = '';
$jstmpc = '';
@ -266,10 +277,10 @@ class ScormAnswerMultipleChoice extends Answer
$html .=
'<tr>
<td align="center" width="5%">
<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="radio"/>
<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.',';
@ -277,10 +288,10 @@ class ScormAnswerMultipleChoice extends Answer
$jstmpc .= $i;
}
$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";";
$jstmpw .= 'questions_answers_correct['.$this->questionJSId.']['.$i.'] = '.$this->correct[$i].';';
$id++;
}
$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');';
$js .= 'questions_answers_correct['.$this->questionJSId.'] = '.$jstmpc.';';
$js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';';
$js .= $jstmpw;
}
@ -537,13 +548,24 @@ 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>';
$score = $this->selectWeighting(1);
$js .= 'questions_answers['.$this->questionJSId.'] = new Array();';
$js .= 'questions_answers_correct['.$this->questionJSId.'] = "";';
$js .= 'questions_types['.$this->questionJSId.'] = \'free\';';
$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = "'.$score.'";';
$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = "0";';
$js .= $jstmpw;
return array($js, $html);
@ -678,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;
}
@ -728,6 +751,7 @@ class ScormAssessmentItem
$css .= '/*]]>*/'."\n";
$css .= '</style>';
}
return $css;
}
@ -748,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;
}
/**
@ -759,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();';
@ -841,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 '';
@ -857,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()
@ -933,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;
@ -959,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>';
}
@ -985,7 +999,7 @@ class ScormSection
* Start the itemBody
*
*/
function start_js()
private function start_js()
{
return '<script>';
}
@ -993,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";
@ -1077,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>';
}
/**
@ -1102,6 +1115,7 @@ class ScormSection
$res = $this->start_page()
. $this->start_header()
. $this->css()
. $this->globalAssets()
. $this->start_js()
. $this->common_js()
. $js
@ -1115,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>
@ -1124,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;

@ -96,7 +96,7 @@ switch ($action) {
$workInfoParent = get_work_data_by_id($workInfo['parent_id']);
$resultUpload = uploadWork($workInfoParent, $courseInfo, true, $workInfo);
if (!$resultUpload) {
echo false;
echo 'false';
break;
}
$work_table = Database:: get_course_table(

@ -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 . ']',

@ -533,7 +533,6 @@ class Template
}
// Default CSS Bootstrap
$bowerCSSFiles = [
'bootstrap-daterangepicker/daterangepicker-bs3.css',
'fontawesome/css/font-awesome.min.css',
@ -568,14 +567,20 @@ class Template
$this->assign('css_static_file_to_string', $css_file_to_string);
}
}
public function setCSSEditor() {
/**
*
*/
public function setCSSEditor()
{
$cssEditor = api_get_cdn_path(api_get_path(WEB_CSS_PATH).'editor.css');
if (is_file(api_get_path(SYS_CSS_PATH).'themes/'.$this->theme.'/editor.css')) {
$cssEditor = api_get_path(WEB_CSS_PATH).'themes/'.$this->theme.'/editor.css';
}
if (is_file(api_get_path(SYS_CSS_PATH).'themes/'.$this->theme.'/editor.css')) {
$cssEditor = api_get_path(WEB_CSS_PATH).'themes/'.$this->theme.'/editor.css';
}
$this->assign('cssEditor', $cssEditor);
}
/**
* Prepare custom CSS to be added at the very end of the <head> section
* @return void

@ -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.

@ -3630,7 +3630,7 @@ class learnpathItem
$lp_table = Database::get_course_table(TABLE_LP_MAIN);
$lp_id = intval($this->lp_id);
$sql = "SELECT * FROM $lp_table
WHERE id = '$lp_id' AND c_id = $course_id";
WHERE id = $lp_id AND c_id = $course_id";
$res = Database::query($sql);
$accumulate_scorm_time = 'false';
if (Database::num_rows($res) > 0) {

@ -11,11 +11,10 @@
* Find the SCO functions (startTimer, computeTime, etc in the second section)
* Find the Chamilo-proper functions (checkAnswers, etc in the third section)
*/
var _debug = false;
var _debug = true;
var findAPITries = 0;
var _apiHandle = null; //private variable
var errMsgLocate = "Unable to locate the LMS's API implementation"
var errMsgLocate = "Unable to locate the LMS's API implementation";
var _NoError = 0;
var _GeneralException = 101;
var _ServerBusy = 102;
@ -34,11 +33,12 @@ var _IncorrectDataType = 405;
* Using the singleton pattern to ensure there's only one API object.
* @return object The API object as given by the LMS
*/
var API = new function ()
var API = new function()
{
if (_apiHandle == null) {
_apiHandle = getAPI();
}
return _apiHandle;
}
@ -96,14 +96,14 @@ function ErrorHandler()
errDescription += "\n";
errDescription += api.LMSGetDiagnostic(null);
}
alert(errDescription);
console.log(errDescription);
} else {
var errDescription = API.LMSGetErrorString(errCode);
if (_debug) {
errDescription += "\n";
errDescription += api.LMSGetDiagnostic(null);
}
alert(errDescription);
console.log(errDescription);
}
}
return errCode;
@ -161,7 +161,6 @@ function doLMSGetValue(name)
var errDescription = API.LMSGetErrorString(errCode);
alert("LMSGetValue(" + name + ") failed. \n" + errDescription);
return "";
return value.toString();
}
}
}
@ -400,8 +399,14 @@ function checkAnswers(interrupted)
var tmpScore = 0;
var status = 'not attempted';
var scoreMax = 0;
for (var i=0; i<questions.length;i++) {
if(questions[i] != undefined && questions[i] != null){
if (_debug) {
console.log('questions_answers_correct:');
console.log(questions_answers_correct);
}
for (var i=0; i < questions.length; i++) {
if (questions[i] != undefined && questions[i] != null){
var idQuestion = questions[i];
var type = questions_types[idQuestion];
var interactionScore = 0;
@ -409,28 +414,46 @@ function checkAnswers(interrupted)
var interactionCorrectResponses = '';
var interactionType = '';
if (_debug) {
console.log('Type: ' +type);
console.log('idQuestion: ' +idQuestion);
console.log('questions_answers: ');
console.log(questions_answers[idQuestion]);
console.log('questions_answers_ponderation: ');
console.log(questions_answers_ponderation[idQuestion]);
console.log('questions_answers_correct: ');
console.log(questions_answers_correct[idQuestion]);
}
if (type == 'mcma') {
var interactionType = 'choice';
interactionType = 'choice';
var myScore = 0;
for(var j=0; j<questions_answers[idQuestion].length;j++) {
var idAnswer = questions_answers[idQuestion][j];
var answer = document.getElementById('question_'+(idQuestion)+'_multiple_'+(idAnswer));
if (answer.checked) {
interactionAnswers += idAnswer+'__|';// changed by isaac flores
myScore +=questions_answers_ponderation[idQuestion][idAnswer];
myScore += questions_answers_ponderation[idQuestion][idAnswer];
}
}
interactionScore = myScore;
scoreMax += questions_score_max[idQuestion];
if (_debug) {
console.log("Score: "+myScore);
}
} else if (type == 'mcua') {
var interactionType = 'choice';
interactionType = 'choice';
var myScore = 0;
for (var j=0; j<questions_answers[idQuestion].length;j++) {
var idAnswer = questions_answers[idQuestion][j];
var answer = document.getElementById('question_'+(idQuestion)+'_unique_'+(idAnswer));
if (answer.checked) {
interactionAnswers += idAnswer;
if (questions_answers_correct[idQuestion] == idAnswer) {
if (_debug) {
console.log("idAnswer: "+idAnswer);
console.log("questions_answers_correct: "+questions_answers_correct[idQuestion][idAnswer]);
}
if (questions_answers_correct[idQuestion][idAnswer] == idAnswer) {
if (questions_answers_ponderation[idQuestion][idAnswer]) {
myScore += questions_answers_ponderation[idQuestion][idAnswer];
} else {
@ -439,10 +462,13 @@ function checkAnswers(interrupted)
}
}
}
if (_debug) {
console.log("Score: "+myScore);
}
interactionScore = myScore;
scoreMax += questions_score_max[idQuestion];
} else if (type == 'tf') {
var interactionType = 'true-false';
interactionType = 'true-false';
var myScore = 0;
for (var j = 0; j < questions_answers[idQuestion].length; j++) {
var idAnswer = questions_answers[idQuestion][j];
@ -460,10 +486,13 @@ function checkAnswers(interrupted)
}
}
}
if (_debug) {
console.log("Score: "+myScore);
}
interactionScore = myScore;
scoreMax += questions_score_max[idQuestion];
} else if (type == 'fib') {
var interactionType = 'fill-in';
interactionType = 'fill-in';
var myScore = 0;
for (var j = 0; j < questions_answers[idQuestion].length; j++) {
var idAnswer = questions_answers[idQuestion][j];
@ -481,10 +510,13 @@ function checkAnswers(interrupted)
}
}
}
if (_debug) {
console.log("Score: "+myScore);
}
interactionScore = myScore;
scoreMax += questions_score_max[idQuestion];
} else if (type == 'matching') {
var interactionType = 'matching';
interactionType = 'matching';
var myScore = 0;
for (var j = 0; j < questions_answers[idQuestion].length; j++) {
var idAnswer = questions_answers[idQuestion][j];
@ -504,24 +536,28 @@ function checkAnswers(interrupted)
}
}
}
if (_debug) {
console.log("Score: "+myScore);
}
interactionScore = myScore;
scoreMax += questions_score_max[idQuestion];
} else if (type == 'free') {
//ignore for now as a score cannot be given
var interactionType = 'free';
interactionType = 'free';
var answer = document.getElementById('question_'+(idQuestion)+'_free');
if (answer && answer.value) {
interactionAnswers += answer.value
}
interactionScore = questions_score_max[idQuestion];
//interactionScore = questions_score_max[idQuestion];
interactionScore = 0;
scoreMax += questions_score_max[idQuestion];
//interactionAnswers = document.getElementById('question_'+(idQuestion)+'_free').value;
//correct responses work by pattern, see SCORM Runtime Env Doc
//interactionCorrectResponses += questions_answers_correct[idQuestion].toString();
} else if (type == 'hotspot') {
var interactionType = 'sequencing';
interactionType = 'sequencing';
interactionScore = 0;
//if(question_score && question_score[idQuestion]){
// interactionScore = question_score[idQuestion];
@ -533,65 +569,58 @@ function checkAnswers(interrupted)
// interactionCorrectResponses += questions_answers_correct[idQuestion][k].toString()+',';
//}
} else if (type == 'exact') {
var interactionType = 'exact';
interactionType = 'exact';
interactionScore = 0;
// not yet implemented see scorm_classes.php ScormAnswerMultipleChoice::export() function
/*
var myScore = 0;
var real_answers = new Array();
for(var j=0; j<questions_answers[idQuestion].length;j++) {
for (var j = 0; j < questions_answers[idQuestion].length; j++) {
var idAnswer = questions_answers[idQuestion][j];
var answer = document.getElementById('question_'+(idQuestion)+'_multiple_'+(idAnswer));
if (answer.checked) {
if(questions_answers_ponderation[idQuestion][idAnswer] != 0 ) {
var answer = document.getElementById('question_' + (idQuestion) + '_exact_' + (idAnswer));
if (answer.checked == true) {
interactionAnswers += idAnswer+', ';
if (questions_answers_correct[idQuestion][idAnswer] != 0) {
real_answers[j] = true;
} else {
real_answers[j] = false;
}
} else {
if(questions_answers_ponderation[idQuestion][idAnswer] != 0) {
if (questions_answers_correct[idQuestion][idAnswer] != 0) {
real_answers[j] = false;
} else {
real_answers[j] = true;
}
}
//alert(real_answers[j] +' ' + answer.checked + ' ' + questions_answers_ponderation[idQuestion][idAnswer]);
}
var final_answer = true;
for(var z=0; z<real_answers.length ;z++) {
if (!real_answers[z]) {
final_answer = false;
}
}
if (final_answer) {
for (var z = 0; z < real_answers.length; z++) {
if (real_answers[z] == false) {
final_answer = false;
}
}
interactionScore = 0;
console.log(real_answers);
if (final_answer) {
//getting only the first score where we save the weight of all the question
myScore += questions_answers_ponderation[idQuestion][1];
interactionScore = questions_answers_ponderation[idQuestion][1];
}
if (_debug) {
console.log("Score: "+interactionScore);
}
interactionScore = myScore;
//correct responses work by pattern, see SCORM Runtime Env Doc
//for(k=0;k<questions_answers_correct[idQuestion].length;k++)
//{
// interactionCorrectResponses += questions_answers_correct[idQuestion][k].toString()+',';
//}
scoreMax += questions_score_max[idQuestion];
*/
}
tmpScore += interactionScore;
doLMSSetValue('cmi.interactions.'+idQuestion+'.id','Q'+idQuestion);
doLMSSetValue('cmi.interactions.'+idQuestion+'.type',interactionType);
doLMSSetValue('cmi.interactions.'+idQuestion+'.student_response',interactionAnswers);
doLMSSetValue('cmi.interactions.'+idQuestion+'.result',interactionScore);
doLMSSetValue('cmi.interactions.'+idQuestion+'.id', 'Q'+idQuestion);
doLMSSetValue('cmi.interactions.'+idQuestion+'.type', interactionType);
doLMSSetValue('cmi.interactions.'+idQuestion+'.student_response', interactionAnswers);
doLMSSetValue('cmi.interactions.'+idQuestion+'.result', interactionScore);
}
}
doLMSSetValue('cmi.core.score.min', 0);
doLMSSetValue('cmi.core.score.max', scoreMax);
doLMSSetValue('cmi.core.score.raw', tmpScore);
//get status
var mastery_score = doLMSGetValue('cmi.student_data.mastery_score');
if (mastery_score <= 0) {
@ -602,6 +631,14 @@ function checkAnswers(interrupted)
} else {
status = 'failed';
}
if (_debug) {
console.log('student_score: ' + tmpScore);
console.log('mastery_score: ' + mastery_score);
console.log('cmi.core.score.max: ' + scoreMax);
console.log('cmi.core.lesson_status: ' + status);
}
doLMSSetValue('cmi.core.lesson_status', status);
if (interrupted && (status != 'completed') && (status != 'passed')) {

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();

@ -90,7 +90,6 @@ $form->addElement('hidden', 'sec_token', $token);
$succeed = false;
if ($form->validate()) {
if ($student_can_edit_in_session && $check) {
$values = $form->getSubmitValues();
// Process work
@ -106,21 +105,8 @@ if ($form->validate()) {
if ($is_allowed_to_edit) {
$script = 'work_list_all.php';
}
if (!$result) {
Session::write(
'message',
Display::return_message(get_lang('UploadError'), 'error')
);
header('Location: '.api_get_path(WEB_CODE_PATH).'work/'.$script.'?'.api_get_cidreq().'&id='.$work_id);
exit;
} else {
Session::write(
'message',
Display::return_message(get_lang('UplUploadSucceeded'), 'success')
);
header('Location: '.api_get_path(WEB_CODE_PATH).'work/'.$script.'?'.api_get_cidreq().'&id='.$work_id);
exit;
}
header('Location: '.api_get_path(WEB_CODE_PATH).'work/'.$script.'?'.api_get_cidreq().'&id='.$work_id);
exit;
} else {
// Bad token or can't add works
Display::addFlash(

@ -1,8 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
require_once '../inc/global.inc.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
@ -55,8 +53,6 @@ $interbreadcrumb[] = array(
$documentsAddedInWork = getAllDocumentsFromWorkToString($workId, $courseInfo);
Display :: display_header(null);
$actionsLeft = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'&origin='.$origin.'">'.
Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
@ -65,17 +61,17 @@ if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !api_is_in
$url = api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId.'&origin='.$origin;
$actionsRight = Display::url(Display::return_icon('upload_package.png', get_lang('UploadMyAssignment'), null, ICON_SIZE_MEDIUM) . get_lang('UploadMyAssignment'), $url, array('class'=>'btn-toolbar'));
}
echo Display::toolbarAction('toolbar-work', array(0 => $actionsLeft . $actionsRight));
$tpl = new Template('');
$content = Display::toolbarAction('toolbar-work', array($actionsLeft . $actionsRight));
if (!empty($my_folder_data['title'])) {
echo Display::page_subheader($my_folder_data['title']);
$content .= Display::page_subheader($my_folder_data['title']);
}
echo Session::read('message');
Session::erase('message');
if (!empty($my_folder_data['description'])) {
$contentWork = Security::remove_XSS($my_folder_data['description']);
$html = '';
$html .= Display::panel($contentWork, get_lang('Description'));
echo $html;
$content .= Display::panel($contentWork, get_lang('Description'));
}
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
@ -94,7 +90,7 @@ switch ($action) {
}
$result = getWorkDateValidationStatus($work_data);
echo $result['message'];
$content .= $result['message'];
$check_qualification = intval($my_folder_data['qualification']);
if (!api_is_invitee()) {
@ -145,20 +141,16 @@ if (!api_is_invitee()) {
);
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list&work_id='.$workId.'&type='.$type.'&'.api_get_cidreq();
?>
$content .= '
<script>
$(function() {
<?php
echo Display::grid_js('results', $url, $columns, $column_model, $extra_params);
?>
'.Display::grid_js('results', $url, $columns, $column_model, $extra_params).'
});
</script>
<?php
';
$html = '';
$tableWork = Display::grid_html('results');
$html = Display::panel($tableWork);
echo $html;
$content .= Display::panel($tableWork);
}
Display :: display_footer();
$tpl->assign('content', $content);
$tpl->display_one_col_template();

@ -259,9 +259,9 @@ class CLp
private $expiredOn;
/**
* @var \DateTime
* @var string
*
* @ORM\Column(name="accumulate_scorm_time", type="boolean", nullable=false)
* @ORM\Column(name="accumulate_scorm_time", type="string", length=5, nullable=false)
*/
private $accumulateScormTime;
@ -989,7 +989,7 @@ class CLp
}
/**
* @return boolean
* @return string
*/
public function getAccumulateScormTime()
{
@ -997,7 +997,7 @@ class CLp
}
/**
* @param boolean $accumulateScormTime
* @param string $accumulateScormTime
* @return CLp
*/
public function setAccumulateScormTime($accumulateScormTime)

Loading…
Cancel
Save