Example #1
0
             return $this->importNubis();
         case IMPORT_TYPE_MMIC:
             return $this->importMMIC();
         case IMPORT_TYPE_BLAISE:
             break;
     }
 }
 function importNubis()
 {
     $arr = $_FILES[SETTING_IMPORT_TEXT];
     if (sizeof($arr) == 0) {
         return Language::messageImportNoFile();
     }
     $name = $arr["name"];
     if (!endsWith($name, EXPORT_FILE_NUBIS)) {
         return Language::messageImportInvalidFile();
     }
     $str = file_get_contents($arr["tmp_name"]);
     if ($str == "") {
         return Language::messageImportInvalidFile();
     }
     $urid = $_SESSION['URID'];
     $user = new User($urid);
     if (loadvar(SETTING_IMPORT_AS) == IMPORT_TARGET_ADD) {
         $surveys = new Surveys();
         $this->addtosuid = $surveys->getMaximumSuid() + 1;
     } else {
         if (loadvar(SETTING_IMPORT_AS) == IMPORT_TARGET_REPLACE) {
             $this->addtosuid = 1;
             /* delete existing content */
             $tables = Common::surveyTables();
             foreach ($tables as $table) {
                 $query = "delete from " . Config::dbSurvey() . $table;
                 $this->db->executeQuery($query);
             }
             /* delete existing data */
             $tables = Common::surveyDataTables();
             foreach ($tables as $table) {
                 if ($table == "_actions") {
                     $query = "delete from " . Config::dbSurvey() . $table . " where suid != ''";
                 } else {
                     $query = "delete from " . Config::dbSurvey() . $table;
                 }
                 $this->db->executeQuery($query);
             }
             /* delete test data */
             $tables = Common::surveyTestDataTables();
             foreach ($tables as $table) {
                 if ($table == "_actions") {
                     $query = "delete from " . Config::dbSurvey() . $table . " where suid != ''";
                 } else {
                     $query = "delete from " . Config::dbSurvey() . $table;
                 }
                 $this->db->executeQuery($query);
             }
         }
     }
     // add suid and urid
     $str = str_ireplace(EXPORT_PLACEHOLDER_URID, $urid, $str);
     $str = str_ireplace(EXPORT_PLACEHOLDER_SUID, $this->addtosuid, $str);
     $queries = explode("\r\n", $str);
     $tables = Common::surveyExportTables();
     foreach ($queries as $q) {
         $q = explode(EXPORT_DELIMITER, trim($q));
         if (sizeof($q) != 3) {
             continue;
         }
         if (!inArray($q[0], $tables)) {
             continue;
         }
         //echo $q[1];
         $fields = sizeof(explode(",", $q[1]));
         $f = "";
         for ($i = 0; $i < $fields; $i++) {
             if ($f != "") {
                 $f .= ",";
             }
             $f .= "?";
         }
         $query = IMPORT_STATEMENT_INSERT . ' ' . Config::dbSurvey() . $q[0] . " (" . $q[1] . ") " . IMPORT_STATEMENT_INSERT_VALUES . " (" . $f . ")";
         $bp = new BindParam();
         $fields2 = sizeof(explode(",", $q[2]));
         if ($fields != $fields2) {
             continue;
             // mismatch column count and value count
         }
         $it = explode(",", $q[2]);
         for ($i = 0; $i < $fields2; $i++) {
             $val =& prepareImportString($it[$i]);
             $bp->add(MYSQL_BINDING_STRING, $val);
             //echo 'adding: ' . $val . '----';
         }
         //echo print_r($bp->get()) . "<br/>";
         $this->db->executeBoundQuery($query, $bp->get());
     }
     // prepare
     set_time_limit(0);
     // compile
     $survey = new Survey($this->addtosuid);
     $compiler = new Compiler($this->addtosuid, getSurveyVersion($survey));
     // sections
     $sections = $survey->getSections();
     foreach ($sections as $section) {
         $mess = $compiler->generateEngine($section->getSeid());
     }
     $mess = $compiler->generateSections();
     $mess = $compiler->generateVariableDescriptives();
     $mess = $compiler->generateTypes();
     $mess = $compiler->generateGetFills();
     $mess = $compiler->generateSetFills();
     $mess = $compiler->generateInlineFields();
     $mess = $compiler->generateGroups();
     $user = new User($_SESSION['URID']);
     $mods = explode("~", $survey->getAllowedModes());
Example #2
0
 function showCompileRes()
 {
     /* update last page */
     $_SESSION['LASTPAGE'] = substr($_SESSION['LASTPAGE'], 0, strripos($_SESSION['LASTPAGE'], "res"));
     $displaySysAdmin = new DisplaySysAdmin();
     $compile = loadvar("compile");
     $components = loadvar("components");
     if ($compile == "") {
         return $displaySysAdmin->showCompile($displaySysAdmin->displayWarning(Language::messageToolsCompileSelectSurvey()));
     }
     if ($components == "") {
         return $displaySysAdmin->showCompile($displaySysAdmin->displayWarning(Language::messageToolsCompileSelectComponent()));
     }
     set_time_limit(0);
     $messages = array();
     foreach ($compile as $comp) {
         $survey = new Survey($comp);
         $compiler = new Compiler($comp, getSurveyVersion($survey));
         if (inArray(SURVEY_COMPONENT_SECTION, $components)) {
             $sections = $survey->getSections();
             foreach ($sections as $section) {
                 $mess = $compiler->generateEngine($section->getSeid());
                 if (sizeof($mess) > 0) {
                     $messages[] = $mess;
                 }
                 $mess = $compiler->generateProgressBar($section->getSeid());
                 if (sizeof($mess) > 0) {
                     $messages[] = $mess;
                 }
             }
             $mess = $compiler->generateSections();
             if (sizeof($mess) > 0) {
                 $messages[] = $mess;
             }
         }
         if (inArray(SURVEY_COMPONENT_VARIABLE, $components)) {
             $mess = $compiler->generateVariableDescriptives();
             if (sizeof($mess) > 0) {
                 $messages[] = $mess;
             }
         }
         if (inArray(SURVEY_COMPONENT_TYPE, $components)) {
             $mess = $compiler->generateTypes();
             if (sizeof($mess) > 0) {
                 $messages[] = $mess;
             }
         }
         if (inArray(SURVEY_COMPONENT_SETTING, $components)) {
             $mess = $compiler->generateSurveySettings();
             if (sizeof($mess) > 0) {
                 $messages[] = $mess;
             }
         }
         if (inArray(SURVEY_COMPONENT_FILL, $components)) {
             $mess = $compiler->generateGetFills();
             if (sizeof($mess) > 0) {
                 $messages[] = $mess;
             }
             $mess = $compiler->generateSetFills();
             if (sizeof($mess) > 0) {
                 $messages[] = $mess;
             }
         }
         if (inArray(SURVEY_COMPONENT_INLINEFIELDS, $components)) {
             $mess = $compiler->generateInlineFields();
             if (sizeof($mess) > 0) {
                 $messages[] = $mess;
             }
         }
         if (inArray(SURVEY_COMPONENT_GROUP, $components)) {
             $mess = $compiler->generateGroups();
             if (sizeof($mess) > 0) {
                 $messages[] = $mess;
             }
         }
     }
     if (sizeof($messages) == 0) {
         $content = $displaySysAdmin->displaySuccess(Language::messageToolsCompileOk());
     } else {
         $content = $displaySysAdmin->displayError(Language::messageToolsCompileNotOk());
     }
     return $displaySysAdmin->showCompile($content);
 }
Example #3
0
 function showEditVariableRes($suid, $vsid)
 {
     $survey = new Survey($suid);
     $var = $survey->getVariableDescriptive($vsid);
     $texttype = loadvar("texttype");
     $value = loadvarAllowHTML("text");
     switch ($texttype) {
         case SETTING_QUESTION:
             $var->setQuestion($value);
             break;
         case SETTING_PRETEXT:
             $var->setPretext($value);
             break;
         case SETTING_POSTTEXT:
             $var->setPostText($value);
             break;
         case SETTING_OPTIONS:
             $code = loadvar("answercode");
             $current = explode("\r\n", $var->getOptionsText());
             foreach ($current as $k => $c) {
                 if (startsWith($c, $code . " ")) {
                     $current[$k] = $code . ' ' . $value;
                     break;
                 }
             }
             $var->setOptionsText(implode("\r\n", $current));
         default:
             break;
     }
     $var->save();
     $compiler = new Compiler($suid, getSurveyVersion($survey));
     $mess = $compiler->generateVariableDescriptives(array($var));
     $mess = $compiler->generateGetFills(array($var));
     $mess = $compiler->generateInlineFields(array($var));
 }
Example #4
0
 function showTranslateTypeAssistanceRes()
 {
     $displayTranslator = new DisplayTranslator();
     $survey = new Survey($_SESSION['SUID']);
     $tyd = getFromSessionParams('tyd');
     $type = $survey->getType($tyd);
     $_SESSION['TYD'] = $tyd;
     $type->setPreText(loadvarAllowHTML(SETTING_PRETEXT));
     $type->setPostText(loadvarAllowHTML(SETTING_POSTTEXT));
     $type->setHoverText(loadvarAllowHTML(SETTING_HOVERTEXT));
     if (loadvar(SETTING_EMPTY_MESSAGE) != "") {
         $type->setEmptyMessage(loadvarAllowHTML(SETTING_EMPTY_MESSAGE));
     }
     $t = $type->getAnswerType();
     switch ($t) {
         case ANSWER_TYPE_STRING:
             /* fall through */
         /* fall through */
         case ANSWER_TYPE_OPEN:
             $type->setErrorMessageMinimumLength(loadvarAllowHTML(SETTING_ERROR_MESSAGE_MINIMUM_LENGTH));
             $type->setErrorMessageMaximumLength(loadvarAllowHTML(SETTING_ERROR_MESSAGE_MAXIMUM_LENGTH));
             $type->setErrorMessageMinimumWords(loadvarAllowHTML(SETTING_ERROR_MESSAGE_MINIMUM_WORDS));
             $type->setErrorMessageMaximumWords(loadvarAllowHTML(SETTING_ERROR_MESSAGE_MAXIMUM_WORDS));
             $type->setErrorMessagePattern(loadvarAllowHTML(SETTING_ERROR_MESSAGE_PATTERN));
             break;
         case ANSWER_TYPE_DOUBLE:
             $type->setErrorMessageDouble(loadvarAllowHTML(SETTING_ERROR_MESSAGE_DOUBLE));
             break;
         case ANSWER_TYPE_INTEGER:
             $type->setErrorMessageInteger(loadvarAllowHTML(SETTING_ERROR_MESSAGE_INTEGER));
             break;
         case ANSWER_TYPE_ENUMERATED:
             $type->setErrorMessageInlineAnswered(loadvarAllowHTML(SETTING_ERROR_MESSAGE_INLINE_ANSWERED));
             $type->setErrorMessageInlineExactRequired(loadvarAllowHTML(SETTING_ERROR_MESSAGE_INLINE_EXACT_REQUIRED));
             $type->setErrorMessageInlineExclusive(loadvarAllowHTML(SETTING_ERROR_MESSAGE_INLINE_EXCLUSIVE));
             $type->setErrorMessageInlineInclusive(loadvarAllowHTML(SETTING_ERROR_MESSAGE_INLINE_INCLUSIVE));
             $type->setErrorMessageInlineMinimumRequired(loadvarAllowHTML(SETTING_ERROR_MESSAGE_INLINE_MINIMUM_REQUIRED));
             $type->setErrorMessageInlineMaximumRequired(loadvarAllowHTML(SETTING_ERROR_MESSAGE_INLINE_MAXIMUM_REQUIRED));
             break;
         case ANSWER_TYPE_SETOFENUMERATED:
             $type->setErrorMessageInlineAnswered(loadvarAllowHTML(SETTING_ERROR_MESSAGE_INLINE_ANSWERED));
             $type->setErrorMessageInlineExactRequired(loadvarAllowHTML(SETTING_ERROR_MESSAGE_INLINE_EXACT_REQUIRED));
             $type->setErrorMessageInlineExclusive(loadvarAllowHTML(SETTING_ERROR_MESSAGE_INLINE_EXCLUSIVE));
             $type->setErrorMessageInlineInclusive(loadvarAllowHTML(SETTING_ERROR_MESSAGE_INLINE_INCLUSIVE));
             $type->setErrorMessageInlineMinimumRequired(loadvarAllowHTML(SETTING_ERROR_MESSAGE_INLINE_MINIMUM_REQUIRED));
             $type->setErrorMessageInlineMaximumRequired(loadvarAllowHTML(SETTING_ERROR_MESSAGE_INLINE_MAXIMUM_REQUIRED));
             /* fall through */
         /* fall through */
         case ANSWER_TYPE_MULTIDROPDOWN:
             $type->setErrorMessageSelectMinimum(loadvarAllowHTML(SETTING_ERROR_MESSAGE_MINIMUM_SELECT));
             $type->setErrorMessageSelectMaximum(loadvarAllowHTML(SETTING_ERROR_MESSAGE_MAXIMUM_SELECT));
             $type->setErrorMessageSelectExact(loadvarAllowHTML(SETTING_ERROR_MESSAGE_EXACT_SELECT));
             $type->setErrorMessageSelectInvalidSubset(loadvarAllowHTML(SETTING_ERROR_MESSAGE_INVALID_SUB_SELECT));
             $type->setErrorMessageSelectInvalidSet(loadvarAllowHTML(SETTING_ERROR_MESSAGE_INVALID_SELECT));
             break;
         case ANSWER_TYPE_RANGE:
             /* fall through */
         /* fall through */
         case ANSWER_TYPE_SLIDER:
             $type->setErrorMessageRange(loadvarAllowHTML(SETTING_ERROR_MESSAGE_RANGE));
             break;
         case ANSWER_TYPE_CALENDAR:
             $type->setErrorMessageMaximumCalendar(loadvarAllowHTML(SETTING_ERROR_MESSAGE_MAXIMUM_CALENDAR));
             break;
     }
     $content = $displayTranslator->displaySuccess(Language::messageTypeChanged($type->getName()));
     $type->save();
     /* compile */
     $compiler = new Compiler($_SESSION['SUID'], getSurveyVersion($survey));
     $mess = $compiler->generateTypes(array($type));
     $vars = $survey->getVariableDescriptivesOfType($tyd);
     $mess = $compiler->generateVariableDescriptives($vars);
     $mess = $compiler->generateGetFills($vars);
     $mess = $compiler->generateInlineFields($vars);
     /* update last page */
     $_SESSION['LASTPAGE'] = substr($_SESSION['LASTPAGE'], 0, strripos($_SESSION['LASTPAGE'], "res"));
     /* return result */
     return $displayTranslator->showTranslateType($_SESSION['TYD'], $content);
 }