本文整理汇总了PHP中condition_info::completion_value_used_as_condition方法的典型用法代码示例。如果您正苦于以下问题:PHP condition_info::completion_value_used_as_condition方法的具体用法?PHP condition_info::completion_value_used_as_condition怎么用?PHP condition_info::completion_value_used_as_condition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类condition_info
的用法示例。
在下文中一共展示了condition_info::completion_value_used_as_condition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ss_print_section
//.........这里部分代码省略.........
!isguestuser() && $mod->uservisible) {
$completiondata = $completioninfo->get_data($mod,true);
$completionicon = '';
if ($isediting) {
switch ($completion) {
case COMPLETION_TRACKING_MANUAL :
$completionicon = 'manual-enabled'; break;
case COMPLETION_TRACKING_AUTOMATIC :
$completionicon = 'auto-enabled'; break;
default: // wtf
}
} else if ($completion==COMPLETION_TRACKING_MANUAL) {
switch($completiondata->completionstate) {
case COMPLETION_INCOMPLETE:
$completionicon = 'manual-n'; break;
case COMPLETION_COMPLETE:
$completionicon = 'manual-y'; break;
}
} else { // Automatic
switch($completiondata->completionstate) {
case COMPLETION_INCOMPLETE:
$completionicon = 'auto-n'; break;
case COMPLETION_COMPLETE:
$completionicon = 'auto-y'; break;
case COMPLETION_COMPLETE_PASS:
$completionicon = 'auto-pass'; break;
case COMPLETION_COMPLETE_FAIL:
$completionicon = 'auto-fail'; break;
}
}
if ($completionicon) {
$imgsrc = $OUTPUT->pix_url('i/completion-'.$completionicon);
$imgalt = s(get_string('completion-alt-'.$completionicon, 'completion'));
if ($completion == COMPLETION_TRACKING_MANUAL && !$isediting) {
$imgtitle = s(get_string('completion-title-'.$completionicon, 'completion'));
$newstate =
$completiondata->completionstate==COMPLETION_COMPLETE
? COMPLETION_INCOMPLETE
: COMPLETION_COMPLETE;
// In manual mode the icon is a toggle form...
// If this completion state is used by the
// conditional activities system, we need to turn
// off the JS.
if (!empty($CFG->enableavailability) &&
condition_info::completion_value_used_as_condition($course, $mod)) {
$extraclass = ' preventjs';
} else {
$extraclass = '';
}
echo "
<form class='togglecompletion$extraclass' method='post' action='togglecompletion.php'><div>
<input type='hidden' name='id' value='{$mod->id}' />
<input type='hidden' name='sesskey' value='".sesskey()."' />
<input type='hidden' name='completionstate' value='$newstate' />
<input type='image' src='$imgsrc' alt='$imgalt' title='$imgtitle' />
</div></form>";
} else {
// In auto mode, or when editing, the icon is just an image
echo "<span class='autocompletion'>";
echo "<img src='$imgsrc' alt='$imgalt' title='$imgalt' /></span>";
}
}
}
// Show availability information (for someone who isn't allowed to
// see the activity itself, or for staff)
if (!$mod->uservisible) {
echo '<div class="availabilityinfo">'.$mod->availableinfo.'</div>';
} else if ($canviewhidden && !empty($CFG->enableavailability)) {
$ci = new condition_info($mod);
$fullinfo = $ci->get_full_information();
if($fullinfo) {
echo '<div class="availabilityinfo">'.get_string($mod->showavailability
? 'userrestriction_visible'
: 'userrestriction_hidden','condition',
$fullinfo).'</div>';
}
}
echo hook_show_activity_intro($mod);
echo html_writer::end_tag('div');
echo html_writer::end_tag('li')."\n";
}
} elseif ($ismoving) {
echo "<ul class=\"section\">\n";
}
if ($ismoving) {
echo '<li><a title="'.$strmovefull.'"'.
' href="'.$CFG->wwwroot.'/course/mod.php?movetosection='.$section->id.'&sesskey='.sesskey().'">'.
'<img class="movetarget" src="'.$OUTPUT->pix_url('movehere') . '" '.
' alt="'.$strmovehere.'" /></a></li>
';
}
if (!empty($section->sequence) || $ismoving) {
echo "</ul><!--class='section'-->\n\n";
}
}
示例2: print_section
//.........这里部分代码省略.........
}
// Completion
$completion = $hidecompletion ? COMPLETION_TRACKING_NONE : $completioninfo->is_enabled($mod);
if ($completion != COMPLETION_TRACKING_NONE && isloggedin() && !isguestuser() && $mod->uservisible) {
$completiondata = $completioninfo->get_data($mod, true);
$completionicon = '';
if ($isediting) {
switch ($completion) {
case COMPLETION_TRACKING_MANUAL:
$completionicon = 'manual-enabled';
break;
case COMPLETION_TRACKING_AUTOMATIC:
$completionicon = 'auto-enabled';
break;
default:
// wtf
}
} else {
if ($completion == COMPLETION_TRACKING_MANUAL) {
switch ($completiondata->completionstate) {
case COMPLETION_INCOMPLETE:
$completionicon = 'manual-n';
break;
case COMPLETION_COMPLETE:
$completionicon = 'manual-y';
break;
}
} else {
// Automatic
switch ($completiondata->completionstate) {
case COMPLETION_INCOMPLETE:
$completionicon = 'auto-n';
break;
case COMPLETION_COMPLETE:
$completionicon = 'auto-y';
break;
case COMPLETION_COMPLETE_PASS:
$completionicon = 'auto-pass';
break;
case COMPLETION_COMPLETE_FAIL:
$completionicon = 'auto-fail';
break;
}
}
}
if ($completionicon) {
$imgsrc = $OUTPUT->pix_url('i/completion-' . $completionicon);
$imgalt = s(get_string('completion-alt-' . $completionicon, 'completion', $mod->name));
if ($completion == COMPLETION_TRACKING_MANUAL && !$isediting) {
$imgtitle = s(get_string('completion-title-' . $completionicon, 'completion', $mod->name));
$newstate = $completiondata->completionstate == COMPLETION_COMPLETE ? COMPLETION_INCOMPLETE : COMPLETION_COMPLETE;
// In manual mode the icon is a toggle form...
// If this completion state is used by the
// conditional activities system, we need to turn
// off the JS.
if (!empty($CFG->enableavailability) && condition_info::completion_value_used_as_condition($course, $mod)) {
$extraclass = ' preventjs';
} else {
$extraclass = '';
}
echo "\n<form class='togglecompletion{$extraclass}' method='post' action='" . $CFG->wwwroot . "/course/togglecompletion.php'><div>\n<input type='hidden' name='id' value='{$mod->id}' />\n<input type='hidden' name='modulename' value='" . s($mod->name) . "' />\n<input type='hidden' name='sesskey' value='" . sesskey() . "' />\n<input type='hidden' name='completionstate' value='{$newstate}' />\n<input type='image' src='{$imgsrc}' alt='{$imgalt}' title='{$imgtitle}' />\n</div></form>";
} else {
// In auto mode, or when editing, the icon is just an image
echo "<span class='autocompletion'>";
echo "<img src='{$imgsrc}' alt='{$imgalt}' title='{$imgalt}' /></span>";
}
}
}
// If there is content AND a link, then display the content here
// (AFTER any icons). Otherwise it was displayed before
if (!empty($url)) {
echo $contentpart;
}
// Show availability information (for someone who isn't allowed to
// see the activity itself, or for staff)
if (!$mod->uservisible) {
echo '<div class="availabilityinfo">' . $mod->availableinfo . '</div>';
} else {
if ($canviewhidden && !empty($CFG->enableavailability)) {
$ci = new condition_info($mod);
$fullinfo = $ci->get_full_information();
if ($fullinfo) {
echo '<div class="availabilityinfo">' . get_string($mod->showavailability ? 'userrestriction_visible' : 'userrestriction_hidden', 'condition', $fullinfo) . '</div>';
}
}
}
echo html_writer::end_tag('div');
echo html_writer::end_tag('li') . "\n";
}
} elseif ($ismoving) {
echo "<ul class=\"section\">\n";
}
if ($ismoving) {
echo '<li><a title="' . $strmovefull . '"' . ' href="' . $CFG->wwwroot . '/course/mod.php?movetosection=' . $section->id . '&sesskey=' . sesskey() . '">' . '<img class="movetarget" src="' . $OUTPUT->pix_url('movehere') . '" ' . ' alt="' . $strmovehere . '" /></a></li>
';
}
if (!empty($section->sequence) || $ismoving) {
echo "</ul><!--class='section'-->\n\n";
}
}
示例3: course_section_cm_completion
/**
* Renders html for completion box on course page
*
* If completion is disabled, returns empty string
* If completion is automatic, returns an icon of the current completion state
* If completion is manual, returns a form (with an icon inside) that allows user to
* toggle completion
*
* @param stdClass $course course object
* @param completion_info $completioninfo completion info for the course, it is recommended
* to fetch once for all modules in course/section for performance
* @param cm_info $mod module to show completion for
* @param array $displayoptions display options, not used in core
* @return string
*/
public function course_section_cm_completion($course, &$completioninfo, cm_info $mod, $displayoptions = array())
{
global $CFG;
$output = '';
if (!empty($displayoptions['hidecompletion']) || !isloggedin() || isguestuser() || !$mod->uservisible) {
return $output;
}
if ($completioninfo === null) {
$completioninfo = new completion_info($course);
}
$completion = $completioninfo->is_enabled($mod);
if ($completion == COMPLETION_TRACKING_NONE) {
if ($this->page->user_is_editing()) {
$output .= html_writer::span(' ', 'filler');
}
return $output;
}
$completiondata = $completioninfo->get_data($mod, true);
$completionicon = '';
if ($this->page->user_is_editing()) {
switch ($completion) {
case COMPLETION_TRACKING_MANUAL:
$completionicon = 'manual-enabled';
break;
case COMPLETION_TRACKING_AUTOMATIC:
$completionicon = 'auto-enabled';
break;
}
} else {
if ($completion == COMPLETION_TRACKING_MANUAL) {
switch ($completiondata->completionstate) {
case COMPLETION_INCOMPLETE:
$completionicon = 'manual-n';
break;
case COMPLETION_COMPLETE:
$completionicon = 'manual-y';
break;
}
} else {
// Automatic
switch ($completiondata->completionstate) {
case COMPLETION_INCOMPLETE:
$completionicon = 'auto-n';
break;
case COMPLETION_COMPLETE:
$completionicon = 'auto-y';
break;
case COMPLETION_COMPLETE_PASS:
$completionicon = 'auto-pass';
break;
case COMPLETION_COMPLETE_FAIL:
$completionicon = 'auto-fail';
break;
}
}
}
if ($completionicon) {
$formattedname = $mod->get_formatted_name();
$imgalt = get_string('completion-alt-' . $completionicon, 'completion', $formattedname);
if ($this->page->user_is_editing()) {
// When editing, the icon is just an image.
$completionpixicon = new pix_icon('i/completion-' . $completionicon, $imgalt, '', array('title' => $imgalt, 'class' => 'iconsmall'));
$output .= html_writer::tag('span', $this->output->render($completionpixicon), array('class' => 'autocompletion'));
} else {
if ($completion == COMPLETION_TRACKING_MANUAL) {
$imgtitle = get_string('completion-title-' . $completionicon, 'completion', $formattedname);
$newstate = $completiondata->completionstate == COMPLETION_COMPLETE ? COMPLETION_INCOMPLETE : COMPLETION_COMPLETE;
// In manual mode the icon is a toggle form...
// If this completion state is used by the
// conditional activities system, we need to turn
// off the JS.
$extraclass = '';
if (!empty($CFG->enableavailability) && condition_info::completion_value_used_as_condition($course, $mod)) {
$extraclass = ' preventjs';
}
$output .= html_writer::start_tag('form', array('method' => 'post', 'action' => new moodle_url('/course/togglecompletion.php'), 'class' => 'togglecompletion' . $extraclass));
$output .= html_writer::start_tag('div');
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'id', 'value' => $mod->id));
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'modulename', 'value' => $mod->name));
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'completionstate', 'value' => $newstate));
$output .= html_writer::empty_tag('input', array('type' => 'image', 'src' => $this->output->pix_url('i/completion-' . $completionicon), 'alt' => $imgalt, 'title' => $imgtitle, 'aria-live' => 'polite'));
$output .= html_writer::end_tag('div');
$output .= html_writer::end_tag('form');
} else {
//.........这里部分代码省略.........