本文整理汇总了PHP中Exercise::manageAnswers方法的典型用法代码示例。如果您正苦于以下问题:PHP Exercise::manageAnswers方法的具体用法?PHP Exercise::manageAnswers怎么用?PHP Exercise::manageAnswers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exercise
的用法示例。
在下文中一共展示了Exercise::manageAnswers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
$mediaCounter = 0;
$arrid = array();
foreach ($questionList as $questionId) {
$choice = isset($exerciseResult[$questionId]) ? $exerciseResult[$questionId] : null;
// Creates a temporary Question object
/** @var Question $objQuestionTmp */
$objQuestionTmp = Question::read($questionId);
$questionWeighting = $objQuestionTmp->selectWeighting();
$answerType = $objQuestionTmp->selectType();
// Start buffer
ob_start();
/* Use switch
switch ($answerType) {
}*/
if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
$question_result = $objExercise->manageAnswers($id, $questionId, $choice, 'exercise_show', array(), false, true, $show_results);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
$choice = array();
$question_result = $objExercise->manageAnswers($id, $questionId, $choice, 'exercise_show', array(), false, true, $show_results);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_NO_OPTION) {
$question_result = $objExercise->manageAnswers($id, $questionId, $choice, 'exercise_show', array(), false, true, $show_results);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
echo '</table>';
} elseif ($answerType == FILL_IN_BLANKS) {
$question_result = $objExercise->manageAnswers($id, $questionId, $choice, 'exercise_show', array(), false, true, $show_results);
$questionScore = $question_result['score'];
示例2: Exercise
<?php
$exerciseId = $app['request']->get('exerciseId');
$exercise = new Exercise();
$exercise->read($exerciseId);
$examResults = get_all_exercise_results($exerciseId, api_get_course_int_id(), api_get_session_id(), true);
foreach ($examResults as $exerciseAttempt) {
$exeId = $exerciseAttempt['exe_id'];
$questionList = $exerciseAttempt['question_list'];
// Cleaning total result in order to recalculate:
$stat_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$sql = 'UPDATE ' . $stat_table . ' SET exe_result = 0, exe_weighting = 0 WHERE exe_id = ' . $exeId;
Database::query($sql);
$totalWeight = 0;
foreach ($questionList as $questionId => $questionAttempt) {
$result = $exercise->manageAnswers($exeId, $questionId, $questionAttempt['answer'], 'exercise_show', array(), true, true, false, array(), true);
$totalWeight += floatval($result['weight']);
}
$sql = 'UPDATE ' . $stat_table . ' SET exe_weighting = ' . $totalWeight . ' WHERE exe_id = ' . $exeId;
Database::query($sql);
}
$urlMainExercise = api_get_path(WEB_CODE_PATH) . 'exercice/';
header('Location: ' . $urlMainExercise . 'exercise_report.php?exerciseId=' . $exerciseId . '&' . api_get_cidreq());
exit;
示例3: scoreAttemptAction
/**
* @Route("/score-attempt/{exeId}/jury/{juryId}")
* @Method({"GET"})
*/
public function scoreAttemptAction($exeId, $juryId)
{
$userId = $this->getUser()->getUserId();
$trackExercise = \ExerciseLib::get_exercise_track_exercise_info($exeId);
if (empty($trackExercise)) {
$this->createNotFoundException();
}
/** @var \Chamilo\CoreBundle\Entity\Jury $jury */
$jury = $this->getRepository()->find($juryId);
if (empty($jury)) {
$this->createNotFoundException('Jury does not exists');
}
if ($jury->getExerciseId() != $trackExercise['exe_exo_id']) {
$this->createNotFoundException('Exercise attempt is not related with this jury.');
}
$members = $jury->getMembers();
$criteria = Criteria::create()->where(Criteria::expr()->eq("userId", $userId))->setFirstResult(0)->setMaxResults(1);
/** @var JuryMembers $member */
$member = $members->matching($criteria)->first();
if (empty($member)) {
$this->createNotFoundException('You are not part of the jury.');
}
$students = $member->getStudents();
$criteria = Criteria::create()->where(Criteria::expr()->eq("userId", $trackExercise['exe_user_id']))->setFirstResult(0)->setMaxResults(1);
/** @var JuryMembers $member */
$student = $students->matching($criteria)->first();
if (empty($student)) {
$this->createNotFoundException('You are not assigned to this user.');
}
// Setting member only for president.
if ($this->isGranted('ROLE_JURY_PRESIDENT')) {
// Relating user with president
if ($member) {
$this->getManager()->getRepository('Chamilo\\CoreBundle\\Entity\\JuryMembers')->assignUserToJuryMember($trackExercise['exe_user_id'], $member->getId());
}
}
$questionScoreTypeModel = array();
$criteria = array('exeId' => $exeId, 'juryUserId' => $userId);
$trackJury = $this->getManager()->getRepository('Chamilo\\CoreBundle\\Entity\\TrackAttemptJury')->findBy($criteria);
if ($trackJury) {
$this->get('session')->getFlashBag()->add('info', "You already review this exercise attempt.");
/** @var TrackAttemptJury $track */
foreach ($trackJury as $track) {
$questionScoreTypeModel[$track->getQuestionId()] = $track->getQuestionScoreNameId();
}
}
$questionList = explode(',', $trackExercise['data_tracking']);
$exerciseResult = \ExerciseLib::getExerciseResult($trackExercise);
$counter = 1;
$objExercise = new \Exercise($trackExercise['c_id']);
$objExercise->read($trackExercise['exe_exo_id']);
$totalScore = $totalWeighting = 0;
$show_media = true;
$tempParentId = null;
$mediaCounter = 0;
$media_list = array();
$modelType = $objExercise->getScoreTypeModel();
$options = array();
if ($modelType) {
/** @var \Chamilo\CoreBundle\Entity\QuestionScore $questionScoreName */
$questionScore = $this->get('orm.em')->getRepository('Chamilo\\CoreBundle\\Entity\\QuestionScore')->find($modelType);
if ($questionScore) {
$items = $questionScore->getItems();
/** @var \Chamilo\CoreBundle\Entity\QuestionScoreName $score */
foreach ($items as $score) {
$options[$score->getId() . ':' . $score->getScore()] = $score;
}
}
} else {
return $this->createNotFoundException('The exercise does not contain a model type.');
}
$exerciseContent = null;
foreach ($questionList as $questionId) {
ob_start();
$choice = isset($exerciseResult[$questionId]) ? $exerciseResult[$questionId] : null;
// Creates a temporary Question object
/** @var \Question $objQuestionTmp */
$objQuestionTmp = \Question::read($questionId);
if ($objQuestionTmp->parent_id != 0) {
if (!in_array($objQuestionTmp->parent_id, $media_list)) {
$media_list[] = $objQuestionTmp->parent_id;
$show_media = true;
}
if ($tempParentId == $objQuestionTmp->parent_id) {
$mediaCounter++;
} else {
$mediaCounter = 0;
}
$counterToShow = chr(97 + $mediaCounter);
$tempParentId = $objQuestionTmp->parent_id;
}
$questionWeighting = $objQuestionTmp->selectWeighting();
$answerType = $objQuestionTmp->selectType();
$question_result = $objExercise->manageAnswers($exeId, $questionId, $choice, 'exercise_show', array(), false, true, true);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
//.........这里部分代码省略.........
示例4: get_exercise_result
/**
* Returns the exercise result
* @param int attempt id
* @return float exercise result
*/
public function get_exercise_result($exe_id)
{
$result = array();
$track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($exe_id);
$totalScore = 0;
if (!empty($track_exercise_info)) {
$objExercise = new Exercise();
$objExercise->read($track_exercise_info['exe_exo_id']);
if (!empty($track_exercise_info['data_tracking'])) {
$question_list = explode(',', $track_exercise_info['data_tracking']);
}
foreach ($question_list as $questionId) {
$question_result = $objExercise->manageAnswers($exe_id, $questionId, '', 'exercise_show', array(), false, true, false);
// $questionScore = $question_result['score'];
$totalScore += $question_result['score'];
}
if ($objExercise->selectPropagateNeg() == 0 && $totalScore < 0) {
$totalScore = 0;
}
$result = array('score' => $totalScore, 'weight' => $track_exercise_info['exe_weighting']);
}
return $result;
}