本文整理汇总了PHP中quiz_has_feedback函数的典型用法代码示例。如果您正苦于以下问题:PHP quiz_has_feedback函数的具体用法?PHP quiz_has_feedback怎么用?PHP quiz_has_feedback使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了quiz_has_feedback函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_quizzes_by_courses
/**
* Returns a list of quizzes in a provided list of courses,
* if no list is provided all quizzes that the user can view will be returned.
*
* @param array $courseids Array of course ids
* @return array of quizzes details
* @since Moodle 3.1
*/
public static function get_quizzes_by_courses($courseids = array())
{
global $USER;
$warnings = array();
$returnedquizzes = array();
$params = array('courseids' => $courseids);
$params = self::validate_parameters(self::get_quizzes_by_courses_parameters(), $params);
$mycourses = array();
if (empty($params['courseids'])) {
$mycourses = enrol_get_my_courses();
$params['courseids'] = array_keys($mycourses);
}
// Ensure there are courseids to loop through.
if (!empty($params['courseids'])) {
list($courses, $warnings) = external_util::validate_courses($params['courseids'], $mycourses);
// Get the quizzes in this course, this function checks users visibility permissions.
// We can avoid then additional validate_context calls.
$quizzes = get_all_instances_in_courses("quiz", $courses);
foreach ($quizzes as $quiz) {
$context = context_module::instance($quiz->coursemodule);
// Update quiz with override information.
$quiz = quiz_update_effective_access($quiz, $USER->id);
// Entry to return.
$quizdetails = array();
// First, we return information that any user can see in the web interface.
$quizdetails['id'] = $quiz->id;
$quizdetails['coursemodule'] = $quiz->coursemodule;
$quizdetails['course'] = $quiz->course;
$quizdetails['name'] = external_format_string($quiz->name, $context->id);
if (has_capability('mod/quiz:view', $context)) {
// Format intro.
list($quizdetails['intro'], $quizdetails['introformat']) = external_format_text($quiz->intro, $quiz->introformat, $context->id, 'mod_quiz', 'intro', null);
$viewablefields = array('timeopen', 'timeclose', 'grademethod', 'section', 'visible', 'groupmode', 'groupingid');
$timenow = time();
$quizobj = quiz::create($quiz->id, $USER->id);
$accessmanager = new quiz_access_manager($quizobj, $timenow, has_capability('mod/quiz:ignoretimelimits', $context, null, false));
// Fields the user could see if have access to the quiz.
if (!$accessmanager->prevent_access()) {
// Some times this function returns just empty.
$hasfeedback = quiz_has_feedback($quiz);
$quizdetails['hasfeedback'] = !empty($hasfeedback) ? 1 : 0;
$quizdetails['hasquestions'] = (int) $quizobj->has_questions();
$quizdetails['autosaveperiod'] = get_config('quiz', 'autosaveperiod');
$additionalfields = array('timelimit', 'attempts', 'attemptonlast', 'grademethod', 'decimalpoints', 'questiondecimalpoints', 'reviewattempt', 'reviewcorrectness', 'reviewmarks', 'reviewspecificfeedback', 'reviewgeneralfeedback', 'reviewrightanswer', 'reviewoverallfeedback', 'questionsperpage', 'navmethod', 'sumgrades', 'grade', 'browsersecurity', 'delay1', 'delay2', 'showuserpicture', 'showblocks', 'completionattemptsexhausted', 'completionpass', 'overduehandling', 'graceperiod', 'preferredbehaviour', 'canredoquestions');
$viewablefields = array_merge($viewablefields, $additionalfields);
}
// Fields only for managers.
if (has_capability('moodle/course:manageactivities', $context)) {
$additionalfields = array('shuffleanswers', 'timecreated', 'timemodified', 'password', 'subnet');
$viewablefields = array_merge($viewablefields, $additionalfields);
}
foreach ($viewablefields as $field) {
$quizdetails[$field] = $quiz->{$field};
}
}
$returnedquizzes[] = $quizdetails;
}
}
$result = array();
$result['quizzes'] = $returnedquizzes;
$result['warnings'] = $warnings;
return $result;
}
示例2: list
$viewobj->accessmanager = $accessmanager;
$viewobj->canreviewmine = $canreviewmine;
// Print table with existing attempts
if ($attempts) {
// Work out which columns we need, taking account what data is available in each attempt.
list($someoptions, $alloptions) = quiz_get_combined_reviewoptions($quiz, $attempts, $context);
$viewobj->attemptcolumn = $quiz->attempts != 1;
$viewobj->gradecolumn = $someoptions->marks >= question_display_options::MARK_AND_MAX &&
quiz_has_grades($quiz);
$viewobj->markcolumn = $viewobj->gradecolumn && ($quiz->grade != $quiz->sumgrades);
$viewobj->overallstats = $lastfinishedattempt && $alloptions->marks >= question_display_options::MARK_AND_MAX;
$viewobj->feedbackcolumn = quiz_has_feedback($quiz) && $alloptions->overallfeedback;
} else {
$viewobj->attemptcolumn = 1;
}
$viewobj->timenow = $timenow;
$viewobj->numattempts = $numattempts;
$viewobj->mygrade = $mygrade;
$viewobj->moreattempts = $unfinished ||
!$accessmanager->is_finished($numattempts, $lastfinishedattempt);
$viewobj->mygradeoverridden = $mygradeoverridden;
$viewobj->gradebookfeedback = $gradebookfeedback;
$viewobj->lastfinishedattempt = $lastfinishedattempt;
$viewobj->canedit = has_capability('mod/quiz:manage', $context);
$viewobj->editurl = new moodle_url('/mod/quiz/edit.php', array('cmid' => $cm->id));
$viewobj->backtocourseurl = new moodle_url('/course/view.php', array('id' => $course->id));
示例3: add_grade_columns
/**
* Add all the grade and feedback columns, if applicable, to the $columns
* and $headers arrays.
* @param object $quiz the quiz settings.
* @param bool $usercanseegrades whether the user is allowed to see grades for this quiz.
* @param array $columns the list of columns. Added to.
* @param array $headers the columns headings. Added to.
* @param bool $includefeedback whether to include the feedbacktext columns
*/
protected function add_grade_columns($quiz, $usercanseegrades, &$columns, &$headers, $includefeedback = true)
{
if ($usercanseegrades) {
$columns[] = 'sumgrades';
$headers[] = get_string('grade', 'quiz') . '/' . quiz_format_grade($quiz, $quiz->grade);
}
if ($includefeedback && quiz_has_feedback($quiz)) {
$columns[] = 'feedbacktext';
$headers[] = get_string('feedback', 'quiz');
}
}
示例4: display
/**
* Display the report.
*/
function display($quiz, $cm, $course)
{
global $CFG, $COURSE, $DB, $PAGE, $OUTPUT;
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
// Work out some display options - whether there is feedback, and whether scores should be shown.
$hasfeedback = quiz_has_feedback($quiz);
$fakeattempt = new stdClass();
$fakeattempt->preview = false;
$fakeattempt->timefinish = $quiz->timeopen;
$fakeattempt->userid = 0;
$reviewoptions = quiz_get_reviewoptions($quiz, $fakeattempt, $context);
$showgrades = quiz_has_grades($quiz) && $reviewoptions->scores;
$download = optional_param('download', '', PARAM_ALPHA);
if ($attemptids = optional_param('attemptid', array(), PARAM_INT)) {
//attempts need to be deleted
require_capability('mod/quiz:deleteattempts', $context);
$attemptids = optional_param('attemptid', array(), PARAM_INT);
foreach ($attemptids as $attemptid) {
add_to_log($course->id, 'quiz', 'delete attempt', 'report.php?id=' . $cm->id, $attemptid, $cm->id);
quiz_delete_attempt($attemptid, $quiz);
}
//No need for a redirect, any attemptids that do not exist are ignored.
//So no problem if the user refreshes and tries to delete the same attempts
//twice.
}
$pageoptions = array();
$pageoptions['id'] = $cm->id;
$pageoptions['q'] = $quiz->id;
$pageoptions['mode'] = 'responses';
$reporturl = new moodle_url($CFG->wwwroot . '/mod/quiz/report.php', $pageoptions);
$qmsubselect = quiz_report_qm_filter_select($quiz);
/// find out current groups mode
$currentgroup = groups_get_activity_group($cm, true);
$mform = new mod_quiz_report_responses_settings($reporturl, array('qmsubselect' => $qmsubselect, 'quiz' => $quiz, 'currentgroup' => $currentgroup));
if ($fromform = $mform->get_data()) {
$attemptsmode = $fromform->attemptsmode;
if ($qmsubselect) {
//control is not on the form if
//the grading method is not set
//to grade one attempt per user eg. for average attempt grade.
$qmfilter = $fromform->qmfilter;
} else {
$qmfilter = 0;
}
set_user_preference('quiz_report_pagesize', $fromform->pagesize);
$pagesize = $fromform->pagesize;
} else {
$qmfilter = optional_param('qmfilter', 0, PARAM_INT);
$attemptsmode = optional_param('attemptsmode', null, PARAM_INT);
if ($attemptsmode === null) {
//default
$attemptsmode = QUIZ_REPORT_ATTEMPTS_ALL;
} else {
if ($currentgroup) {
//default for when a group is selected
if ($attemptsmode === null || $attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL) {
$attemptsmode = QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH;
}
} else {
if (!$currentgroup && $course->id == SITEID) {
//force report on front page to show all, unless a group is selected.
$attemptsmode = QUIZ_REPORT_ATTEMPTS_ALL;
}
}
}
$pagesize = get_user_preferences('quiz_report_pagesize', 0);
}
if ($pagesize < 1) {
$pagesize = QUIZ_REPORT_DEFAULT_PAGE_SIZE;
}
// We only want to show the checkbox to delete attempts
// if the user has permissions and if the report mode is showing attempts.
$candelete = has_capability('mod/quiz:deleteattempts', $context) && $attemptsmode != QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO;
$displayoptions = array();
$displayoptions['attemptsmode'] = $attemptsmode;
$displayoptions['qmfilter'] = $qmfilter;
//work out the sql for this table.
if (!($students = get_users_by_capability($context, array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'), '', '', '', '', '', '', false))) {
$students = array();
} else {
$students = array_keys($students);
}
if (empty($currentgroup)) {
// all users who can attempt quizzes
$allowed = $students;
$groupstudents = array();
} else {
// all users who can attempt quizzes and who are in the currently selected group
if (!($groupstudents = get_users_by_capability($context, array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'), '', '', '', '', $currentgroup, '', false))) {
$groupstudents = array();
} else {
$groupstudents = array_keys($groupstudents);
}
$allowed = $groupstudents;
}
$questions = quiz_report_load_questions($quiz);
$table = new quiz_report_responses_table($quiz, $qmsubselect, $groupstudents, $students, $questions, $candelete, $reporturl, $displayoptions);
//.........这里部分代码省略.........
示例5: display
/**
* Display the report.
*/
function display($quiz, $cm, $course) {
global $CFG, $COURSE, $DB, $OUTPUT;
$this->context = get_context_instance(CONTEXT_MODULE, $cm->id);
// Work out some display options - whether there is feedback, and whether scores should be shown.
$hasfeedback = quiz_has_feedback($quiz);
$fakeattempt = new stdClass();
$fakeattempt->preview = false;
$fakeattempt->timefinish = $quiz->timeopen;
$fakeattempt->userid = 0;
$reviewoptions = quiz_get_reviewoptions($quiz, $fakeattempt, $this->context);
$showgrades = quiz_has_grades($quiz) && $reviewoptions->scores;
$download = optional_param('download', '', PARAM_ALPHA);
/// find out current groups mode
$currentgroup = groups_get_activity_group($cm, true);
if (!$students = get_users_by_capability($this->context, array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'),'u.id,1','','','','','',false)) {
$students = array();
} else {
$students = array_keys($students);
}
if (empty($currentgroup)) {
// all users who can attempt quizzes
$allowed = $students;
$groupstudents = array();
} else {
// all users who can attempt quizzes and who are in the currently selected group
if (!$groupstudents = get_users_by_capability($this->context, array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'),'u.id,1','','','',$currentgroup,'',false)) {
$groupstudents = array();
} else {
$groupstudents = array_keys($groupstudents);
}
$allowed = $groupstudents;
}
$pageoptions = array();
$pageoptions['id'] = $cm->id;
$pageoptions['mode'] = 'overview';
$reporturl = new moodle_url('/mod/quiz/report.php', $pageoptions);
$qmsubselect = quiz_report_qm_filter_select($quiz);
$mform = new mod_quiz_report_overview_settings($reporturl, array('qmsubselect'=> $qmsubselect, 'quiz'=>$quiz,
'currentgroup'=>$currentgroup, 'context'=>$this->context));
if ($fromform = $mform->get_data()) {
$regradeall = false;
$regradealldry = false;
$regradealldrydo = false;
$attemptsmode = $fromform->attemptsmode;
if ($qmsubselect) {
//control is not on the form if
//the grading method is not set
//to grade one attempt per user eg. for average attempt grade.
$qmfilter = $fromform->qmfilter;
} else {
$qmfilter = 0;
}
$regradefilter = $fromform->regradefilter;
set_user_preference('quiz_report_overview_detailedmarks', $fromform->detailedmarks);
set_user_preference('quiz_report_pagesize', $fromform->pagesize);
$detailedmarks = $fromform->detailedmarks;
$pagesize = $fromform->pagesize;
} else {
$regradeall = optional_param('regradeall', 0, PARAM_BOOL);
$regradealldry = optional_param('regradealldry', 0, PARAM_BOOL);
$regradealldrydo = optional_param('regradealldrydo', 0, PARAM_BOOL);
$attemptsmode = optional_param('attemptsmode', null, PARAM_INT);
if ($qmsubselect) {
$qmfilter = optional_param('qmfilter', 0, PARAM_INT);
} else {
$qmfilter = 0;
}
$regradefilter = optional_param('regradefilter', 0, PARAM_INT);
$detailedmarks = get_user_preferences('quiz_report_overview_detailedmarks', 1);
$pagesize = get_user_preferences('quiz_report_pagesize', 0);
}
if ($currentgroup) {
//default for when a group is selected
if ($attemptsmode === null || $attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL) {
$attemptsmode = QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH;
}
} else if (!$currentgroup && $course->id == SITEID) {
//force report on front page to show all, unless a group is selected.
$attemptsmode = QUIZ_REPORT_ATTEMPTS_ALL;
} else if ($attemptsmode === null) {
//default
$attemptsmode = QUIZ_REPORT_ATTEMPTS_ALL;
}
if (!$reviewoptions->scores) {
$detailedmarks = 0;
}
if ($pagesize < 1) {
$pagesize = QUIZ_REPORT_DEFAULT_PAGE_SIZE;
//.........这里部分代码省略.........
示例6: display
/**
* Display the report.
*/
function display($quiz, $cm, $course)
{
global $CFG, $db;
// Define some strings
$strreallydel = addslashes(get_string('deleteattemptcheck', 'quiz'));
$strtimeformat = get_string('strftimedatetime');
$strreviewquestion = get_string('reviewresponse', 'quiz');
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
// Only print headers if not asked to download data
if (!($download = optional_param('download', NULL))) {
$this->print_header_and_tabs($cm, $course, $quiz, "overview");
}
if ($attemptids = optional_param('attemptid', array(), PARAM_INT)) {
//attempts need to be deleted
require_capability('mod/quiz:deleteattempts', $context);
$attemptids = optional_param('attemptid', array(), PARAM_INT);
foreach ($attemptids as $attemptid) {
add_to_log($course->id, 'quiz', 'delete attempt', 'report.php?id=' . $cm->id, $attemptid, $cm->id);
quiz_delete_attempt($attemptid, $quiz);
}
//No need for a redirect, any attemptids that do not exist are ignored.
//So no problem if the user refreshes and tries to delete the same attempts
//twice.
}
// Work out some display options - whether there is feedback, and whether scores should be shown.
$hasfeedback = quiz_has_feedback($quiz->id) && $quiz->grade > 1.0E-7 && $quiz->sumgrades > 1.0E-7;
$fakeattempt = new stdClass();
$fakeattempt->preview = false;
$fakeattempt->timefinish = $quiz->timeopen;
$reviewoptions = quiz_get_reviewoptions($quiz, $fakeattempt, $context);
$showgrades = $quiz->grade && $quiz->sumgrades && $reviewoptions->scores;
$pageoptions = array();
$pageoptions['id'] = $cm->id;
$pageoptions['q'] = $quiz->id;
$pageoptions['mode'] = 'overview';
/// find out current groups mode
$currentgroup = groups_get_activity_group($cm, true);
$reporturl = new moodle_url($CFG->wwwroot . '/mod/quiz/report.php', $pageoptions);
$qmsubselect = quiz_report_qm_filter_select($quiz);
$mform = new mod_quiz_report_overview_settings($reporturl, compact('qmsubselect', 'quiz', 'currentgroup'));
if ($fromform = $mform->get_data()) {
$attemptsmode = $fromform->attemptsmode;
if ($qmsubselect) {
//control is not on the form if
//the grading method is not set
//to grade one attempt per user eg. for average attempt grade.
$qmfilter = $fromform->qmfilter;
} else {
$qmfilter = 0;
}
set_user_preference('quiz_report_overview_detailedmarks', $fromform->detailedmarks);
set_user_preference('quiz_report_pagesize', $fromform->pagesize);
$detailedmarks = $fromform->detailedmarks;
$pagesize = $fromform->pagesize;
} else {
$qmfilter = optional_param('qmfilter', 0, PARAM_INT);
$attemptsmode = optional_param('attemptsmode', QUIZ_REPORT_ATTEMPTS_ALL, PARAM_INT);
$detailedmarks = get_user_preferences('quiz_report_overview_detailedmarks', 1);
$pagesize = get_user_preferences('quiz_report_pagesize', 0);
}
if ($attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL && $currentgroup) {
$attemptsmode = QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH;
}
if (!$reviewoptions->scores) {
$detailedmarks = 0;
}
if ($pagesize < 1) {
$pagesize = QUIZ_REPORT_DEFAULT_PAGE_SIZE;
}
// We only want to show the checkbox to delete attempts
// if the user has permissions and if the report mode is showing attempts.
$candelete = has_capability('mod/quiz:deleteattempts', $context) && $attemptsmode != QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO;
$displayoptions = array();
$displayoptions['attemptsmode'] = $attemptsmode;
$displayoptions['qmfilter'] = $qmfilter;
$reporturlwithdisplayoptions = new moodle_url($CFG->wwwroot . '/mod/quiz/report.php', $pageoptions + $displayoptions);
if ($groupmode = groups_get_activity_groupmode($cm)) {
// Groups are being used
if (!$download) {
groups_print_activity_menu($cm, $reporturlwithdisplayoptions->out());
}
}
// Print information on the number of existing attempts
if (!$download) {
//do not print notices when downloading
if ($strattemptnum = quiz_num_attempt_summary($quiz, $cm, true, $currentgroup)) {
echo '<div class="quizattemptcounts">' . $strattemptnum . '</div>';
}
}
$nostudents = false;
if (!($students = get_users_by_capability($context, array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'), '', '', '', '', '', '', false))) {
notify(get_string('nostudentsyet'));
$nostudents = true;
$studentslist = '';
} else {
$studentslist = join(',', array_keys($students));
}
//.........这里部分代码省略.........
示例7: print_heading
$mygradeoverridden = true;
}
if (!empty($grade->str_feedback)) {
$gradebookfeedback = $grade->str_feedback;
}
}
}
// Print table with existing attempts
if ($attempts) {
print_heading(get_string('summaryofattempts', 'quiz'));
// Work out which columns we need, taking account what data is available in each attempt.
list($someoptions, $alloptions) = quiz_get_combined_reviewoptions($quiz, $attempts, $context);
$gradecolumn = $someoptions->scores && $quiz->grade && $quiz->sumgrades;
$markcolumn = $gradecolumn && $quiz->grade != $quiz->sumgrades;
$overallstats = $alloptions->scores;
$feedbackcolumn = quiz_has_feedback($quiz->id);
$overallfeedback = $feedbackcolumn && $alloptions->overallfeedback;
// Prepare table header
$table->class = 'generaltable quizattemptsummary';
$table->head = array(get_string('attempt', 'quiz'), get_string('timecompleted', 'quiz'));
$table->align = array('center', 'left');
$table->size = array('', '');
if ($markcolumn) {
$table->head[] = get_string('marks', 'quiz') . " / {$quiz->sumgrades}";
$table->align[] = 'center';
$table->size[] = '';
}
if ($gradecolumn) {
$table->head[] = get_string('grade') . " / {$quiz->grade}";
$table->align[] = 'center';
$table->size[] = '';
示例8: array
$navlinks[] = array('name' => $strquizzes, 'link' => '', 'type' => 'activity');
$navigation = build_navigation($navlinks);
print_header_simple($strquizzes, '', $navigation, '', '', true, $streditquestions, navmenu($course));
// Get all the appropriate data
if (!($quizzes = get_all_instances_in_course("quiz", $course))) {
notice(get_string('thereareno', 'moodle', $strquizzes), "../../course/view.php?id={$course->id}");
die;
}
// Check if we need the closing date header
$showclosingheader = false;
$showfeedback = false;
foreach ($quizzes as $quiz) {
if ($quiz->timeclose != 0) {
$showclosingheader = true;
}
if (quiz_has_feedback($quiz->id)) {
$showfeedback = true;
}
}
// Configure table for displaying the list of instances.
$headings = array(get_string('name'));
$align = array('left');
if ($showclosingheader) {
array_push($headings, get_string('quizcloses', 'quiz'));
array_push($align, 'left');
}
if ($course->format == 'weeks' or $course->format == 'weekscss') {
array_unshift($headings, get_string('week'));
} else {
array_unshift($headings, get_string('section'));
}
示例9: array
$navlinks[] = array('name' => $strquizzes, 'link' => '', 'type' => 'activity');
$navigation = build_navigation($navlinks);
print_header_simple($strquizzes, '', $navigation, '', '', true, $streditquestions, navmenu($course));
// Get all the appropriate data
if (!($quizzes = get_all_instances_in_course("quiz", $course))) {
notice(get_string('thereareno', 'moodle', $strquizzes), "../../course/view.php?id={$course->id}");
die;
}
// Check if we need the closing date header
$showclosingheader = false;
$showfeedback = false;
foreach ($quizzes as $quiz) {
if ($quiz->timeclose != 0) {
$showclosingheader = true;
}
if (quiz_has_feedback($quiz)) {
$showfeedback = true;
}
}
// Configure table for displaying the list of instances.
$headings = array(get_string('name'));
$align = array('left');
if ($showclosingheader) {
array_push($headings, get_string('quizcloses', 'quiz'));
array_push($align, 'left');
}
if ($course->format == 'weeks' or $course->format == 'weekscss') {
array_unshift($headings, get_string('week'));
} else {
array_unshift($headings, get_string('section'));
}
示例10: add_grade_columns
/**
* Add all the grade and feedback columns, if applicable, to the $columns
* and $headers arrays.
* @param object $quiz the quiz settings.
* @param array $columns the list of columns. Added to.
* @param array $headers the columns headings. Added to.
*/
protected function add_grade_columns($quiz, &$columns, &$headers)
{
if ($this->should_show_grades($quiz)) {
$columns[] = 'sumgrades';
$headers[] = get_string('grade', 'quiz') . '/' . quiz_format_grade($quiz, $quiz->grade);
}
if (quiz_has_feedback($quiz)) {
$columns[] = 'feedbacktext';
$headers[] = get_string('feedback', 'quiz');
}
}