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


PHP course_enrolment_manager::get_total_users方法代码示例

本文整理汇总了PHP中course_enrolment_manager::get_total_users方法的典型用法代码示例。如果您正苦于以下问题:PHP course_enrolment_manager::get_total_users方法的具体用法?PHP course_enrolment_manager::get_total_users怎么用?PHP course_enrolment_manager::get_total_users使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在course_enrolment_manager的用法示例。


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

示例1: time

}
$now = time();
$timefrom = 100 * floor(($now - $timetoshowusers) / 100);
// Round to nearest 100 seconds for better query cache
$params['now'] = $now;
$params['timefrom'] = $timefrom;
list($esqljoin, $eparams) = get_enrolled_sql($context_module);
$params = array_merge($params, $eparams);
$params['courseid'] = $cid;
//var_dump($params);
$userfields = user_picture::fields('u', array('username'));
$csql = "SELECT COUNT(u.id)\n                      FROM {user} u {$groupmembers}\n                     WHERE u.lastaccess > :timefrom\n                           AND u.lastaccess <= :now\n                           AND u.deleted = 0\n                           {$groupselect}";
$usercount = $DB->count_records_sql($csql, $params);
//var_dump($usercount);
$manager = new course_enrolment_manager($PAGE, $course, $filter = '', $role = '', $search = '', $fgroup = '', $status = '');
$totalenrolled = $manager->get_total_users();
echo '<div class="container container-demo" style="width: 1170px;margin-right: auto;margin-left: auto;">

	<div class="report">';
echo '<div id="flip" >
<p id="fl" style="text-align:right;padding-right:20px;margin-top:5px" ><i class="fa fa-angle-double-up" style="font-size:18px;"></i>
<span id="titile-status">
<span style="float:left;margin-right:180px;margin-left:40px;" id="ccourse">Course : ' . $course->fullname . ' </span><span id="ctopic" style="float:left;margin-right:180px;"> Topic : Inheritance</span>     <span style="float:left;margin-right:180px;" id="cactivity">Activity : Quiz</span> <i style="float:right" class="fa fa-angle-double-down" style="font-size:18px;"></i>

</span>
</p>
</div>';
echo '<div id="panel"><div class="tleft" ><form style="margin: 0px;padding-top: 0px;">
				<table style="width:100%">
					<tr>
						<td>
开发者ID:kmahesh541,项目名称:moodle_vpl,代码行数:31,代码来源:testcenter-150.php

示例2: array

        $PAGE->set_heading($pageheading);
        echo $OUTPUT->header();
        echo $OUTPUT->heading(fullname($user));
        if (!is_null($mform)) {
            $mform->display();
        } else {
            echo $pagecontent;
        }
        echo $OUTPUT->footer();
        exit;
    }
}
$renderer = $PAGE->get_renderer('core_enrol');
$fields = array('userdetails' => array('picture' => false, 'firstname' => get_string('firstname'), 'lastname' => get_string('lastname'), 'email' => get_string('email')), 'lastseen' => get_string('lastaccess'), 'role' => get_string('roles', 'role'), 'group' => get_string('groups', 'group'), 'enrol' => get_string('enrolmentinstances', 'enrol'));
$table->set_fields($fields, $renderer);
$canassign = has_capability('moodle/role:assign', $manager->get_context());
$users = $manager->get_users_for_display($renderer, $PAGE->url, $table->sort, $table->sortdirection, $table->page, $table->perpage);
foreach ($users as $userid => &$user) {
    $user['picture'] = $OUTPUT->render($user['picture']);
    $user['role'] = $renderer->user_roles_and_actions($userid, $user['roles'], $manager->get_assignable_roles(), $canassign, $PAGE->url);
    $user['group'] = $renderer->user_groups_and_actions($userid, $user['groups'], $manager->get_all_groups(), has_capability('moodle/course:managegroups', $manager->get_context()), $PAGE->url);
    $user['enrol'] = $renderer->user_enrolments_and_actions($userid, $user['enrolments'], $PAGE->url);
}
$table->set_total_users($manager->get_total_users());
$table->set_users($users);
$PAGE->set_title($PAGE->course->fullname . ': ' . get_string('totalenrolledusers', 'enrol', $manager->get_total_users()));
$PAGE->set_heading($PAGE->title);
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('enrolledusers', 'enrol'));
echo $renderer->render($table);
echo $OUTPUT->footer();
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:31,代码来源:users.php

示例3: test_get_total_users

 /**
  * Verify get_total_users() returned number of users expected in every situation.
  */
 public function test_get_total_users()
 {
     global $PAGE;
     $this->resetAfterTest();
     // All users filtering.
     $manager = new course_enrolment_manager($PAGE, $this->course);
     $totalusers = $manager->get_total_users();
     $this->assertEquals(6, $totalusers, 'All users must be returned when no filtering is applied.');
     // Student role filtering.
     $manager = new course_enrolment_manager($PAGE, $this->course, null, 5);
     $totalusers = $manager->get_total_users();
     $this->assertEquals(5, $totalusers, 'Only students must be returned when student role filtering is applied.');
     // Teacher role filtering.
     $manager = new course_enrolment_manager($PAGE, $this->course, null, 3);
     $totalusers = $manager->get_total_users();
     $this->assertEquals(1, $totalusers, 'Only teacher must be returned when teacher role filtering is applied.');
     // Search user filtering.
     $manager = new course_enrolment_manager($PAGE, $this->course, null, 0, 'userall');
     $totalusers = $manager->get_total_users();
     $this->assertEquals(1, $totalusers, 'Only searchable user must be returned when search filtering is applied.');
     // Group 1 filtering.
     $manager = new course_enrolment_manager($PAGE, $this->course, null, 0, '', $this->groups['group1']->id);
     $totalusers = $manager->get_total_users();
     $this->assertEquals(2, $totalusers, 'Only group members must be returned when group filtering is applied.');
     // Group 2 filtering.
     $manager = new course_enrolment_manager($PAGE, $this->course, null, 0, '', $this->groups['group2']->id);
     $totalusers = $manager->get_total_users();
     $this->assertEquals(3, $totalusers, 'Only group members must be returned when group filtering is applied.');
     // 'No groups' filtering.
     $manager = new course_enrolment_manager($PAGE, $this->course, null, 0, '', -1);
     $totalusers = $manager->get_total_users();
     $this->assertEquals(2, $totalusers, 'Only non-group members must be returned when \'no groups\' filtering is applied.');
     // Active users filtering.
     $manager = new course_enrolment_manager($PAGE, $this->course, null, 0, '', 0, ENROL_USER_ACTIVE);
     $totalusers = $manager->get_total_users();
     $this->assertEquals(5, $totalusers, 'Only active users must be returned when active users filtering is applied.');
     // Suspended users filtering.
     $manager = new course_enrolment_manager($PAGE, $this->course, null, 0, '', 0, ENROL_USER_SUSPENDED);
     $totalusers = $manager->get_total_users();
     $this->assertEquals(1, $totalusers, 'Only suspended users must be returned when suspended users filtering is applied.');
 }
开发者ID:janeklb,项目名称:moodle,代码行数:44,代码来源:course_enrolment_manager_test.php

示例4: process_uploaded_groups

 /**
  * enrol and add user to groups in course
  * @param object $course
  * @param csv_import_reader $reader
  * @param int $roleid
  */
 public function process_uploaded_groups($course, $reader, $roleid)
 {
     global $DB, $PAGE;
     $usercol = null;
     // Index of username column.
     $groupcol = null;
     // Index of group column.
     // Find the index of the needed columns.
     $i = 0;
     foreach ($reader->get_columns() as $col) {
         $col = strtoupper(trim($col));
         switch ($col) {
             case 'USERNAME':
                 $usercol = $i;
                 break;
             case 'GROUP':
                 $groupcol = $i;
                 break;
         }
         $i++;
     }
     // Get the manual enrolment plugin.
     $enrolinstances = enrol_get_instances($course->id, true);
     $manualinstance = null;
     foreach ($enrolinstances as $instance) {
         if ($instance->enrol == 'manual') {
             $manualinstance = $instance;
             break;
         }
     }
     $manualenroler = enrol_get_plugin('manual');
     // Get the list of enrolled users for the course.
     $manager = new course_enrolment_manager($PAGE, $course);
     $totalusers = $manager->get_total_users();
     /*
      * Since the number of fields being retrieved are limited (email, id, lastaccess, and lastseen),
      * I feel comfortable retrieving the entire enrolled userbase for this course.
      */
     $users = $manager->get_users('firstname', 'ASC', 0, $totalusers);
     $groups = $manager->get_all_groups();
     $groupids = array();
     foreach ($groups as $group) {
         $groupids[$group->name] = $group->id;
     }
     // Prep the returned array.
     $output = array('group_created' => array(), 'user_enrolled' => array(), 'member_added' => array(), 'error' => array('user_not_found' => array(), 'group_failed' => array(), 'enrol_failed' => array(), 'member_failed' => array(), 'user_not_added' => array()));
     // Loop through the records.
     $reader->init();
     while ($line = $reader->next()) {
         $username = trim($line[$usercol]);
         $groupname = trim($line[$groupcol]);
         // Check if the user exists.
         $user = $DB->get_record('user', array('username' => $username));
         if ($user === false) {
             $output['error']['user_not_found'][] = $username;
             continue;
         }
         // Enroll the user as needed.
         if (!isset($users[$user->id])) {
             try {
                 $manualenroler->enrol_user($manualinstance, $user->id, $roleid);
                 $output['user_enrolled'][] = $username;
             } catch (Exception $e) {
                 $output['error']['enroll_failed'][] = $username;
             }
         }
         // Create the group as needed.
         if (!isset($groupids[$groupname])) {
             if ($groupname != '') {
                 $data = new stdClass();
                 $data->courseid = $course->id;
                 $data->name = $groupname;
                 $newgroupid = groups_create_group($data);
             } else {
                 $newgroupid = false;
             }
             if ($newgroupid === false) {
                 if ($groupname != '') {
                     $output['error']['group_failed'][] = $groupname;
                 }
             } else {
                 $groupids[$groupname] = $newgroupid;
                 $output['group_created'][] = $groupname;
             }
         }
         // Add the user to the group.
         if ($groupname != '') {
             if (groups_add_member($groupids[$groupname], $user->id)) {
                 if (!isset($output['member_added'][$groupname])) {
                     $output['member_added'][$groupname] = array();
                 }
                 $output['member_added'][$groupname][] = $username;
             } else {
                 if (!isset($output['error']['member_failed'][$groupname])) {
//.........这里部分代码省略.........
开发者ID:at-tools,项目名称:moodle-block_uploadgroups,代码行数:101,代码来源:lib.php


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