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


PHP quiz_attempt_state函数代码示例

本文整理汇总了PHP中quiz_attempt_state函数的典型用法代码示例。如果您正苦于以下问题:PHP quiz_attempt_state函数的具体用法?PHP quiz_attempt_state怎么用?PHP quiz_attempt_state使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了quiz_attempt_state函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_quiz_attempt_state

 /**
  * @dataProvider quiz_attempt_state_data_provider
  *
  * @param unknown $attemptstate as in the quiz_attempts.state DB column.
  * @param unknown $relativetimefinish time relative to now when the attempt finished, or null for 0.
  * @param unknown $relativetimeclose time relative to now when the quiz closes, or null for 0.
  * @param unknown $expectedstate expected result. One of the mod_quiz_display_options constants/
  */
 public function test_quiz_attempt_state($attemptstate, $relativetimefinish, $relativetimeclose, $expectedstate)
 {
     $attempt = new stdClass();
     $attempt->state = $attemptstate;
     if ($relativetimefinish === null) {
         $attempt->timefinish = 0;
     } else {
         $attempt->timefinish = time() + $relativetimefinish;
     }
     $quiz = new stdClass();
     if ($relativetimeclose === null) {
         $quiz->timeclose = 0;
     } else {
         $quiz->timeclose = time() + $relativetimeclose;
     }
     $this->assertEquals($expectedstate, quiz_attempt_state($quiz, $attempt));
 }
开发者ID:janeklb,项目名称:moodle,代码行数:25,代码来源:locallib_test.php

示例2: get_attempt_state

 /**
  * @return int one of the mod_quiz_display_options::DURING,
  *      IMMEDIATELY_AFTER, LATER_WHILE_OPEN or AFTER_CLOSE constants.
  */
 public function get_attempt_state()
 {
     return quiz_attempt_state($this->get_quiz(), $this->attempt);
 }
开发者ID:elie89,项目名称:moodle,代码行数:8,代码来源:attemptlib.php

示例3: make_review_link

    /**
     * Make some text into a link to review the quiz, if that is appropriate.
     *
     * @param string $linktext some text.
     * @param object $attempt the attempt object
     * @return string some HTML, the $linktext either unmodified or wrapped in a
     *      link to the review page.
     */
    public function make_review_link($attempt, $reviewoptions, $output) {

        // If the attempt is still open, don't link.
        if (in_array($attempt->state, array(quiz_attempt::IN_PROGRESS, quiz_attempt::OVERDUE))) {
            return $output->no_review_message('');
        }

        $when = quiz_attempt_state($this->quizobj->get_quiz(), $attempt);
        $reviewoptions = mod_quiz_display_options::make_from_quiz(
                $this->quizobj->get_quiz(), $when);

        if (!$reviewoptions->attempt) {
            return $output->no_review_message($this->quizobj->cannot_review_message($when, true));

        } else {
            return $output->review_link($this->quizobj->review_url($attempt->id),
                    $this->attempt_must_be_in_popup(), $this->get_popup_options());
        }
    }
开发者ID:JP-Git,项目名称:moodle,代码行数:27,代码来源:accessmanager.php

示例4: quiz_get_combined_reviewoptions

/**
 * Combines the review options from a number of different quiz attempts.
 * Returns an array of two ojects, so the suggested way of calling this
 * funciton is:
 * list($someoptions, $alloptions) = quiz_get_combined_reviewoptions(...)
 *
 * @param object $quiz the quiz instance.
 * @param array $attempts an array of attempt objects.
 * @param $context the roles and permissions context,
 *          normally the context for the quiz module instance.
 *
 * @return array of two options objects, one showing which options are true for
 *          at least one of the attempts, the other showing which options are true
 *          for all attempts.
 */
function quiz_get_combined_reviewoptions($quiz, $attempts) {
    $fields = array('feedback', 'generalfeedback', 'rightanswer', 'overallfeedback');
    $someoptions = new stdClass();
    $alloptions = new stdClass();
    foreach ($fields as $field) {
        $someoptions->$field = false;
        $alloptions->$field = true;
    }
    $someoptions->marks = question_display_options::HIDDEN;
    $alloptions->marks = question_display_options::MARK_AND_MAX;

    foreach ($attempts as $attempt) {
        $attemptoptions = mod_quiz_display_options::make_from_quiz($quiz,
                quiz_attempt_state($quiz, $attempt));
        foreach ($fields as $field) {
            $someoptions->$field = $someoptions->$field || $attemptoptions->$field;
            $alloptions->$field = $alloptions->$field && $attemptoptions->$field;
        }
        $someoptions->marks = max($someoptions->marks, $attemptoptions->marks);
        $alloptions->marks = min($alloptions->marks, $attemptoptions->marks);
    }
    return array($someoptions, $alloptions);
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:38,代码来源:locallib.php

示例5: make_review_link

 /**
  * Make some text into a link to review the quiz, if that is appropriate.
  *
  * @param string $linktext some text.
  * @param object $attempt the attempt object
  * @return string some HTML, the $linktext either unmodified or wrapped in a
  *      link to the review page.
  */
 public function make_review_link($attempt, $canpreview, $reviewoptions)
 {
     global $CFG;
     // If review of responses is not allowed, or the attempt is still open, don't link.
     if (!$attempt->timefinish) {
         return '';
     }
     $when = quiz_attempt_state($this->_readerobj->get_reader(), $attempt);
     $reviewoptions = mod_reader_display_options::make_from_quiz($this->_readerobj->get_reader(), $when);
     if (!$reviewoptions->attempt) {
         $message = $this->cannot_review_message($when, true);
         if ($message) {
             return '<span class="noreviewmessage">' . $message . '</span>';
         } else {
             return '';
         }
     }
     $linktext = get_string('review', 'quiz');
     // It is OK to link, does it need to be in a secure window?
     if ($this->securewindow_required($canpreview)) {
         return $this->_securewindowrule->make_review_link($linktext, $attempt->id);
     } else {
         return '<a href="' . $this->_readerobj->review_url($attempt->id) . '" title="' . get_string('reviewthisattempt', 'quiz') . '">' . $linktext . '</a>';
     }
 }
开发者ID:e-rasvet,项目名称:reader,代码行数:33,代码来源:accessrules.php

示例6: quiz_get_combined_reviewoptions

/**
 * Combines the review options from a number of different quiz attempts.
 * Returns an array of two ojects, so the suggested way of calling this
 * funciton is:
 * list($someoptions, $alloptions) = quiz_get_combined_reviewoptions(...)
 *
 * @param object $quiz the quiz instance.
 * @param array $attempts an array of attempt objects.
 *
 * @return array of two options objects, one showing which options are true for
 *          at least one of the attempts, the other showing which options are true
 *          for all attempts.
 */
function quiz_get_combined_reviewoptions($quiz, $attempts)
{
    $fields = array('feedback', 'generalfeedback', 'rightanswer', 'overallfeedback');
    $someoptions = new stdClass();
    $alloptions = new stdClass();
    foreach ($fields as $field) {
        $someoptions->{$field} = false;
        $alloptions->{$field} = true;
    }
    $someoptions->marks = question_display_options::HIDDEN;
    $alloptions->marks = question_display_options::MARK_AND_MAX;
    // This shouldn't happen, but we need to prevent reveal information.
    if (empty($attempts)) {
        return array($someoptions, $someoptions);
    }
    foreach ($attempts as $attempt) {
        $attemptoptions = mod_quiz_display_options::make_from_quiz($quiz, quiz_attempt_state($quiz, $attempt));
        foreach ($fields as $field) {
            $someoptions->{$field} = $someoptions->{$field} || $attemptoptions->{$field};
            $alloptions->{$field} = $alloptions->{$field} && $attemptoptions->{$field};
        }
        $someoptions->marks = max($someoptions->marks, $attemptoptions->marks);
        $alloptions->marks = min($alloptions->marks, $attemptoptions->marks);
    }
    return array($someoptions, $alloptions);
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:39,代码来源:locallib.php

示例7: test_quiz_attempt_state_never_sumitted_quiz_closed

 public function test_quiz_attempt_state_never_sumitted_quiz_closed()
 {
     $attempt = new stdClass();
     $attempt->state = quiz_attempt::ABANDONED;
     $attempt->timefinish = time() - 7200;
     $quiz = new stdClass();
     $quiz->timeclose = time() - 3600;
     $this->assertEquals(mod_quiz_display_options::AFTER_CLOSE, quiz_attempt_state($quiz, $attempt));
 }
开发者ID:rushi963,项目名称:moodle,代码行数:9,代码来源:locallib_test.php

示例8: make_review_link

    /**
     * Make some text into a link to review the quiz, if that is appropriate.
     *
     * @param string $linktext some text.
     * @param object $attempt the attempt object
     * @return string some HTML, the $linktext either unmodified or wrapped in a
     *      link to the review page.
     */
    public function make_review_link($attempt, $reviewoptions, $output) {

        // If review of responses is not allowed, or the attempt is still open, don't link.
        if (!$attempt->timefinish) {
            return $output->no_review_message('');
        }

        $when = quiz_attempt_state($this->quizobj->get_quiz(), $attempt);
        $reviewoptions = mod_quiz_display_options::make_from_quiz(
                $this->quizobj->get_quiz(), $when);

        if (!$reviewoptions->attempt) {
            return $output->no_review_message($this->quizobj->cannot_review_message($when, true));

        } else {
            return $output->review_link($this->quizobj->review_url($attempt->id),
                    $this->attempt_must_be_in_popup(), $this->get_popup_options());
        }
    }
开发者ID:numbas,项目名称:moodle,代码行数:27,代码来源:accessmanager.php


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