$data = $ilDB->fetchAssoc($res); if ($data['question_type_id'] == 0) { $query = "SELECT MAX(question_type_id) maxid FROM qpl_question_type"; $res = $ilDB->query($query); $data = $ilDB->fetchAssoc($res); $max = $data["maxid"] + 1; $statement = $ilDB->prepareManip("UPDATE qpl_question_type SET question_type_id = ? WHERE type_tag = ? AND plugin = ?", array("integer", "text", "integer")); $data = array($max, 'assOrderingHorizontal', 0); $affectedRows = $ilDB->execute($statement, $data); } } ?> <#1572> <?php include_once "./Services/Database/classes/class.ilDBAnalyzer.php"; $analyzer = new ilDBAnalyzer(); $pk = $analyzer->getPrimaryKeyInformation("il_object_def"); $fields = $analyzer->getFieldInformation("il_object_def"); $ilMySQLAbstraction->performAbstraction("il_object_def", $fields, true, $pk); ?> <#1573> <?php $ilMySQLAbstraction->replaceEmptyStringsWithNull("il_object_def"); ?> <#1574> <?php $ilCtrlStructureReader->getStructure(); ?> <#1575> <?php $ilMySQLAbstraction->performAbstraction("il_block_setting");
/** * Rename a table column * Use this only on aleady "abstracted" tables. * * @param string table name * @param string old column name * @param string new column name */ function renameTableColumn($a_table, $a_column, $a_new_column) { // check table name if (!$this->checkColumnName($a_new_column)) { $this->raisePearError("ilDB Error: renameTableColumn(" . $a_table . "," . $a_column . "," . $a_new_column . ")<br />" . $this->error_str); } $manager = $this->db->loadModule('Manager'); $reverse = $this->db->loadModule('Reverse'); $def = $reverse->getTableFieldDefinition($a_table, $a_column); $this->handleError($def, "renameTableColumn(" . $a_table . "," . $a_column . "," . $a_new_column . ")"); if (is_file("./Services/Database/classes/class.ilDBAnalyzer.php")) { include_once "./Services/Database/classes/class.ilDBAnalyzer.php"; } else { include_once "../Services/Database/classes/class.ilDBAnalyzer.php"; } $analyzer = new ilDBAnalyzer(); $best_alt = $analyzer->getBestDefinitionAlternative($def); $def = $def[$best_alt]; unset($def["nativetype"]); unset($def["mdb2type"]); $f["definition"] = $def; $f["name"] = $a_new_column; $changes = array("rename" => array($a_column => $f)); $r = $manager->alterTable($a_table, $changes, false); return $this->handleError($r, "renameTableColumn(" . $a_table . "," . $a_column . "," . $a_new_column . ")"); }
/** * handler for begin of element parser */ function handlerBeginTag($a_xml_parser, $a_name, $a_attribs) { global $ilDB; $this->sametag = FALSE; $this->characterbuffer = ""; $this->depth[$a_xml_parser]++; $this->path[$this->depth[$a_xml_parser]] = strtolower($a_name); $this->qti_element = $a_name; switch (strtolower($a_name)) { case "results": break; case "row": switch ($this->table) { case 'tst_active': if (!$this->user_criteria_checked) { $this->user_criteria_checked = true; if ($ilDB->tableColumnExists('usr_data', $a_attribs['user_criteria'])) { include_once './Services/Database/classes/class.ilDBAnalyzer.php'; $analyzer = new ilDBAnalyzer(); $info = $analyzer->getFieldInformation('usr_data'); $this->user_criteria_field = $a_attribs['user_criteria']; $this->user_criteria_type = $info[$a_attribs['user_criteria']]['type']; } } $usr_id = ANONYMOUS_USER_ID; if (strlen($this->user_criteria_field)) { $result = $ilDB->queryF("SELECT usr_id FROM usr_data WHERE " . $this->user_criteria_field . " = %s", array($this->user_criteria_type), array($a_attribs[$this->user_criteria_field])); if ($result->numRows()) { $row = $ilDB->fetchAssoc($result); $usr_id = $row['usr_id']; } } $next_id = $ilDB->nextId('tst_active'); $affectedRows = $ilDB->manipulateF("INSERT INTO tst_active (active_id, user_fi, anonymous_id, test_fi, lastindex, tries, submitted, submittimestamp, tstamp, importname) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", array('integer', 'integer', 'text', 'integer', 'integer', 'integer', 'integer', 'timestamp', 'integer', 'text'), array($next_id, $usr_id, strlen($a_attribs['anonymous_id']) ? $a_attribs['anonymous_id'] : NULL, $this->tst_obj->getTestId(), $a_attribs['lastindex'], $a_attribs['tries'], $a_attribs['submitted'], strlen($a_attribs['submittimestamp']) ? $a_attribs['submittimestamp'] : NULL, $a_attribs['tstamp'], $a_attribs['fullname'])); $this->active_id_mapping[$a_attribs['active_id']] = $next_id; break; case 'tst_test_question': $questions = $this->tst_obj->getQuestions(); $id = $questions[$a_attribs['sequence']]; if ($id > 0) { $this->question_id_mapping[$a_attribs['question_fi']] = $id; } else { $this->question_id_mapping[$a_attribs['question_fi']] = $a_attribs['question_fi']; global $ilLog; $ilLog->write("Error: Could not find question for sequence " . $a_attribs['sequence'] . " of test id " . $this->tst_obj->getTestId()); } break; case 'tst_pass_result': $affectedRows = $ilDB->manipulateF("INSERT INTO tst_pass_result (active_fi, pass, points, maxpoints, questioncount, answeredquestions, workingtime, tstamp) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)", array('integer', 'integer', 'float', 'float', 'integer', 'integer', 'integer', 'integer'), array($this->active_id_mapping[$a_attribs['active_fi']], strlen($a_attribs['pass']) ? $a_attribs['pass'] : 0, $a_attribs["points"] ? $a_attribs["points"] : 0, $a_attribs["maxpoints"] ? $a_attribs["maxpoints"] : 0, $a_attribs["questioncount"], $a_attribs["answeredquestions"], $a_attribs["workingtime"] ? $a_attribs["workingtime"] : 0, $a_attribs["tstamp"])); break; case 'tst_result_cache': $affectedRows = $ilDB->manipulateF("INSERT INTO tst_result_cache (active_fi, pass, max_points, reached_points, mark_short, mark_official, passed, failed, tstamp) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s)", array('integer', 'integer', 'float', 'float', 'text', 'text', 'integer', 'integer', 'integer'), array($this->active_id_mapping[$a_attribs['active_fi']], strlen($a_attribs['pass']) ? $a_attribs['pass'] : 0, $a_attribs["max_points"] ? $a_attribs["max_points"] : 0, $a_attribs["reached_points"] ? $a_attribs["reached_points"] : 0, strlen($a_attribs["mark_short"]) ? $a_attribs["mark_short"] : " ", strlen($a_attribs["mark_official"]) ? $a_attribs["mark_official"] : " ", $a_attribs["passed"] ? 1 : 0, $a_attribs["failed"] ? 1 : 0, $a_attribs["tstamp"])); break; case 'tst_sequence': $affectedRows = $ilDB->insert("tst_sequence", array("active_fi" => array("integer", $this->active_id_mapping[$a_attribs['active_fi']]), "pass" => array("integer", $a_attribs['pass']), "sequence" => array("clob", $a_attribs['sequence']), "postponed" => array("text", strlen($a_attribs['postponed']) ? $a_attribs['postponed'] : NULL), "hidden" => array("text", strlen($a_attribs['hidden']) ? $a_attribs['hidden'] : NULL), "tstamp" => array("integer", $a_attribs['tstamp']))); break; case 'tst_solutions': $next_id = $ilDB->nextId('tst_solutions'); $affectedRows = $ilDB->insert("tst_solutions", array("solution_id" => array("integer", $next_id), "active_fi" => array("integer", $this->active_id_mapping[$a_attribs['active_fi']]), "question_fi" => array("integer", $this->question_id_mapping[$a_attribs['question_fi']]), "value1" => array("clob", strlen($a_attribs['value1']) ? $a_attribs['value1'] : NULL), "value2" => array("clob", strlen($a_attribs['value2']) ? $a_attribs['value2'] : NULL), "pass" => array("integer", $a_attribs['pass']), "tstamp" => array("integer", $a_attribs['tstamp']))); break; case 'tst_test_result': $next_id = $ilDB->nextId('tst_test_result'); $affectedRows = $ilDB->manipulateF("INSERT INTO tst_test_result (test_result_id, active_fi, question_fi, points, pass, manual, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)", array('integer', 'integer', 'integer', 'float', 'integer', 'integer', 'integer'), array($next_id, $this->active_id_mapping[$a_attribs['active_fi']], $this->question_id_mapping[$a_attribs['question_fi']], $a_attribs['points'], $a_attribs['pass'], strlen($a_attribs['manual']) ? $a_attribs['manual'] : 0, $a_attribs['tstamp'])); break; case 'tst_times': $next_id = $ilDB->nextId('tst_times'); $affectedRows = $ilDB->manipulateF("INSERT INTO tst_times (times_id, active_fi, started, finished, pass, tstamp) VALUES (%s, %s, %s, %s, %s, %s)", array('integer', 'integer', 'timestamp', 'timestamp', 'integer', 'integer'), array($next_id, $this->active_id_mapping[$a_attribs['active_fi']], $a_attribs['started'], $a_attribs['finished'], $a_attribs['pass'], $a_attribs['tstamp'])); break; } break; default: $this->table = $a_name; break; } }
/** * get the type of the value column in the database * * @return string 'text' or 'clob' */ public static function _getValueType() { include_once './Services/Database/classes/class.ilDBAnalyzer.php'; $analyzer = new ilDBAnalyzer(); $info = $analyzer->getFieldInformation('settings'); if ($info['value']['type'] == 'clob') { return 'clob'; } else { return 'text'; } }
/** * Checks if a unique constraint exists based on the fields of the unique constraint (not the name) * * @param string $a_table table name * @param array $a_fields array of field names (strings) * @return bool false if no unique constraint with the given fields exists */ function uniqueConstraintExists($a_table, $a_fields) { if (is_file("./Services/Database/classes/class.ilDBAnalyzer.php")) { include_once "./Services/Database/classes/class.ilDBAnalyzer.php"; } else { include_once "../Services/Database/classes/class.ilDBAnalyzer.php"; } $analyzer = new ilDBAnalyzer(); $cons = $analyzer->getConstraintsInformation($a_table); foreach ($cons as $c) { if ($c["type"] == "unique" && count($a_fields) == count($c["fields"])) { $all_in = true; foreach ($a_fields as $f) { if (!isset($c["fields"][$f])) { $all_in = false; } } if ($all_in) { return true; } } } return false; }