當前位置: 首頁>>代碼示例>>PHP>>正文


PHP quiz_access_manager::print_start_attempt_button方法代碼示例

本文整理匯總了PHP中quiz_access_manager::print_start_attempt_button方法的典型用法代碼示例。如果您正苦於以下問題:PHP quiz_access_manager::print_start_attempt_button方法的具體用法?PHP quiz_access_manager::print_start_attempt_button怎麽用?PHP quiz_access_manager::print_start_attempt_button使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在quiz_access_manager的用法示例。


在下文中一共展示了quiz_access_manager::print_start_attempt_button方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1:

        } else {
            if ($canpreview) {
                $buttontext = get_string('previewquiznow', 'quiz');
            }
        }
    }
    // If, so far, we think a button should be printed, so check if they will be allowed to access it.
    if ($buttontext) {
        if (!$moreattempts) {
            $buttontext = '';
        } else {
            if ($canattempt && ($messages = $accessmanager->prevent_access())) {
                $accessmanager->print_messages($messages);
                $buttontext = '';
            }
        }
    }
}
/// Now actually print the appropriate button.
if ($buttontext) {
    $accessmanager->print_start_attempt_button($canpreview, $buttontext, $unfinished);
} else {
    echo $OUTPUT->continue_button($CFG->wwwroot . '/course/view.php?id=' . $course->id);
}
echo $OUTPUT->box_end();
// Mark module as viewed (note, we do this here and not in finish_page,
// otherwise the 'not enrolled' error conditions would result in marking
// 'viewed', I think it's better if they don't.)
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
echo $OUTPUT->footer();
開發者ID:ajv,項目名稱:Offline-Caching,代碼行數:31,代碼來源:view.php

示例2: prepareQuizAttempt

function prepareQuizAttempt($q)
{
    global $DB;
    if ($id) {
        if (!($cm = get_coursemodule_from_id('quiz', $id))) {
            print_error('invalidcoursemodule');
        }
        if (!($course = $DB->get_record('course', array('id' => $cm->course)))) {
            print_error('coursemisconf');
        }
        if (!($quiz = $DB->get_record('quiz', array('id' => $cm->instance)))) {
            print_error('invalidcoursemodule');
        }
    } else {
        if (!($quiz = $DB->get_record('quiz', array('id' => $q)))) {
            print_error('invalidquizid', 'quiz');
        }
        if (!($course = $DB->get_record('course', array('id' => $quiz->course)))) {
            print_error('invalidcourseid');
        }
        if (!($cm = get_coursemodule_from_instance("quiz", $quiz->id, $course->id))) {
            print_error('invalidcoursemodule');
        }
    }
    /// Check login and get context.
    require_login($course->id, false, $cm);
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
    require_capability('mod/quiz:view', $context);
    /// Cache some other capabilites we use several times.
    $canattempt = has_capability('mod/quiz:attempt', $context);
    $canreviewmine = has_capability('mod/quiz:reviewmyattempts', $context);
    $canpreview = has_capability('mod/quiz:preview', $context);
    /// Create an object to manage all the other (non-roles) access rules.
    $timenow = time();
    $accessmanager = new quiz_access_manager(new quiz($quiz, $cm, $course), $timenow, has_capability('mod/quiz:ignoretimelimits', $context, NULL, false));
    /// Print information about the student's best score for this quiz if possible.
    $moreattempts = $unfinished || !$accessmanager->is_finished($numattempts, $lastfinishedattempt);
    /// Determine if we should be showing a start/continue attempt button,
    /// or a button to go back to the course page.
    print_box_start('quizattempt');
    $buttontext = '';
    // This will be set something if as start/continue attempt button should appear.
    if (!$quiz->questions) {
        print_heading(get_string("noquestions", "quiz"));
    } else {
        if ($unfinished) {
            if ($canattempt) {
                $buttontext = get_string('continueattemptquiz', 'quiz');
            } else {
                if ($canpreview) {
                    $buttontext = get_string('continuepreview', 'quiz');
                }
            }
        } else {
            if ($canattempt) {
                $messages = $accessmanager->prevent_new_attempt($numattempts, $lastfinishedattempt);
                if ($messages) {
                    $accessmanager->print_messages($messages);
                } else {
                    if ($numattempts == 0) {
                        $buttontext = get_string('attemptquiznow', 'quiz');
                    } else {
                        $buttontext = get_string('reattemptquiz', 'quiz');
                    }
                }
            } else {
                if ($canpreview) {
                    $buttontext = get_string('previewquiznow', 'quiz');
                }
            }
        }
        // If, so far, we think a button should be printed, so check if they will be allowed to access it.
        if ($buttontext) {
            if (!$moreattempts) {
                $buttontext = '';
            } else {
                if ($canattempt && ($messages = $accessmanager->prevent_access())) {
                    $accessmanager->print_messages($messages);
                    $buttontext = '';
                }
            }
        }
    }
    /// Now actually print the appropriate button.
    if ($buttontext) {
        $accessmanager->print_start_attempt_button($canpreview, $buttontext, $unfinished);
    } else {
        print_continue($CFG->wwwroot . '/course/view.php?id=' . $course->id);
    }
    print_box_end();
}
開發者ID:arshanam,項目名稱:Moodle-ITScholars-LMS,代碼行數:91,代碼來源:test_view.php


注:本文中的quiz_access_manager::print_start_attempt_button方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。