Esempio n. 1
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 sendCodesMailObject()
 {
     global $ilUser;
     $this->parent_gui->handleWriteAccess();
     $this->setCodesSubtabs();
     include_once "./Modules/Survey/classes/forms/FormMailCodesGUI.php";
     $form_gui = new FormMailCodesGUI($this);
     if ($form_gui->checkInput()) {
         $code_exists = strpos($_POST['m_message'], '[code]') !== FALSE;
         if (!$code_exists) {
             if (!$code_exists) {
                 ilUtil::sendFailure($this->lng->txt('please_enter_mail_code'));
             }
             $form_gui->setValuesByPost();
         } else {
             if ($_POST['savemessage'] == 1) {
                 global $ilUser;
                 $title = strlen($_POST['savemessagetitle']) ? $_POST['savemessagetitle'] : ilStr::substr($_POST['m_message'], 0, 40) . '...';
                 $this->object->saveUserSettings($ilUser->getId(), 'savemessage', $title, $_POST['m_message']);
             }
             $lang = $ilUser->getPref("survey_code_language");
             if (!$lang) {
                 $lang = $this->lng->getDefaultLanguage();
             }
             $this->object->sendCodes($_POST['m_notsent'], $_POST['m_subject'], $_POST['m_message'], $lang);
             ilUtil::sendSuccess($this->lng->txt('mail_sent'), true);
             $this->ctrl->redirect($this, 'mailCodes');
         }
     } else {
         $form_gui->setValuesByPost();
     }
     $this->tpl->setVariable("ADM_CONTENT", $form_gui->getHTML());
 }
 /**
  * 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());
     include_once "./Services/Utilities/classes/class.ilStr.php";
     $maxlen = 75;
     if (strlen($questiontext) > $maxlen + 3) {
         $questiontext = ilStr::substr($questiontext, 0, $maxlen) . "...";
     }
     $result = array();
     $row = array('counter' => $counter, 'title' => $counter . '. ' . $this->getTitle(), 'question' => $questiontext, 'users_answered' => $cumulated['TOTAL']['USERS_ANSWERED'], 'users_skipped' => $cumulated['TOTAL']['USERS_SKIPPED'], 'question_type' => $this->lng->txt($cumulated['TOTAL']['QUESTION_TYPE']), 'mode' => $cumulated['TOTAL']['MODE'], 'mode_nr_of_selections' => $cumulated['TOTAL']['MODE_NR_OF_SELECTIONS'], 'median' => $cumulated['TOTAL']['MEDIAN'], 'arithmetic_mean' => $cumulated['TOTAL']['ARITHMETIC_MEAN']);
     array_push($result, $row);
     $maxlen -= 3;
     foreach ($cumulated as $key => $value) {
         if (is_numeric($key)) {
             if (strlen($value['ROW']) > $maxlen + 3) {
                 $value['ROW'] = ilStr::substr($value['ROW'], 0, $maxlen) . "...";
             }
             $row = array('title' => '', 'question' => $key + 1 . ". " . $value['ROW'], 'users_answered' => $value['USERS_ANSWERED'], 'users_skipped' => $value['USERS_SKIPPED'], 'question_type' => '', 'mode' => $value["MODE"], 'mode_nr_of_selections' => $value["MODE_NR_OF_SELECTIONS"], 'median' => $value["MEDIAN"], 'arithmetic_mean' => $value["ARITHMETIC_MEAN"]);
             array_push($result, $row);
         }
     }
     return $result;
 }
Esempio n. 4
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;
 }
 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");
 }