本文整理汇总了PHP中question_engine::set_max_mark_in_attempts方法的典型用法代码示例。如果您正苦于以下问题:PHP question_engine::set_max_mark_in_attempts方法的具体用法?PHP question_engine::set_max_mark_in_attempts怎么用?PHP question_engine::set_max_mark_in_attempts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_engine
的用法示例。
在下文中一共展示了question_engine::set_max_mark_in_attempts方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: quiz_update_question_instance
/**
* Save changes to question instance
*
* Saves changes to the question grades in the quiz_question_instances table.
* It does not update 'sumgrades' in the quiz table.
*
* @param int grade The maximal grade for the question
* @param int $questionid The id of the question
* @param int $quizid The id of the quiz to update / add the instances for.
*/
function quiz_update_question_instance($grade, $questionid, $quiz) {
global $DB;
$instance = $DB->get_record('quiz_question_instances', array('quiz' => $quiz->id,
'question' => $questionid));
$slot = quiz_get_slot_for_question($quiz, $questionid);
if (!$instance || !$slot) {
throw new coding_exception('Attempt to change the grade of a quesion not in the quiz.');
}
if (abs($grade - $instance->grade) < 1e-7) {
// Grade has not changed. Nothing to do.
return;
}
$instance->grade = $grade;
$DB->update_record('quiz_question_instances', $instance);
question_engine::set_max_mark_in_attempts(new qubaids_for_quiz($quiz->id),
$slot, $grade);
}
示例2: quiz_update_slot_maxmark
/**
* Change the max mark for a slot.
*
* Saves changes to the question grades in the quiz_slots table and any
* corresponding question_attempts.
* It does not update 'sumgrades' in the quiz table.
*
* @param stdClass $slot row from the quiz_slots table.
* @param float $maxmark the new maxmark.
*/
function quiz_update_slot_maxmark($slot, $maxmark)
{
global $DB;
if (abs($maxmark - $slot->maxmark) < 1.0E-7) {
// Grade has not changed. Nothing to do.
return;
}
$slot->maxmark = $maxmark;
$DB->update_record('quiz_slots', $slot);
question_engine::set_max_mark_in_attempts(new qubaids_for_quiz($slot->quizid), $slot->slot, $maxmark);
}
示例3: update_slot_maxmark
/**
* Change the max mark for a slot.
*
* Saves changes to the question grades in the quiz_slots table and any
* corresponding question_attempts.
* It does not update 'sumgrades' in the quiz table.
*
* @param \stdClass $slot row from the quiz_slots table.
* @param float $maxmark the new maxmark.
* @return bool true if the new grade is different from the old one.
*/
public function update_slot_maxmark($slot, $maxmark)
{
global $DB;
if (abs($maxmark - $slot->maxmark) < 1.0E-7) {
// Grade has not changed. Nothing to do.
return false;
}
$trans = $DB->start_delegated_transaction();
$slot->maxmark = $maxmark;
$DB->update_record('quiz_slots', $slot);
\question_engine::set_max_mark_in_attempts(new \qubaids_for_quiz($slot->quizid), $slot->slot, $maxmark);
$trans->allow_commit();
return true;
}
示例4: offlinequiz_update_question_instance
/**
* Save new maxgrade to a question instance
*
* Saves changes to the question grades in the offlinequiz_group_questions table.
* The grades of the questions in the group template qubas are also updated.
* This function does not update 'sumgrades' in the offlinequiz table.
*
* @param int $offlinequiz The offlinequiz to update / add the instances for.
* @param int $questionid The id of the question
* @param int grade The maximal grade for the question
*/
function offlinequiz_update_question_instance($offlinequiz, $questionid, $grade)
{
global $DB;
// First change the maxmark of the question in all offline quiz groups.
$groupquestionids = $DB->get_fieldset_select('offlinequiz_group_questions', 'id', 'offlinequizid = :offlinequizid AND questionid = :questionid', array('offlinequizid' => $offlinequiz->id, 'questionid' => $questionid));
foreach ($groupquestionids as $groupquestionid) {
$DB->set_field('offlinequiz_group_questions', 'maxmark', $grade, array('id' => $groupquestionid));
}
$groups = $DB->get_records('offlinequiz_groups', array('offlinequizid' => $offlinequiz->id), 'number', '*', 0, $offlinequiz->numgroups);
// Now change the maxmark of the question instance in the template question usages of the offlinequiz groups.
foreach ($groups as $group) {
if ($group->templateusageid) {
$templateusage = question_engine::load_questions_usage_by_activity($group->templateusageid);
$slots = $templateusage->get_slots();
$slot = 0;
foreach ($slots as $thisslot) {
if ($templateusage->get_question($thisslot)->id == $questionid) {
$slot = $thisslot;
break;
}
}
if ($slot) {
// Update the grade in the template usage.
question_engine::set_max_mark_in_attempts(new qubaid_list(array($group->templateusageid)), $slot, $grade);
}
}
}
// Now do the same for the qubas of the results of the offline quiz.
if ($results = $DB->get_records('offlinequiz_results', array('offlinequizid' => $offlinequiz->id))) {
foreach ($results as $result) {
if ($result->usageid > 0) {
$quba = question_engine::load_questions_usage_by_activity($result->usageid);
$slots = $quba->get_slots();
$slot = 0;
foreach ($slots as $thisslot) {
if ($quba->get_question($thisslot)->id == $questionid) {
$slot = $thisslot;
break;
}
}
if ($slot) {
question_engine::set_max_mark_in_attempts(new qubaid_list(array($result->usageid)), $slot, $grade);
// Now set the new sumgrades also in the offline quiz result.
$newquba = question_engine::load_questions_usage_by_activity($result->usageid);
$DB->set_field('offlinequiz_results', 'sumgrades', $newquba->get_total_mark(), array('id' => $result->id));
}
}
}
}
}