当前位置: 首页>>代码示例>>PHP>>正文


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怎么用?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);
}
开发者ID:nigeli,项目名称:moodle,代码行数:30,代码来源:editlib.php

示例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);
}
开发者ID:abhilash1994,项目名称:moodle,代码行数:21,代码来源:editlib.php

示例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;
 }
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:25,代码来源:structure.php

示例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));
                }
            }
        }
    }
}
开发者ID:frankkoch,项目名称:moodle-mod_offlinequiz,代码行数:61,代码来源:locallib.php


注:本文中的question_engine::set_max_mark_in_attempts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。