本文整理汇总了PHP中assQuestion::saveToDb方法的典型用法代码示例。如果您正苦于以下问题:PHP assQuestion::saveToDb方法的具体用法?PHP assQuestion::saveToDb怎么用?PHP assQuestion::saveToDb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类assQuestion
的用法示例。
在下文中一共展示了assQuestion::saveToDb方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveToDb
/**
* Saves a the object to the database
*
*/
public function saveToDb($original_id = "")
{
$this->saveQuestionDataToDb($original_id);
$this->saveAdditionalQuestionDataToDb();
$this->saveAnswerSpecificDataToDb();
parent::saveToDb();
}
示例2: saveToDb
/**
* Saves a assFileUpload object to a database
*
*/
public function saveToDb($original_id = "")
{
global $ilDB;
$this->saveQuestionDataToDb($original_id);
// save additional data
$affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s", array("integer"), array($this->getId()));
$affectedRows = $ilDB->manipulateF("INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, maxsize, allowedextensions, compl_by_submission) VALUES (%s, %s, %s, %s)", array("integer", "float", "text", "integer"), array($this->getId(), strlen($this->getMaxSize()) ? $this->getMaxSize() : NULL, strlen($this->getAllowedExtensions()) ? $this->getAllowedExtensions() : NULL, (int) $this->isCompletionBySubmissionEnabled()));
parent::saveToDb();
}
示例3: saveToDb
/**
* Saves a assOrderingHorizontal object to a database
*
*/
public function saveToDb($original_id = "")
{
global $ilDB;
$this->saveQuestionDataToDb($original_id);
// save additional data
$affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s", array("integer"), array($this->getId()));
$affectedRows = $ilDB->manipulateF("INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, ordertext, textsize) VALUES (%s, %s, %s)", array("integer", "text", "float"), array($this->getId(), $this->getOrderText(), $this->getTextSize() < 10 ? NULL : $this->getTextSize()));
parent::saveToDb();
}
示例4: saveToDb
/**
* Saves a the object to the database
*
*/
public function saveToDb($original_id = "")
{
global $ilDB;
$this->saveQuestionDataToDb($original_id);
// save additional data
$affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s", array("integer"), array($this->getId()));
$affectedRows = $ilDB->manipulateF("INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, errortext, textsize, points_wrong) VALUES (%s, %s, %s, %s)", array("integer", "text", "float", "float"), array($this->getId(), $this->getErrorText(), $this->getTextSize(), $this->getPointsWrong()));
$affectedRows = $ilDB->manipulateF("DELETE FROM qpl_a_errortext WHERE question_fi = %s", array('integer'), array($this->getId()));
$sequence = 0;
foreach ($this->errordata as $object) {
$next_id = $ilDB->nextId('qpl_a_errortext');
$affectedRows = $ilDB->manipulateF("INSERT INTO qpl_a_errortext (answer_id, question_fi, text_wrong, text_correct, points, sequence) VALUES (%s, %s, %s, %s, %s, %s)", array('integer', 'integer', 'text', 'text', 'float', 'integer'), array($next_id, $this->getId(), $object->text_wrong, $object->text_correct, $object->points, $sequence++));
}
parent::saveToDb();
}
示例5: saveToDb
/**
* Saves a assFlashQuestion object to a database
*
* @access public
*/
function saveToDb($original_id = "")
{
global $ilDB, $ilLog;
$this->saveQuestionDataToDb($original_id);
// save additional data
$affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s", array("integer"), array($this->getId()));
$affectedRows = $ilDB->manipulateF("INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, width, height, applet, params) VALUES (%s, %s, %s, %s, %s)", array("integer", "integer", "integer", "text", "text"), array($this->getId(), strlen($this->getWidth()) ? $this->getWidth() : 550, strlen($this->getHeight()) ? $this->getHeight() : 400, $this->getApplet(), serialize($this->getParameters())));
if ($_SESSION["flash_upload_filename"]) {
$path = $this->getFlashPath();
ilUtil::makeDirParents($path);
@rename($_SESSION["flash_upload_filename"], $path . $this->getApplet());
unset($_SESSION["flash_upload_filename"]);
}
parent::saveToDb();
}
示例6: saveToDb
/**
* Saves a assNumeric object to a database
*
* @param object $db A pear DB object
* @access public
*/
function saveToDb($original_id = "")
{
global $ilDB;
$this->saveQuestionDataToDb($original_id);
// save additional data
$affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s", array("integer"), array($this->getId()));
$affectedRows = $ilDB->manipulateF("INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, maxnumofchars) VALUES (%s, %s)", array("integer", "integer"), array($this->getId(), $this->getMaxChars() ? $this->getMaxChars() : 0));
// Write range to the database
// 1. delete old range
$result = $ilDB->manipulateF("DELETE FROM qpl_num_range WHERE question_fi = %s", array('integer'), array($this->getId()));
// 2. write range
$next_id = $ilDB->nextId('qpl_num_range');
$answer_result = $ilDB->manipulateF("INSERT INTO qpl_num_range (range_id, question_fi, lowerlimit, upperlimit, points, aorder, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)", array('integer', 'integer', 'text', 'text', 'float', 'integer', 'integer'), array($next_id, $this->id, $this->getLowerLimit(), $this->getUpperLimit(), $this->getPoints(), 0, time()));
parent::saveToDb($original_id);
}
示例7: saveToDb
/**
* Saves a assJavaApplet object to a database
*
* Saves a assJavaApplet object to a database (experimental)
*
* @param object $db A pear DB object
* @access public
*/
function saveToDb($original_id = "")
{
global $ilDB;
$this->saveQuestionDataToDb($original_id);
$params = $this->buildParams();
// save additional data
$affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s", array("integer"), array($this->getId()));
$affectedRows = $ilDB->manipulateF("INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, image_file, params) VALUES (%s, %s, %s)", array("integer", "text", "text"), array($this->getId(), $this->javaapplet_filename, $params));
parent::saveToDb($original_id);
}
示例8: saveToDb
/**
* Saves a assMultipleChoice object to a database
*
* @param string $original_id
*/
public function saveToDb($original_id = "")
{
$this->saveQuestionDataToDb($original_id);
$this->saveAdditionalQuestionDataToDb();
$this->saveAnswerSpecificDataToDb();
$this->ensureNoInvalidObligation($this->getId());
parent::saveToDb($original_id);
}
示例9: saveToDb
/**
* Saves a assClozeTest object to a database
*
* @param integer $original_id ID of the original question
* @access public
*/
function saveToDb($original_id = "")
{
global $ilDB;
$this->saveQuestionDataToDb($original_id);
include_once "./Services/Math/classes/class.EvalMath.php";
$eval = new EvalMath();
$eval->suppress_errors = TRUE;
// save additional data
$affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s", array("integer"), array($this->getId()));
$affectedRows = $ilDB->manipulateF("INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, textgap_rating, identical_scoring, fixed_textlen) VALUES (%s, %s, %s, %s)", array("integer", "text", "text", "integer"), array($this->getId(), $this->getTextgapRating(), $this->getIdenticalScoring(), $this->getFixedTextLength() ? $this->getFixedTextLength() : NULL));
$affectedRows = $ilDB->manipulateF("DELETE FROM qpl_a_cloze WHERE question_fi = %s", array("integer"), array($this->getId()));
foreach ($this->gaps as $key => $gap) {
foreach ($gap->getItems() as $item) {
$query = "";
switch ($gap->getType()) {
case CLOZE_TEXT:
$next_id = $ilDB->nextId('qpl_a_cloze');
$affectedRows = $ilDB->manipulateF("INSERT INTO qpl_a_cloze (answer_id, question_fi, gap_id, answertext, points, aorder, cloze_type) VALUES (%s, %s, %s, %s, %s, %s, %s)", array("integer", "integer", "integer", "text", "float", "integer", "text"), array($next_id, $this->getId(), $key, strlen($item->getAnswertext()) ? $item->getAnswertext() : "", $item->getPoints(), $item->getOrder(), $gap->getType()));
break;
case CLOZE_SELECT:
$next_id = $ilDB->nextId('qpl_a_cloze');
$affectedRows = $ilDB->manipulateF("INSERT INTO qpl_a_cloze (answer_id, question_fi, gap_id, answertext, points, aorder, cloze_type, shuffle) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", array("integer", "integer", "integer", "text", "float", "integer", "text", "text"), array($next_id, $this->getId(), $key, strlen($item->getAnswertext()) ? $item->getAnswertext() : "", $item->getPoints(), $item->getOrder(), $gap->getType(), $gap->getShuffle() ? "1" : "0"));
break;
case CLOZE_NUMERIC:
$next_id = $ilDB->nextId('qpl_a_cloze');
$affectedRows = $ilDB->manipulateF("INSERT INTO qpl_a_cloze (answer_id, question_fi, gap_id, answertext, points, aorder, cloze_type, lowerlimit, upperlimit) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)", array("integer", "integer", "integer", "text", "float", "integer", "text", "text", "text"), array($next_id, $this->getId(), $key, strlen($item->getAnswertext()) ? $item->getAnswertext() : "", $item->getPoints(), $item->getOrder(), $gap->getType(), $eval->e($item->getLowerBound() !== FALSE) && strlen($item->getLowerBound()) > 0 ? $item->getLowerBound() : $item->getAnswertext(), $eval->e($item->getUpperBound() !== FALSE) && strlen($item->getUpperBound()) > 0 ? $item->getUpperBound() : $item->getAnswertext()));
break;
}
}
}
parent::saveToDb($original_id);
}
示例10: saveToDb
/**
* Saves a assFormulaQuestion object to a database
* @access public
*/
function saveToDb($original_id = "")
{
global $ilDB;
$this->saveQuestionDataToDb($original_id);
// save variables
$affectedRows = $ilDB->manipulateF("\n\t\tDELETE FROM il_qpl_qst_fq_var \n\t\tWHERE question_fi = %s", array("integer"), array($this->getId()));
$source_qst_id = $original_id;
$target_qst_id = $this->getId();
foreach ($this->variables as $variable) {
$next_id = $ilDB->nextId('il_qpl_qst_fq_var');
$ilDB->insert('il_qpl_qst_fq_var', array('variable_id' => array('integer', $next_id), 'question_fi' => array('integer', $this->getId()), 'variable' => array('text', $variable->getVariable()), 'range_min' => array('float', strlen($variable->getRangeMin()) ? $variable->getRangeMin() : 0.0), 'range_max' => array('float', strlen($variable->getRangeMax()) ? $variable->getRangeMax() : 0.0), 'unit_fi' => array('integer', is_object($variable->getUnit()) ? (int) $variable->getUnit()->getId() : 0), 'varprecision' => array('integer', (int) $variable->getPrecision()), 'intprecision' => array('integer', (int) $variable->getIntprecision()), 'range_min_txt' => array('text', $variable->getRangeMinTxt()), 'range_max_txt' => array('text', $variable->getRangeMaxTxt())));
}
// save results
$affectedRows = $ilDB->manipulateF("DELETE FROM il_qpl_qst_fq_res WHERE question_fi = %s", array("integer"), array($this->getId()));
foreach ($this->results as $result) {
$next_id = $ilDB->nextId('il_qpl_qst_fq_res');
if (is_object($result->getUnit())) {
$tmp_result_unit = $result->getUnit()->getId();
} else {
$tmp_result_unit = NULL;
}
$formula = str_replace(",", ".", $result->getFormula());
$ilDB->insert("il_qpl_qst_fq_res", array("result_id" => array("integer", $next_id), "question_fi" => array("integer", $this->getId()), "result" => array("text", $result->getResult()), "range_min" => array("float", strlen($result->getRangeMin()) ? $result->getRangeMin() : 0), "range_max" => array("float", strlen($result->getRangeMax()) ? $result->getRangeMax() : 0), "tolerance" => array("float", strlen($result->getTolerance()) ? $result->getTolerance() : 0), "unit_fi" => array("integer", (int) $tmp_result_unit), "formula" => array("clob", $formula), "resprecision" => array("integer", $result->getPrecision()), "rating_simple" => array("integer", $result->getRatingSimple() ? 1 : 0), "rating_sign" => array("float", $result->getRatingSimple() ? 0 : $result->getRatingSign()), "rating_value" => array("float", $result->getRatingSimple() ? 0 : $result->getRatingValue()), "rating_unit" => array("float", $result->getRatingSimple() ? 0 : $result->getRatingUnit()), "points" => array("float", $result->getPoints()), "result_type" => array('integer', (int) $result->getResultType()), "range_min_txt" => array("text", $result->getRangeMinTxt()), "range_max_txt" => array("text", $result->getRangeMaxTxt())));
}
// save result units
$affectedRows = $ilDB->manipulateF("DELETE FROM il_qpl_qst_fq_res_unit WHERE question_fi = %s", array("integer"), array($this->getId()));
foreach ($this->results as $result) {
foreach ($this->getResultUnits($result) as $unit) {
$next_id = $ilDB->nextId('il_qpl_qst_fq_res_unit');
$affectedRows = $ilDB->manipulateF("INSERT INTO il_qpl_qst_fq_res_unit (result_unit_id, question_fi, result, unit_fi) VALUES (%s, %s, %s, %s)", array('integer', 'integer', 'text', 'integer'), array($next_id, $this->getId(), $result->getResult(), $unit->getId()));
}
}
// copy category/unit-process:
// if $source_qst_id = '' -> nothing to copy because this is a new question
// if $source_qst_id == $target_qst_id -> nothing to copy because this is just an update-process
// if $source_qst_id != $target_qst_id -> copy categories and untis because this is a copy-process
// @todo: Nadia wtf?
if ($source_qst_id != $target_qst_id && $source_qst_id > 0) {
$res = $ilDB->queryF('
SELECT * FROM il_qpl_qst_fq_ucat WHERE question_fi = %s', array('integer'), array($source_qst_id));
$cp_cats = array();
while ($row = $ilDB->fetchAssoc($res)) {
$cp_cats[] = $row['category_id'];
}
foreach ($cp_cats as $old_category_id) {
// copy admin-categorie to custom-category (with question_fi)
$new_cat_id = $this->unitrepository->copyCategory($old_category_id, $target_qst_id);
// copy units to custom_category
$this->unitrepository->copyUnitsByCategories($old_category_id, $new_cat_id, $target_qst_id);
}
}
parent::saveToDb();
}
示例11: saveToDb
/**
* Saves a assOrderingQuestion object to a database
*
* @param object $db A pear DB object
* @access public
*/
function saveToDb($original_id = "")
{
global $ilDB;
$this->saveQuestionDataToDb($original_id);
// save additional data
$affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s", array("integer"), array($this->getId()));
$affectedRows = $ilDB->manipulateF("INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, ordering_type, thumb_geometry, element_height) VALUES (%s, %s, %s, %s)", array("integer", "text", "integer", "integer"), array($this->getId(), $this->ordering_type, $this->getThumbGeometry(), $this->getElementHeight() > 20 ? $this->getElementHeight() : NULL));
$affectedRows = $ilDB->manipulateF("DELETE FROM qpl_a_ordering WHERE question_fi = %s", array('integer'), array($this->getId()));
// Anworten wegschreiben
foreach ($this->answers as $key => $value) {
$answer_obj = $this->answers[$key];
$next_id = $ilDB->nextId('qpl_a_ordering');
$affectedRows = $ilDB->manipulateF("INSERT INTO qpl_a_ordering (answer_id, question_fi, answertext, solution_order, " . "random_id, tstamp) VALUES (%s, %s, %s, %s, %s, %s)", array('integer', 'integer', 'text', 'integer', 'integer', 'integer'), array($next_id, $this->getId(), ilRTE::_replaceMediaObjectImageSrc($answer_obj->getAnswertext(), 0), $key, $answer_obj->getRandomID(), time()));
}
if ($this->getOrderingType() == OQ_PICTURES) {
$this->rebuildThumbnails();
}
$this->cleanImagefiles();
parent::saveToDb($original_id);
}
示例12: saveToDb
/**
* Saves a assTextQuestion object to a database
*
* @param object $db A pear DB object
* @access public
*/
function saveToDb($original_id = "")
{
global $ilDB;
$this->saveQuestionDataToDb($original_id);
// save additional data
$affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s", array("integer"), array($this->getId()));
$affectedRows = $ilDB->manipulateF("INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, maxnumofchars, keywords, textgap_rating, matchcondition, keyword_relation) VALUES (%s, %s, %s, %s, %s, %s)", array("integer", "integer", "text", "text", 'integer', 'text'), array($this->getId(), $this->getMaxNumOfChars(), NULL, $this->getTextRating(), $this->matchcondition, $this->getKeywordRelation()));
$ilDB->manipulateF("DELETE FROM qpl_a_essay WHERE question_fi = %s", array("integer"), array($this->getId()));
foreach ($this->answers as $answer) {
$nextID = $ilDB->nextId('qpl_a_essay');
$ilDB->manipulateF("INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points) VALUES (%s, %s, %s, %s)", array("integer", "integer", "text", 'float'), array($nextID, $this->getId(), $answer->answertext, $answer->points));
}
parent::saveToDb($original_id);
}
示例13: saveToDb
/**
* Saves a assMatchingQuestion object to a database
*
* @param object $db A pear DB object
*/
public function saveToDb($original_id = "")
{
global $ilDB;
$this->saveQuestionDataToDb($original_id);
// save additional data
$affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s", array("integer"), array($this->getId()));
$affectedRows = $ilDB->manipulateF("INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, shuffle, matching_type, thumb_geometry, element_height) VALUES (%s, %s, %s, %s, %s)", array("integer", "text", "text", "integer", "integer"), array($this->getId(), $this->shuffle, $this->matching_type, $this->getThumbGeometry(), $this->getElementHeight() >= 20 ? $this->getElementHeight() : NULL));
// delete old terms
$affectedRows = $ilDB->manipulateF("DELETE FROM qpl_a_mterm WHERE question_fi = %s", array('integer'), array($this->getId()));
// delete old definitions
$affectedRows = $ilDB->manipulateF("DELETE FROM qpl_a_mdef WHERE question_fi = %s", array('integer'), array($this->getId()));
$termids = array();
// write terms
foreach ($this->terms as $key => $term) {
$next_id = $ilDB->nextId('qpl_a_mterm');
$affectedRows = $ilDB->manipulateF("INSERT INTO qpl_a_mterm (term_id, question_fi, picture, term) VALUES (%s, %s, %s, %s)", array('integer', 'integer', 'text', 'text'), array($next_id, $this->getId(), $term->picture, $term->text));
$termids[$term->identifier] = $next_id;
}
$definitionids = array();
// write definitions
foreach ($this->definitions as $key => $definition) {
$next_id = $ilDB->nextId('qpl_a_mdef');
$affectedRows = $ilDB->manipulateF("INSERT INTO qpl_a_mdef (def_id, question_fi, picture, definition, morder) VALUES (%s, %s, %s, %s, %s)", array('integer', 'integer', 'text', 'text', 'integer'), array($next_id, $this->getId(), $definition->picture, $definition->text, $definition->identifier));
$definitionids[$definition->identifier] = $next_id;
}
$affectedRows = $ilDB->manipulateF("DELETE FROM qpl_a_matching WHERE question_fi = %s", array('integer'), array($this->getId()));
$matchingpairs = $this->getMatchingPairs();
foreach ($matchingpairs as $key => $pair) {
$next_id = $ilDB->nextId('qpl_a_matching');
$affectedRows = $ilDB->manipulateF("INSERT INTO qpl_a_matching (answer_id, question_fi, points, term_fi, definition_fi) VALUES (%s, %s, %s, %s, %s)", array('integer', 'integer', 'float', 'integer', 'integer'), array($next_id, $this->getId(), $pair->points, $termids[$pair->term->identifier], $definitionids[$pair->definition->identifier]));
}
$this->rebuildThumbnails();
parent::saveToDb($original_id);
}
示例14: saveToDb
/**
* Saves a assFlashQuestion object to a database
*
* @access public
*/
function saveToDb($original_id = "")
{
$this->saveQuestionDataToDb($original_id);
$this->saveAdditionalQuestionDataToDb();
parent::saveToDb();
}
示例15: saveToDb
/**
* Saves a assSingleChoice object to a database
*
* @param string $original_id
*
*/
public function saveToDb($original_id = "")
{
/** @var ilDB $ilDB */
global $ilDB;
$this->saveQuestionDataToDb($original_id);
// kann das weg?
$oldthumbsize = 0;
if ($this->isSingleline && $this->getThumbSize()) {
// get old thumbnail size
$result = $ilDB->queryF("SELECT thumb_size FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s", array("integer"), array($this->getId()));
if ($result->numRows() == 1) {
$data = $ilDB->fetchAssoc($result);
$oldthumbsize = $data['thumb_size'];
}
}
$this->saveAdditionalQuestionDataToDb();
$this->saveAnswerSpecificDataToDb();
parent::saveToDb($original_id);
}