Esempio n. 1
0
 /**
  * Creates a the cumulated results data for the question
  *
  * @return array Data
  */
 public function getCumulatedResultData($survey_id, $counter, $finished_ids)
 {
     $cumulated =& $this->calculateCumulatedResults($survey_id, $finished_ids);
     $questiontext = preg_replace("/\\<[^>]+?>/ims", "", $this->getQuestiontext());
     $maxlen = 75;
     include_once "./Services/Utilities/classes/class.ilStr.php";
     if (ilStr::strlen($questiontext) > $maxlen + 3) {
         $questiontext = ilStr::substr($questiontext, 0, $maxlen) . "...";
     }
     $result = array('counter' => $counter, 'title' => $counter . '. ' . $this->getTitle(), 'question' => $questiontext, 'users_answered' => $cumulated['USERS_ANSWERED'], 'users_skipped' => $cumulated['USERS_SKIPPED'], 'question_type' => $this->lng->txt($cumulated["QUESTION_TYPE"]), 'mode' => $cumulated["MODE"], 'mode_nr_of_selections' => $cumulated["MODE_NR_OF_SELECTIONS"], 'median' => $cumulated["MEDIAN"], 'arithmetic_mean' => $cumulated["ARITHMETIC_MEAN"]);
     return $result;
 }
Esempio n. 2
0
 public function createErrorTextExport($selections = null)
 {
     $counter = 0;
     $errorcounter = 0;
     include_once "./Services/Utilities/classes/class.ilStr.php";
     if (!is_array($selections)) {
         $selections = array();
     }
     $textarray = preg_split("/[\n\r]+/", $this->getErrorText());
     foreach ($textarray as $textidx => $text) {
         $items = preg_split("/\\s+/", $text);
         foreach ($items as $idx => $item) {
             if (($posHash = strpos($item, '#')) === 0 || ($posOpeningBrackets = strpos($item, '((')) === 0 || ($posClosingBrackets = strpos($item, '))')) !== false) {
                 /* (Word|Passage)-Marking delimiter found. */
                 if ($posHash !== false) {
                     $item = ilStr::substr($item, 1, ilStr::strlen($item) - 1);
                 } elseif ($posOpeningBrackets !== false) {
                     $item = ilStr::substr($item, 2, ilStr::strlen($item) - 2);
                     /* Sometimes a closing bracket group needs
                        to be removed as well. */
                     if (strpos($item, '))') !== false) {
                         $item = ilStr::substr($item, 0, ilStr::strlen($item) - 2);
                     }
                 } else {
                     $appendComma = "";
                     if ($item[$posClosingBrackets + 2] == ',') {
                         $appendComma = ",";
                     }
                     $item = ilStr::substr($item, 0, $posClosingBrackets) . $appendComma;
                 }
             }
             $word = "";
             if (in_array($counter, $selections)) {
                 $word .= '#';
             }
             $word .= ilUtil::prepareFormOutput($item);
             if (in_array($counter, $selections)) {
                 $word .= '#';
             }
             $items[$idx] = $word;
             $counter++;
         }
         $textarray[$textidx] = join($items, " ");
     }
     return join($textarray, "\n");
 }
 public function createErrorTextExport($selections = null)
 {
     $counter = 0;
     $errorcounter = 0;
     include_once "./Services/Utilities/classes/class.ilStr.php";
     if (!is_array($selections)) {
         $selections = array();
     }
     $textarray = preg_split("/[\n\r]+/", $this->getErrorText());
     foreach ($textarray as $textidx => $text) {
         $items = preg_split("/\\s+/", $text);
         foreach ($items as $idx => $item) {
             if (strpos($item, '#') === 0) {
                 $item = ilStr::substr($item, 1, ilStr::strlen($item));
                 if ($correct_solution) {
                     $errorobject = $this->errordata[$errorcounter];
                     if (is_object($errorobject)) {
                         $item = $errorobject->text_correct;
                     }
                     $errorcounter++;
                 }
             }
             $word = "";
             if (in_array($counter, $selections)) {
                 $word .= '#';
             }
             $word .= ilUtil::prepareFormOutput($item);
             if (in_array($counter, $selections)) {
                 $word .= '#';
             }
             $items[$idx] = $word;
             $counter++;
         }
         $textarray[$textidx] = join($items, " ");
     }
     return join($textarray, "\n");
 }