本文整理汇总了PHP中Exercise::addToList方法的典型用法代码示例。如果您正苦于以下问题:PHP Exercise::addToList方法的具体用法?PHP Exercise::addToList怎么用?PHP Exercise::addToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exercise
的用法示例。
在下文中一共展示了Exercise::addToList方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reuseQuestionAction
/**
* @param Application $app
* @param int $exerciseId
* @param int $questionId
* @return Response
*/
public function reuseQuestionAction(Application $app, $exerciseId, $questionId)
{
/** @var \Question $question */
$question = \Question::read($questionId);
if ($question) {
// adds the exercise ID represented by $fromExercise into the list of exercises for the current question
$question->addToList($exerciseId);
$objExercise = new \Exercise();
$objExercise->read($exerciseId);
// adds the question ID represented by $recup into the list of questions for the current exercise
$objExercise->addToList($exerciseId);
Session::write('objExercise', $objExercise);
/*$params = array(
'cidReq' => api_get_course_id(),
'id_session' => api_get_session_id(),
'id' => $questionId,
'exerciseId' => $exerciseId
);
$url = $app['url_generator']->generate('exercise_question_pool', $params);
return $app->redirect($url);*/
$response = \Display::return_message(get_lang('QuestionReused') . ": " . $question->question);
return new Response($response, 200, array());
}
}
示例2: processCreation
/**
* function which process the creation of questions
* @param FormValidator $form the formvalidator instance
* @param Exercise $objExercise the Exercise instance
*/
public function processCreation($form, $objExercise = null)
{
$this->updateParentId($form->getSubmitValue('parent_id'));
$this->updateTitle($form->getSubmitValue('questionName'));
$this->updateDescription($form->getSubmitValue('questionDescription'));
$this->updateLevel($form->getSubmitValue('questionLevel'));
$this->updateCategory($form->getSubmitValue('questionCategory'));
// Save normal question if NOT media
if ($this->type != MEDIA_QUESTION) {
$this->save($objExercise->id);
$field_value = new ExtraFieldValue('question');
$params = $form->getSubmitValues();
$params['question_id'] = $this->id;
$field_value->save_field_values($params);
if ($objExercise) {
// modify the exercise
$objExercise->addToList($this->id);
$objExercise->update_question_positions();
}
}
}
示例3: unset
// gets an existing question and copies it into a new exercise
$objQuestionTmp = Question::read($recup);
// if the question exists
if ($objQuestionTmp) {
/* Adds the exercise ID represented by $fromExercise into the list
of exercises for the current question */
$objQuestionTmp->addToList($fromExercise);
}
// destruction of the Question object
unset($objQuestionTmp);
if (!$objExercise instanceof Exercise) {
$objExercise = new Exercise();
$objExercise->read($fromExercise);
}
// Adds the question ID represented by $recup into the list of questions for the current exercise
$objExercise->addToList($recup);
Session::write('objExercise', $objExercise);
} else {
if (isset($_POST['recup']) && is_array($_POST['recup']) && $fromExercise) {
$list_recup = $_POST['recup'];
foreach ($list_recup as $course_id => $question_data) {
$origin_course_id = intval($course_id);
$origin_course_info = api_get_course_info_by_id($origin_course_id);
$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);
示例4: processCreation
/**
* function which process the creation of questions
* @param FormValidator $form
* @param Exercise $objExercise
*/
public function processCreation($form, $objExercise = null)
{
$this->updateTitle($form->getSubmitValue('questionName'));
$this->updateDescription($form->getSubmitValue('questionDescription'));
$this->updateLevel($form->getSubmitValue('questionLevel'));
$this->updateCategory($form->getSubmitValue('questionCategory'));
//Save normal question if NOT media
if ($this->type != MEDIA_QUESTION) {
$this->save($objExercise->id);
// modify the exercise
$objExercise->addToList($this->id);
$objExercise->update_question_positions();
}
}
示例5: Question
Session::Messages($langQuestionNotFound);
redirect_to_home_page("modules/exercise/admin.php?course={$course_code}&exerciseId={$exerciseId}");
}
if (isset($_GET['editQuestion'])) {
//clone and redirect to edit
if (isset($_GET['clone'])) {
//if user comes from an exercise page
if (isset($exerciseId)) {
// duplicates the question
$new_question_id = $objQuestion->duplicate();
// deletes the old question from the specific exercise
$objQuestion->delete($exerciseId);
// removes the old question ID from the question list of the Exercise object
$objExercise->removeFromList($question_id);
// 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}");
示例6: fill_exe
/**
* Loads the data and injects it into the Chamilo database, using the Chamilo
* internal functions.
* @return array List of user IDs for the users that have just been inserted
*/
function fill_exe()
{
$qc = 5000;
//how many questions to create per exercise
$eol = PHP_EOL;
$courses = array();
//declare only to avoid parsing notice
$qst = array();
require_once 'data_exe.php';
//fill the $users array
$output = array();
$output[] = array('title' => 'Exe Filling Report: ');
$i = 1;
$lib = api_get_path(SYS_CODE_PATH);
require_once $lib . 'exercice/exercise.class.php';
require_once $lib . 'exercice/question.class.php';
require_once $lib . 'exercice/answer.class.php';
foreach ($courses as $i => $course) {
//first check that the first item doesn't exist already
$output[$i]['line-init'] = $course['title'];
$res = CourseManager::create_course($course);
$output[$i]['line-info'] = $res ? $res : get_lang('NotInserted');
$i++;
if (is_array($res)) {
//now insert an exercise
foreach ($course['exes'] as $exe) {
$objExercise = new Exercise($res['real_id']);
$objExercise->id = 0;
$objExercise->course_id = $res['real_id'];
$objExercise->exercise = $exe['title'];
$objExercise->type = 1;
$objExercise->attempts = $exe['attempts'];
$objExercise->random = $exe['random'];
$objExercise->active = 1;
$objExercise->propagate_neg = 0;
$objExercise->pass_percentage = $exe['pass_percentage'];
$objExercise->session_id = 0;
$objExercise->results_disabled = 0;
$objExercise->expired_time = $exe['time'];
$objExercise->review_answers = $exe['review_answers'];
$objExercise->save();
$id = $objExercise->id;
if (!empty($id)) {
$qi = 0;
while ($qi < $qc) {
foreach ($qst as $q) {
error_log('Created ' . $qi . ' questions');
$question = Question::getInstance($q['type']);
$question->id = 0;
$question->question = $q['title'] . ' ' . $qi;
$question->description = $q['desc'];
$question->type = $q['type'];
$question->course = $res;
$r = $question->save($id);
if ($r === false) {
continue;
}
$qid = $question->id;
$objExercise->addToList($qid);
$objExercise->update_question_positions();
$aid = 1;
foreach ($q['answers'] as $asw) {
$answer = new UniqueAnswer($qid);
$answer->create_answer($aid, $qid, $asw['title'], '', $asw['score'], $asw['correct'], $res['real_id']);
$aid++;
}
$qi++;
}
}
}
}
}
}
return $output;
}