diff --git a/main/exercise/export/scorm/ScormAnswerFillInBlanks.php b/main/exercise/export/scorm/ScormAnswerFillInBlanks.php
new file mode 100644
index 0000000000..c1119b5d53
--- /dev/null
+++ b/main/exercise/export/scorm/ScormAnswerFillInBlanks.php
@@ -0,0 +1,92 @@
+
';
+ // get all enclosed answers
+ $blankList = [];
+ foreach ($this->answer as $i => $answer) {
+ $blankList[] = '['.$answer.']';
+ }
+
+ // splits text and weightings that are joined with the character '::'
+ list($answer, $weight) = explode('::', $answer);
+
+ $switchable = explode('@', $weight);
+ $isSetSwitchable = false;
+ if (isset($switchable[1]) && $switchable[1] == 1) {
+ $isSetSwitchable = true;
+ }
+
+ $weights = explode(',', $switchable[0]);
+ // because [] is parsed here we follow this procedure:
+ // 1. find everything between the [ and ] tags
+ $i = 1;
+ $jstmp = '';
+ $jstmpc = '';
+ $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
+ $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
+ $startlocations = api_strpos($answer, '[');
+ $endlocations = api_strpos($answer, ']');
+ while ($startlocations !== false && $endlocations !== false) {
+ $texstring = api_substr($answer, $startlocations, ($endlocations - $startlocations) + 1);
+ $replaceText = '';
+ $answer = api_substr_replace(
+ $answer,
+ $replaceText,
+ $startlocations,
+ ($endlocations - $startlocations) + 1
+ );
+ $jstmp .= $i.',';
+ if (!empty($texstring)) {
+ $sub = api_substr($texstring, 1, -1);
+ if (!empty($sub)) {
+ $jstmpc .= "'".api_htmlentities($sub, ENT_QUOTES, $charset)."',";
+ }
+ }
+ $my_weight = explode('@', $weights[$i - 1]);
+ if (count($my_weight) == 2) {
+ $weight_db = $my_weight[0];
+ } else {
+ $weight_db = $my_weight[0];
+ }
+ $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n";
+ $i++;
+ $startlocations = api_strpos($answer, '[');
+ $endlocations = api_strpos($answer, ']');
+ }
+
+ $html .= '
+ |
+ '.$answer.'
+ |
+ | ';
+ $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp, 0, -1).');'."\n";
+ $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc, 0, -1).');'."\n";
+ $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n";
+ $js .= $jstmpw;
+
+ return [$js, $html];
+ }
+}
diff --git a/main/exercise/export/scorm/scorm_classes.php b/main/exercise/export/scorm/scorm_classes.php
index 990776f0d8..4cf1b5d7d9 100755
--- a/main/exercise/export/scorm/scorm_classes.php
+++ b/main/exercise/export/scorm/scorm_classes.php
@@ -1,88 +1,7 @@
';
- // get all enclosed answers
- $blankList = [];
- foreach ($this->answer as $i => $answer) {
- $blankList[] = '['.$answer.']';
- }
-
- // splits text and weightings that are joined with the character '::'
- list($answer, $weight) = explode('::', $answer);
- $weights = explode(',', $weight);
- // because [] is parsed here we follow this procedure:
- // 1. find everything between the [ and ] tags
- $i = 1;
- $jstmp = '';
- $jstmpc = '';
- $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
- $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
- $startlocations = api_strpos($answer, '[');
- $endlocations = api_strpos($answer, ']');
- while ($startlocations !== false && $endlocations !== false) {
- $texstring = api_substr($answer, $startlocations, ($endlocations - $startlocations) + 1);
- $replaceText = '';
- $answer = api_substr_replace(
- $answer,
- $replaceText,
- $startlocations,
- ($endlocations - $startlocations) + 1
- );
- $jstmp .= $i.',';
- if (!empty($texstring)) {
- $sub = api_substr($texstring, 1, -1);
- if (!empty($sub)) {
- $jstmpc .= "'".api_htmlentities($sub, ENT_QUOTES, $charset)."',";
- }
- }
- $my_weight = explode('@', $weights[$i - 1]);
- if (count($my_weight) == 2) {
- $weight_db = $my_weight[0];
- } else {
- $weight_db = $my_weight[0];
- }
- $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n";
- $i++;
- $startlocations = api_strpos($answer, '[');
- $endlocations = api_strpos($answer, ']');
- }
- $html .= '
- |
- '.$answer.'
- |
- | ';
- $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp, 0, -1).');'."\n";
- $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc, 0, -1).');'."\n";
- $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n";
- $js .= $jstmpw;
-
- return [$js, $html];
- }
-}
/**
* This class handles the SCORM export of free-answer questions.