本文整理汇总了PHP中condition_info::get_full_information方法的典型用法代码示例。如果您正苦于以下问题:PHP condition_info::get_full_information方法的具体用法?PHP condition_info::get_full_information怎么用?PHP condition_info::get_full_information使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类condition_info
的用法示例。
在下文中一共展示了condition_info::get_full_information方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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_availability
/**
* Renders HTML to show course module availability information (for someone who isn't allowed
* to see the activity itself, or for staff)
*
* @param cm_info $mod
* @param array $displayoptions
* @return string
*/
public function course_section_cm_availability(cm_info $mod, $displayoptions = array())
{
global $CFG;
if (!$mod->uservisible) {
// this is a student who is not allowed to see the module but might be allowed
// to see availability info (i.e. "Available from ...")
if (!empty($mod->showavailability) && !empty($mod->availableinfo)) {
$output = html_writer::tag('div', $mod->availableinfo, array('class' => 'availabilityinfo'));
}
return $output;
}
// this is a teacher who is allowed to see module but still should see the
// information that module is not available to all/some students
$modcontext = context_module::instance($mod->id);
$canviewhidden = has_capability('moodle/course:viewhiddenactivities', $modcontext);
if ($canviewhidden && !empty($CFG->enableavailability)) {
// Don't add availability information if user is not editing and activity is hidden.
if ($mod->visible || $this->page->user_is_editing()) {
$hidinfoclass = '';
if (!$mod->visible) {
$hidinfoclass = 'hide';
}
$ci = new condition_info($mod);
$fullinfo = $ci->get_full_information();
if ($fullinfo) {
return '<div class="availabilityinfo ' . $hidinfoclass . '">' . get_string($mod->showavailability ? 'userrestriction_visible' : 'userrestriction_hidden', 'condition', $fullinfo) . '</div>';
}
}
}
return '';
}
示例4: strtolower
function get_course_mods($id, $username = '')
{
global $CFG, $DB;
$username = utf8_decode($username);
$username = strtolower($username);
if ($username) {
$user = get_complete_user_data('username', $username);
}
$modinfo = get_fast_modinfo($id);
$sections = $modinfo->get_section_info_all();
$forum = forum_get_course_forum($id, 'news');
$news_forum_id = $forum->id;
$mods = get_fast_modinfo($id)->get_cms();
$modnames = get_module_types_names();
$modnamesplural = get_module_types_names(true);
$modnamesused = get_fast_modinfo($id)->get_used_module_names();
$rawmods = get_course_mods($id);
$context = context_course::instance($id);
// Kludge to use username param to get non visible sections and modules
$username_orig = $username;
if ($username_orig == 'joomdle_get_not_visible') {
$username = '';
}
$e = array();
foreach ($sections as $section) {
if ($username_orig != 'joomdle_get_not_visible') {
if (!$section->visible) {
continue;
}
}
$sectionmods = explode(",", $section->sequence);
foreach ($sectionmods as $modnumber) {
if (empty($mods[$modnumber])) {
continue;
}
$mod = $mods[$modnumber];
if ($username_orig != 'joomdle_get_not_visible') {
if (!$mod->visible) {
continue;
}
}
$resource['completion_info'] = '';
if ($username) {
$cm = get_coursemodule_from_id(false, $mod->id);
if (!\core_availability\info_module::is_user_visible($cm, $user->id)) {
if (empty($mod->availableinfo)) {
// Mod not visible, and no completion info to show
continue;
}
$resource['available'] = 0;
$ci = new condition_info($mod);
$resource['completion_info'] = $ci->get_full_information();
} else {
$resource['available'] = 1;
}
} else {
$resource['available'] = 1;
}
$e[$section->section]['section'] = $section->section;
$e[$section->section]['name'] = $section->name;
$e[$section->section]['summary'] = file_rewrite_pluginfile_urls($section->summary, 'pluginfile.php', $context->id, 'course', 'section', $section->id);
$e[$section->section]['summary'] = str_replace('pluginfile.php', '/auth/joomdle/pluginfile_joomdle.php', $e[$section->section]['summary']);
$resource['id'] = $mod->id;
$resource['name'] = $mod->name;
$resource['mod'] = $mod->modname;
// Get content
$resource['content'] = '';
$modname = $mod->modname;
$functionname = $modname . "_get_coursemodule_info";
if (file_exists("{$CFG->dirroot}/mod/{$modname}/lib.php")) {
include_once "{$CFG->dirroot}/mod/{$modname}/lib.php";
if ($hasfunction = function_exists($functionname)) {
if ($info = $functionname($rawmods[$modnumber])) {
$resource['content'] = $info->content;
}
}
}
// Format for mod->icon is: f/type-24
$type = substr($mod->icon, 2);
$parts = explode('-', $type);
$type = $parts[0];
$resource['type'] = $type;
//In forum, type is unused, so we use it for forum type: news/general
if ($mod->modname == 'forum') {
$cm = get_coursemodule_from_id('forum', $mod->id);
if ($cm->instance == $news_forum_id) {
$resource['type'] = 'news';
}
}
/*
if ($mod->modname == 'resource')
{
// Get display options for resource
$params = array ($mod->instance);
$query = "SELECT display from {$CFG->prefix}resource where id = ?";
$record = $DB->get_record_sql ($query, $params);
$resource['display'] = $record->display;
}
else $resource['display'] = 0;
//.........这里部分代码省略.........
示例5: test_is_available
/**
* Tests the is_available function for modules. This does not test all the
* conditions and stuff, because it only needs to check that the system
* connects through to the real availability API. Also tests
* get_full_information function.
*/
public function test_is_available()
{
// Create course.
$generator = $this->getDataGenerator();
$course = $generator->create_course();
// Create activity with no restrictions and one with date restriction.
$page1 = $generator->get_plugin_generator('mod_page')->create_instance(array('course' => $course));
$time = time() + 100;
$avail = '{"op":"|","show":true,"c":[{"type":"date","d":">=","t":' . $time . '}]}';
$page2 = $generator->get_plugin_generator('mod_page')->create_instance(array('course' => $course, 'availability' => $avail));
// No conditions.
$ci = new condition_info((object) array('id' => $page1->cmid), CONDITION_MISSING_EVERYTHING);
$this->assertDebuggingCalled();
$this->assertTrue($ci->is_available($text, false, 0));
$this->assertDebuggingCalled();
$this->assertEquals('', $text);
// Date condition.
$ci = new condition_info((object) array('id' => $page2->cmid), CONDITION_MISSING_EVERYTHING);
$this->assertDebuggingCalled();
$this->assertFalse($ci->is_available($text));
$this->assertDebuggingCalled();
$expectedtime = userdate($time, get_string('strftimedate', 'langconfig'));
$this->assertContains($expectedtime, $text);
// Full information display.
$text = $ci->get_full_information();
$this->assertDebuggingCalled();
$expectedtime = userdate($time, get_string('strftimedate', 'langconfig'));
$this->assertContains($expectedtime, $text);
}
示例6: array
function test_is_available()
{
global $DB, $USER;
$courseid = $this->make_course();
// No conditions
$cmid = $this->make_course_module($courseid);
$ci = new condition_info((object) array('id' => $cmid), CONDITION_MISSING_EVERYTHING);
$this->assertTrue($ci->is_available($text, false, 0));
$this->assertEqual('', $text);
// Time (from)
$time = time() + 100;
$cmid = $this->make_course_module($courseid, array('availablefrom' => $time));
$ci = new condition_info((object) array('id' => $cmid), CONDITION_MISSING_EVERYTHING);
$this->assertFalse($ci->is_available($text));
$this->assert(new PatternExpectation('/' . preg_quote(userdate($time, get_string('strftimedate', 'langconfig'))) . '/'), $text);
$time = time() - 100;
$cmid = $this->make_course_module($courseid, array('availablefrom' => $time));
$ci = new condition_info((object) array('id' => $cmid), CONDITION_MISSING_EVERYTHING);
$this->assertTrue($ci->is_available($text));
$this->assertEqual('', $text);
$this->assert(new PatternExpectation('/' . preg_quote(userdate($time, get_string('strftimedate', 'langconfig'))) . '/'), $ci->get_full_information());
// Time (until)
$cmid = $this->make_course_module($courseid, array('availableuntil' => time() - 100));
$ci = new condition_info((object) array('id' => $cmid), CONDITION_MISSING_EVERYTHING);
$this->assertFalse($ci->is_available($text));
$this->assertEqual('', $text);
// Completion
$oldid = $cmid;
$cmid = $this->make_course_module($courseid);
$this->make_section($courseid, array($oldid, $cmid));
$oldcm = $DB->get_record('course_modules', array('id' => $oldid));
$oldcm->completion = COMPLETION_TRACKING_MANUAL;
$DB->update_record('course_modules', $oldcm);
$ci = new condition_info((object) array('id' => $cmid), CONDITION_MISSING_EVERYTHING);
$ci->add_completion_condition($oldid, COMPLETION_COMPLETE);
$this->assertFalse($ci->is_available($text, false));
$this->assertEqual(get_string('requires_completion_1', 'condition', 'xxx'), $text);
$completion = new completion_info($DB->get_record('course', array('id' => $courseid)));
$completion->update_state($oldcm, COMPLETION_COMPLETE);
completion_info::wipe_session_cache();
condition_info::wipe_session_cache();
$this->assertTrue($ci->is_available($text));
$this->assertFalse($ci->is_available($text, false, $USER->id + 1));
completion_info::wipe_session_cache();
condition_info::wipe_session_cache();
$completion = new completion_info($DB->get_record('course', array('id' => $courseid)));
$completion->update_state($oldcm, COMPLETION_INCOMPLETE);
$this->assertFalse($ci->is_available($text));
$ci->wipe_conditions();
$ci->add_completion_condition($oldid, COMPLETION_INCOMPLETE);
condition_info::wipe_session_cache();
$this->assertTrue($ci->is_available($text));
$this->assertTrue($ci->is_available($text, false, $USER->id + 1));
condition_info::wipe_session_cache();
$this->assertTrue($ci->is_available($text, true));
// Grade
$ci->wipe_conditions();
// Add a fake grade item
$gradeitemid = $DB->insert_record('grade_items', (object) array('courseid' => $courseid, 'itemname' => 'frog'));
// Add a condition on a value existing...
$ci->add_grade_condition($gradeitemid, null, null, true);
$this->assertFalse($ci->is_available($text));
$this->assertEqual(get_string('requires_grade_any', 'condition', 'frog'), $text);
// Fake it existing
$DB->insert_record('grade_grades', (object) array('itemid' => $gradeitemid, 'userid' => $USER->id, 'finalgrade' => 3.78));
condition_info::wipe_session_cache();
$this->assertTrue($ci->is_available($text));
condition_info::wipe_session_cache();
$this->assertTrue($ci->is_available($text, true));
// Now require that user gets more than 3.78001
$ci->wipe_conditions();
$ci->add_grade_condition($gradeitemid, 3.78001, null, true);
condition_info::wipe_session_cache();
$this->assertFalse($ci->is_available($text));
$this->assertEqual(get_string('requires_grade_min', 'condition', 'frog'), $text);
// ...just on 3.78...
$ci->wipe_conditions();
$ci->add_grade_condition($gradeitemid, 3.78, null, true);
condition_info::wipe_session_cache();
$this->assertTrue($ci->is_available($text));
// ...less than 3.78
$ci->wipe_conditions();
$ci->add_grade_condition($gradeitemid, null, 3.78, true);
condition_info::wipe_session_cache();
$this->assertFalse($ci->is_available($text));
$this->assertEqual(get_string('requires_grade_max', 'condition', 'frog'), $text);
// ...less than 3.78001
$ci->wipe_conditions();
$ci->add_grade_condition($gradeitemid, null, 3.78001, true);
condition_info::wipe_session_cache();
$this->assertTrue($ci->is_available($text));
// ...in a range that includes it
$ci->wipe_conditions();
$ci->add_grade_condition($gradeitemid, 3, 4, true);
condition_info::wipe_session_cache();
$this->assertTrue($ci->is_available($text));
// ...in a range that doesn't include it
$ci->wipe_conditions();
$ci->add_grade_condition($gradeitemid, 4, 5, true);
condition_info::wipe_session_cache();
//.........这里部分代码省略.........
示例7: strtolower
function get_course_mods($id, $username = '')
{
global $CFG, $DB;
$username = utf8_decode($username);
$username = strtolower($username);
if ($username) {
$user = get_complete_user_data('username', $username);
}
$sections = get_all_sections($id);
$forum = forum_get_course_forum($id, 'news');
$news_forum_id = $forum->id;
get_all_mods($id, $mods, $modnames, $modnamesplural, $modnamesused);
$context = get_context_instance(CONTEXT_COURSE, $id);
$e = array();
foreach ($sections as $section) {
if (!$section->visible) {
continue;
}
$sectionmods = explode(",", $section->sequence);
foreach ($sectionmods as $modnumber) {
if (empty($mods[$modnumber])) {
continue;
}
$mod = $mods[$modnumber];
$resource['completion_info'] = '';
if ($username) {
$cm = get_coursemodule_from_id(false, $mod->id);
if (!coursemodule_visible_for_user($cm, $user->id)) {
if (!$mod->showavailability) {
// Mod not visible, and no completion info to show
continue;
}
$resource['available'] = 0;
$ci = new condition_info($mod);
$resource['completion_info'] = $ci->get_full_information();
} else {
$resource['available'] = 1;
}
} else {
$resource['available'] = 1;
}
$e[$section->section]['section'] = $section->section;
$e[$section->section]['name'] = $section->name;
$e[$section->section]['summary'] = file_rewrite_pluginfile_urls($section->summary, 'pluginfile.php', $context->id, 'course', 'section', $section->id);
$e[$section->section]['summary'] = str_replace('pluginfile.php', '/auth/joomdle/pluginfile_joomdle.php', $e[$section->section]['summary']);
$resource['id'] = $mod->id;
$resource['name'] = $mod->name;
$resource['mod'] = $mod->modname;
// Format for mod->icon is: f/type-24
$type = substr($mod->icon, 2);
$parts = explode('-', $type);
$type = $parts[0];
$resource['type'] = $type;
//In forum, type is unused, so we use it for forum type: news/general
if ($mod->modname == 'forum') {
$cm = get_coursemodule_from_id('forum', $mod->id);
if ($cm->instance == $news_forum_id) {
$resource['type'] = 'news';
}
}
$e[$section->section]['mods'][] = $resource;
}
}
return $e;
}