本文整理汇总了PHP中default_questiontype::restore方法的典型用法代码示例。如果您正苦于以下问题:PHP default_questiontype::restore方法的具体用法?PHP default_questiontype::restore怎么用?PHP default_questiontype::restore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类default_questiontype
的用法示例。
在下文中一共展示了default_questiontype::restore方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: restore
function restore($old_question_id, $new_question_id, $info, $restore)
{
$status = parent::restore($old_question_id, $new_question_id, $info, $restore);
if ($status) {
$extraquestionfields = $this->extra_question_fields();
$questionextensiontable = array_shift($extraquestionfields);
//We have to recode the answers field (a list of answers id)
$questionextradata = get_record($questionextensiontable, $this->questionid_column_name(), $new_question_id);
if (isset($questionextradata->answers)) {
$answers_field = "";
$in_first = true;
$tok = strtok($questionextradata->answers, ",");
while ($tok) {
// Get the answer from backup_ids
$answer = backup_getid($restore->backup_unique_code, "question_answers", $tok);
if ($answer) {
if ($in_first) {
$answers_field .= $answer->new_id;
$in_first = false;
} else {
$answers_field .= "," . $answer->new_id;
}
}
// Check for next
$tok = strtok(",");
}
// We have the answers field recoded to its new ids
$questionextradata->answers = $answers_field;
// Update the question
$status = $status && update_record($questionextensiontable, $questionextradata);
}
}
return $status;
}