本文整理汇总了PHP中Answer::duplicate方法的典型用法代码示例。如果您正苦于以下问题:PHP Answer::duplicate方法的具体用法?PHP Answer::duplicate怎么用?PHP Answer::duplicate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Answer
的用法示例。
在下文中一共展示了Answer::duplicate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: copyQuestionAction
/**
* @param Application $app
* @param int $exerciseId
* @param int $questionId
* @return Response
*/
public function copyQuestionAction(Application $app, $exerciseId, $questionId)
{
$question = \Question::read($questionId);
if ($question) {
$newQuestionTitle = $question->selectTitle() . ' - ' . get_lang('Copy');
$question->updateTitle($newQuestionTitle);
//Duplicating the source question, in the current course
$courseInfo = api_get_course_info();
$newId = $question->duplicate($courseInfo);
// Reading new question
$newQuestion = \Question::read($newId);
$newQuestion->addToList($exerciseId);
// Reading Answers obj of the current course
$newAnswer = new \Answer($questionId);
$newAnswer->read();
//Duplicating the Answers in the current course
$newAnswer->duplicate($newId);
/*$params = array(
'cidReq' => api_get_course_id(),
'id_session' => api_get_session_id(),
'id' => $newId,
'exerciseId' => $exerciseId
);
$url = $app['url_generator']->generate('exercise_question_pool', $params);
return $app->redirect($url);*/
$response = \Display::return_message(get_lang('QuestionCopied') . ": " . $newQuestionTitle);
return new Response($response, 200, array());
}
}
示例2: foreach
$current_course = api_get_course_info();
foreach ($question_data as $old_question_id) {
//Reading the source question
$old_question_obj = Question::read($old_question_id, $origin_course_id);
if ($old_question_obj) {
$old_question_obj->updateTitle($old_question_obj->selectTitle() . ' - ' . get_lang('Copy'));
//Duplicating the source question, in the current course
$new_id = $old_question_obj->duplicate($current_course);
//Reading new question
$new_question_obj = Question::read($new_id);
$new_question_obj->addToList($fromExercise);
//Reading Answers obj of the current course
$new_answer_obj = new Answer($old_question_id, $origin_course_id);
$new_answer_obj->read();
//Duplicating the Answers in the current course
$new_answer_obj->duplicate($new_id, $current_course);
// destruction of the Question object
unset($new_question_obj);
unset($old_question_obj);
if (!$objExercise instanceof Exercise) {
$objExercise = new Exercise();
$objExercise->read($fromExercise);
}
}
}
}
Session::write('objExercise', $objExercise);
}
}
}
if (isset($_SESSION['gradebook'])) {
示例3: copy_exercise
/**
* Copies an exercise (duplicate all questions and answers)
*/
public function copy_exercise()
{
$exercise_obj = new Exercise();
$exercise_obj = $this;
// force the creation of a new exercise
$exercise_obj->updateTitle($exercise_obj->selectTitle() . ' - ' . get_lang('Copy'));
//Hides the new exercise
$exercise_obj->updateStatus(false);
$exercise_obj->updateId(0);
$exercise_obj->save();
$new_exercise_id = $exercise_obj->selectId();
$question_list = $exercise_obj->selectQuestionList();
if (!empty($question_list)) {
//Question creation
foreach ($question_list as $old_question_id) {
$old_question_obj = Question::read($old_question_id);
$new_id = $old_question_obj->duplicate();
if ($new_id) {
$new_question_obj = Question::read($new_id);
if (isset($new_question_obj) && $new_question_obj) {
$new_question_obj->addToList($new_exercise_id);
// This should be moved to the duplicate function
$new_answer_obj = new Answer($old_question_id);
$new_answer_obj->read();
$new_answer_obj->duplicate($new_id);
}
}
}
}
}
示例4: unset
} else {
// goes back to the question viewing
$editQuestion = $modifyQuestion;
unset($newQuestion, $modifyQuestion);
}
}
if (!empty($clone_question) && !empty($objExercise->id)) {
$old_question_obj = Question::read($clone_question);
$old_question_obj->question = $old_question_obj->question . ' - ' . get_lang('Copy');
$new_id = $old_question_obj->duplicate();
$new_question_obj = Question::read($new_id);
$new_question_obj->addToList($exerciseId);
// This should be moved to the duplicate function
$new_answer_obj = new Answer($clone_question);
$new_answer_obj->read();
$new_answer_obj->duplicate($new_id);
//Reloading tne $objExercise obj
$objExercise->read($objExercise->id);
header('Location: admin.php?' . api_get_cidreq() . '&exerciseId=' . $objExercise->id);
exit;
}
// if cancelling answer creation/modification
if ($cancelAnswers) {
// goes back to the question viewing
$editQuestion = $modifyAnswers;
unset($modifyAnswers);
}
$nameTools = null;
// modifies the query string that is used in the link of tool name
if ($editQuestion || $modifyQuestion || $newQuestion || $modifyAnswers) {
$nameTools = get_lang('QuestionManagement');
示例5: Question
// adds the new question ID into the question list of the Exercise object
$objExercise->addToList($new_question_id);
// construction of the duplicated Question
$objQuestion = new Question();
$objQuestion->read($new_question_id);
// adds the exercise ID into the exercise list of the Question object
$objQuestion->addToList($exerciseId);
// copies answers from the old qustion to the new
$objAnswer = new Answer($question_id);
$objAnswer->duplicate($new_question_id);
redirect_to_home_page("modules/exercise/admin.php?course={$course_code}&exerciseId={$exerciseId}&editQuestion={$new_question_id}");
//if the user comes from question pool
} else {
$new_question_id = $objQuestion->duplicate();
$objAnswer = new Answer($question_id);
$objAnswer->duplicate($new_question_id);
redirect_to_home_page("modules/exercise/admin.php?course={$course_code}&editQuestion={$question_id}");
}
}
$pageName = $langQuestionManagement;
$navigation[] = array('url' => isset($exerciseId) ? "admin.php?course={$course_code}&exerciseId={$exerciseId}" : "question_pool.php?course={$course_code}&exerciseId=0", 'name' => isset($exerciseId) ? $langExerciseManagement : $langQuestionPool);
include 'question_admin.inc.php';
} elseif (isset($_GET['modifyAnswers'])) {
$objAnswer = new Answer($question_id);
include 'answer_admin.inc.php';
} else {
$pageName = $langInfoQuestion;
$navigation[] = array('url' => isset($exerciseId) ? "admin.php?course={$course_code}&exerciseId={$exerciseId}" : "question_pool.php?course={$course_code}&exerciseId=0", 'name' => isset($exerciseId) ? $langExerciseManagement : $langQuestionPool);
include 'statement_admin.inc.php';
}
} else {
示例6: copy_exercise
/**
* Copies an exercise (duplicate all questions and answers)
*/
public function copy_exercise()
{
$original_exercise = $this;
$exercise_obj = new Exercise();
$exercise_obj->setCategoriesGrouping(false);
$exercise_obj->read($this->id);
// force the creation of a new exercise
$exercise_obj->updateTitle($exercise_obj->selectTitle() . ' - ' . get_lang('Copy'));
//Hides the new exercise
$exercise_obj->updateStatus(false);
$exercise_obj->updateId(0);
$exercise_obj->save();
$exercise_obj->save_exercise_list_order($this->course['real_id'], api_get_session_id());
$new_exercise_id = $exercise_obj->selectId();
if ($new_exercise_id) {
$original_exercise->copy_exercise_categories($exercise_obj);
$question_list = $exercise_obj->getQuestionListWithMediasUncompressed();
if (!empty($question_list)) {
//Question creation
foreach ($question_list as $old_question_id) {
$old_question_obj = Question::read($old_question_id);
$new_id = $old_question_obj->duplicate();
if ($new_id) {
$new_question_obj = Question::read($new_id);
if (isset($new_question_obj) && $new_question_obj) {
$new_question_obj->addToList($new_exercise_id);
// This should be moved to the duplicate function
$new_answer_obj = new Answer($old_question_id);
//$new_answer_obj->read();
$new_answer_obj->duplicate($new_id);
}
}
}
}
}
}