• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP enrol_get_users_courses函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中enrol_get_users_courses函数的典型用法代码示例。如果您正苦于以下问题:PHP enrol_get_users_courses函数的具体用法?PHP enrol_get_users_courses怎么用?PHP enrol_get_users_courses使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: mycourses

 protected function mycourses($CFG, $sidebar)
 {
     $mycourses = enrol_get_users_courses($_SESSION['USER']->id);
     $courselist = array();
     foreach ($mycourses as $key => $val) {
         $courselist[] = $val->id;
     }
     $content = '';
     for ($x = 1; $x <= sizeof($courselist); $x++) {
         $course = get_course($courselist[$x - 1]);
         $title = $course->fullname;
         if ($course instanceof stdClass) {
             require_once $CFG->libdir . '/coursecatlib.php';
             $course = new course_in_list($course);
         }
         $url = $CFG->wwwroot . "/theme/keats/pix/coursenoimage.jpg";
         foreach ($course->get_course_overviewfiles() as $file) {
             $isimage = $file->is_valid_image();
             $url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage);
             if (!$isimage) {
                 $url = $CFG->wwwroot . "/theme/keats/pix/coursenoimage.jpg";
             }
         }
         $content .= '<div class="view view-second view-mycourse ' . ($x % 3 == 0 ? 'view-nomargin' : '') . '">
                         <img src="' . $url . '" />
                         <div class="mask">
                             <h2>' . $title . '</h2>
                             <a href="' . $CFG->wwwroot . '/course/view.php?id=' . $courselist[$x - 1] . '" class="info">Enter</a>
                         </div>
                     </div>';
     }
     return $content;
 }
开发者ID:simonsCatalyst,项目名称:simonsCatalyst-keats,代码行数:33,代码来源:renderers.php


示例2: display_exams_list

/**
 *	Function to display a teacher's available exams. This uses all the
 *  courses that a teacher is enrolled in and checks which course has 
 *  exams related to it. Shows the exam, the date and adds a 
 */
function display_exams_list()
{
    global $DB, $CFG, $USER;
    $IP_Address = $tableName = 'Exams';
    $user_table = 'user';
    $table = new html_table();
    $table->head = array('Course', 'Date', 'Navigation');
    $table->tablealign = 'center';
    $table->width = '100%';
    $user_courses = enrol_get_users_courses($USER->id, true, '*', 'visible DESC,sortorder ASC');
    /**
     *	Checks the teachers courses with available tests and if exists add to the main page. 
     */
    foreach ($user_courses as $uc) {
        $rec = $DB->get_records_sql('SELECT booklet_id, year_semester_origin 
							FROM {mem_booklet_data}
							WHERE course_id=?', array(intval($uc->id)));
        $row_info = array();
        if (count($rec) > 0) {
            $row = new html_table_row(array($uc->fullname, current($rec)->year_semester_origin, '<div style="text-align: center"><a href=' . $CFG->wwwroot . '/local/memplugin/grid.php?course_id=' . intval($uc->id) . '>' . get_string('startmarking', 'local_memplugin') . '</a></div>'));
            $table->data[] = $row;
        }
    }
    echo html_writer::table($table);
}
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:30,代码来源:exams_list_form.php


示例3: __construct

 /**
  * Constructor. Sets local copies of user preferences and initialises grade_tree.
  * @param int $userid
  * @param object $gpr grade plugin return tracking object
  * @param string $context
  */
 public function __construct($userid, $gpr, $context)
 {
     global $CFG, $COURSE, $DB;
     parent::__construct($COURSE->id, $gpr, $context);
     // Get the user (for full name).
     $this->user = $DB->get_record('user', array('id' => $userid));
     // Load the user's courses.
     $this->courses = enrol_get_users_courses($this->user->id, false, 'id, shortname, showgrades');
     $this->showrank = array();
     $this->showrank['any'] = false;
     $this->showtotalsifcontainhidden = array();
     if ($this->courses) {
         foreach ($this->courses as $course) {
             $this->showrank[$course->id] = grade_get_setting($course->id, 'report_overview_showrank', !empty($CFG->grade_report_overview_showrank));
             if ($this->showrank[$course->id]) {
                 $this->showrank['any'] = true;
             }
             $this->showtotalsifcontainhidden[$course->id] = grade_get_setting($course->id, 'report_overview_showtotalsifcontainhidden', $CFG->grade_report_overview_showtotalsifcontainhidden);
         }
     }
     // base url for sorting by first/last name
     $this->baseurl = $CFG->wwwroot . '/grade/overview/index.php?id=' . $userid;
     $this->pbarurl = $this->baseurl;
     $this->setup_table();
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:31,代码来源:lib.php


示例4: get_content

   public function get_content() {
     global $DB;
     if ($this->content !== null) {
       return $this->content;
     }
       global $CFG, $USER, $PAGE;
       $this->content = new stdClass();
       require_once($CFG->dirroot.'/blocks/queries/lib.php');
       require_once($CFG->dirroot.'/blocks/queries/commentform.php');
       require_once($CFG->dirroot.'/blocks/queries/queries_form.php');
       
       //query to enrol users courses particulars
       $courses = enrol_get_users_courses($USER->id);
     
       //calling function for if login user instructor or not
       $instructorlogin = block_queries_getrole_user($courses,'instructor');
     
       //calling function for if login user registrar or not
       $registrarlogin = block_queries_getrole_user($courses,'registrar');
       
       //calling function for if login user student or not
       $studentlogin = block_queries_getrole_user($courses,'student');
       
       /************calling function for getting data to the logged in user*************/
       $this->content->text = block_queries_display_view($USER,$instructorlogin,$registrarlogin,$studentlogin);
 
       $this->content->footer = '';
       $this->page->requires->js('/blocks/queries/js/commentform_popup.js');
       // Return the content object
       return $this->content;
   }
开发者ID:anilch,项目名称:Personel,代码行数:31,代码来源:block_queries.php


示例5: get_users_courses

 /**
  * Get list of courses user is enrolled in (only active enrolments are returned).
  * Please note the current user must be able to access the course, otherwise the course is not included.
  *
  * @param int $userid
  * @return array of courses
  */
 public static function get_users_courses($userid)
 {
     global $USER, $DB;
     // Do basic automatic PARAM checks on incoming data, using params description
     // If any problems are found then exceptions are thrown with helpful error messages
     $params = self::validate_parameters(self::get_users_courses_parameters(), array('userid' => $userid));
     $courses = enrol_get_users_courses($params['userid'], true, 'id, shortname, fullname, idnumber, visible');
     $result = array();
     foreach ($courses as $course) {
         $context = context_course::instance($course->id, IGNORE_MISSING);
         try {
             self::validate_context($context);
         } catch (Exception $e) {
             // current user can not access this course, sorry we can not disclose who is enrolled in this course!
             continue;
         }
         if ($userid != $USER->id and !has_capability('moodle/course:viewparticipants', $context)) {
             // we need capability to view participants
             continue;
         }
         list($enrolledsqlselect, $enrolledparams) = get_enrolled_sql($context);
         $enrolledsql = "SELECT COUNT(*) FROM ({$enrolledsqlselect}) AS enrolleduserids";
         $enrolledusercount = $DB->count_records_sql($enrolledsql, $enrolledparams);
         $result[] = array('id' => $course->id, 'shortname' => $course->shortname, 'fullname' => $course->fullname, 'idnumber' => $course->idnumber, 'visible' => $course->visible, 'enrolledusercount' => $enrolledusercount);
     }
     return $result;
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:34,代码来源:externallib.php


示例6: message_print_contact_selector

function message_print_contact_selector($countunreadtotal, $usergroup, $user1, $user2, $blockedusers, $onlinecontacts, $offlinecontacts, $strangers, $showcontactactionlinks, $page = 0)
{
    global $PAGE;
    echo html_writer::start_tag('div', array('class' => 'contactselector mdl-align'));
    //if 0 unread messages and they've requested unread messages then show contacts
    if ($countunreadtotal == 0 && $usergroup == VIEW_UNREAD_MESSAGES) {
        $usergroup = VIEW_CONTACTS;
    }
    //if they have no blocked users and they've requested blocked users switch them over to contacts
    if (count($blockedusers) == 0 && $usergroup == VIEW_BLOCKED) {
        $usergroup = VIEW_CONTACTS;
    }
    $onlyactivecourses = true;
    $courses = enrol_get_users_courses($user1->id, $onlyactivecourses);
    $coursecontexts = message_get_course_contexts($courses);
    //we need one of these again so holding on to them
    $strunreadmessages = null;
    if ($countunreadtotal > 0) {
        //if there are unread messages
        $strunreadmessages = get_string('unreadmessages', 'message', $countunreadtotal);
    }
    message_print_usergroup_selector($usergroup, $courses, $coursecontexts, $countunreadtotal, count($blockedusers), $strunreadmessages);
    $refreshpage = false;
    if ($usergroup == VIEW_UNREAD_MESSAGES) {
        message_print_contacts($onlinecontacts, $offlinecontacts, $strangers, $refreshpage, $PAGE->url, 1, $showcontactactionlinks, $strunreadmessages, $user2);
    } else {
        if ($usergroup == VIEW_CONTACTS || $usergroup == VIEW_SEARCH) {
            message_print_contacts($onlinecontacts, $offlinecontacts, $strangers, $refreshpage, $PAGE->url, 0, $showcontactactionlinks, $strunreadmessages, $user2);
        } else {
            if ($usergroup == VIEW_BLOCKED) {
                message_print_blocked_users($blockedusers, $PAGE->url, $showcontactactionlinks, null, $user2);
            } else {
                if (substr($usergroup, 0, 7) == VIEW_COURSE) {
                    $courseidtoshow = intval(substr($usergroup, 7));
                    if (!empty($courseidtoshow) && array_key_exists($courseidtoshow, $coursecontexts) && has_capability('moodle/course:viewparticipants', $coursecontexts[$courseidtoshow])) {
                        message_print_participants($coursecontexts[$courseidtoshow], $courseidtoshow, $PAGE->url, $showcontactactionlinks, null, $page, $user2);
                    } else {
                        //shouldn't get here. User trying to access a course they're not in perhaps.
                        add_to_log(SITEID, 'message', 'view', 'index.php', $usergroup);
                    }
                }
            }
        }
    }
    echo html_writer::start_tag('form', array('action' => 'index.php', 'method' => 'GET'));
    echo html_writer::start_tag('fieldset');
    $managebuttonclass = 'visible';
    if ($usergroup == VIEW_SEARCH) {
        $managebuttonclass = 'hiddenelement';
    }
    $strmanagecontacts = get_string('search', 'message');
    echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'usergroup', 'value' => VIEW_SEARCH));
    echo html_writer::empty_tag('input', array('type' => 'submit', 'value' => $strmanagecontacts, 'class' => $managebuttonclass));
    echo html_writer::end_tag('fieldset');
    echo html_writer::end_tag('form');
    echo html_writer::end_tag('div');
}
开发者ID:vuchannguyen,项目名称:web,代码行数:57,代码来源:lib.php


示例7: execute

 function execute($data, $user, $courseid)
 {
     global $DB, $CFG;
     require_once $CFG->libdir . '/enrollib.php';
     $finalcourses = array();
     $mycourses = enrol_get_users_courses($user->id);
     if (!empty($mycourses)) {
         $finalcourses = array_keys($mycourses);
     }
     return $finalcourses;
 }
开发者ID:adonm,项目名称:learning,代码行数:11,代码来源:plugin.class.php


示例8: definition

 public function definition()
 {
     global $CFG, $USER, $DB;
     $mform = $this->_form;
     $mform->addElement('header', 'general', get_string('askaquestion', 'block_queries'));
     $courses = enrol_get_users_courses($USER->id);
     foreach ($courses as $course) {
         // to get instructors in course level
         $sql = "SELECT u.id, u.email, u.firstname, u.lastname\n                    FROM {context} AS cxt\n                    JOIN {role_assignments} AS ra\n                    ON cxt.id = ra.contextid \n                    JOIN {user} AS u\n                    ON ra.userid = u.id\n                    WHERE cxt.instanceid = {$course->id} AND ra.roleid = 10 AND cxt.contextlevel = 50";
         $instructors = $DB->get_records_sql($sql);
         $instructors12 = array();
         foreach ($instructors as $instructor) {
             $fullname = fullname($instructor);
             $instructors12[$instructor->id . ',instructor'] = $fullname;
         }
     }
     $registraroptions = array();
     foreach ($courses as $course) {
         // to get registrars in course level
         $sql = "SELECT u.id, u.email, u.firstname, u.lastname\n                         FROM {context} AS cxt\n                         JOIN {role_assignments} AS ra\n                         ON cxt.id = ra.contextid \n                         JOIN {user} AS u\n                         ON ra.userid = u.id\n                         WHERE cxt.instanceid = {$course->id} AND ra.roleid = 9 AND cxt.contextlevel = 50";
         $registrars = $DB->get_records_sql($sql);
         foreach ($registrars as $registrar) {
             $registrarfullname = fullname($registrar);
             $registraroptions[$registrar->id . ',registrar'] = $registrarfullname;
         }
     }
     $record = $DB->get_record_sql("SELECT * FROM {user} where id = 2");
     $adminoption = array();
     $adminoption[$record->id . ',admin'] = $record->firstname;
     $options = array(get_string('instructor', 'block_queries') => $instructors12, get_string('registrar', 'block_queries') => $registraroptions, get_string('admin', 'block_queries') => $adminoption);
     $mform->addElement('selectgroups', 'usertype', get_string('usertype', 'block_queries'), $options);
     $mform->addRule('usertype', get_string('required'), 'required', null, 'client');
     $adminoption[$record->id] = $record->firstname;
     $mform->addElement('text', 'subject', get_string('subject', 'block_queries'));
     $mform->setType('subject', PARAM_RAW);
     $mform->addRule('subject', get_string('required'), 'required', null, 'client');
     $mform->addElement('textarea', 'description', get_string('description', 'block_queries'), 'wrap="virtual" rows="3" cols="25"');
     $mform->addRule('description', get_string('required'), 'required', null, 'client');
     $this->add_action_buttons(FALSE, get_string('postquery', 'block_queries'));
     $mform->addElement('html', html_writer::tag('a', get_string('mypreviewqueries', 'block_queries'), array('href' => $CFG->wwwroot . '/blocks/queries/display_queries.php?studentid=' . $USER->id, 'class' => 'mypreviewqueries')));
 }
开发者ID:anilch,项目名称:Personel,代码行数:41,代码来源:queries_form.php


示例9: definition

 function definition()
 {
     global $CFG, $DB, $USER;
     $mform = $this->_form;
     $attributes_heading = 'size="24"';
     $attributes_radio_text = 'size="11"';
     //General Section.
     $mform->addElement('header', 'general', get_string('genheader', 'local_memplugin'));
     //Get list of logged in user's enrolled courses and display as checkboxes.
     $user_courses = enrol_get_users_courses($USER->id, true, '*', 'visible DESC,sortorder ASC');
     $select_course_array = array();
     $select_course_array[0] = '';
     // Add a blank space to the select box.
     $selectgroup = array();
     //TODO Remove below Select code for checkboxes instead of dropdown
     foreach ($user_courses as $uc) {
         $select_course_array[$uc->id] = $uc->fullname;
     }
     $selectgroup[] = $mform->createElement('select', 'coursechoices', get_string('sectionheader', 'local_memplugin'), $select_course_array);
     $mform->addElement('group', 'courseselect', get_string('courses', 'local_memplugin'), $selectgroup, array('<br>'), false);
     //TODO For now we can only handle one course section but uncomment the following and get rid of the above
     //Selection items to make it checkboxes again.
     /*
     
     foreach ($user_courses as $uc){
     	$courses_group[] =& $mform->createElement('advcheckbox', 'courseboxes['.$uc->id.']', null, $uc->fullname, array('group'=>0),array(0,1));
             }
     $mform->addElement('group', 'courseselect', get_string('courses', 'local_memplugin'), $courses_group, array('<br>'), false);
     */
     $mform->addElement('header', 'fileheader', get_string('file', 'local_memplugin'));
     //Switch to a filepicker for now until we figure out how it works.
     //$mform->addElement('filemanager', 'files', get_string('exambatch', 'local_memplugin'), null, array('accepted_types' => 'image/png'));
     $mform->addElement('filepicker', 'userfile', get_string('exambatch', 'local_memplugin'), null, array('accepted_types' => 'application/zip'));
     $mform->closeHeaderBefore('buttonar');
     $buttonarray = array();
     //$buttonarray[] =& $mform->createElement('submit','savebutton', get_string('savebutton', 'local_memplugin'));
     $buttonarray[] =& $mform->createElement('submit', 'markbutton', get_string('markbutton', 'local_memplugin'));
     $buttonarray[] =& $mform->createElement('cancel');
     $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:40,代码来源:mark_exam_form.php


示例10: __construct

 /**
  * Constructor. Sets local copies of user preferences and initialises grade_tree.
  * @param int $userid
  * @param object $gpr grade plugin return tracking object
  * @param string $context
  */
 public function __construct($userid, $gpr, $context)
 {
     global $CFG, $COURSE, $DB;
     parent::__construct($COURSE->id, $gpr, $context);
     // Get the user (for full name).
     $this->user = $DB->get_record('user', array('id' => $userid));
     // Load the user's courses.
     $this->courses = enrol_get_users_courses($this->user->id, false, 'id, shortname, showgrades');
     $this->showrank = array();
     $this->showrank['any'] = false;
     $this->showtotalsifcontainhidden = array();
     $this->studentcourseids = array();
     $this->teachercourses = array();
     $roleids = explode(',', get_config('moodle', 'gradebookroles'));
     if ($this->courses) {
         foreach ($this->courses as $course) {
             $this->showrank[$course->id] = grade_get_setting($course->id, 'report_overview_showrank', !empty($CFG->grade_report_overview_showrank));
             if ($this->showrank[$course->id]) {
                 $this->showrank['any'] = true;
             }
             $this->showtotalsifcontainhidden[$course->id] = grade_get_setting($course->id, 'report_overview_showtotalsifcontainhidden', $CFG->grade_report_overview_showtotalsifcontainhidden);
             $coursecontext = context_course::instance($course->id);
             foreach ($roleids as $roleid) {
                 if (user_has_role_assignment($userid, $roleid, $coursecontext->id)) {
                     $this->studentcourseids[$course->id] = $course->id;
                     // We only need to check if one of the roleids has been assigned.
                     break;
                 }
             }
             if (has_capability('moodle/grade:viewall', $coursecontext, $userid)) {
                 $this->teachercourses[$course->id] = $course;
             }
         }
     }
     // base url for sorting by first/last name
     $this->baseurl = $CFG->wwwroot . '/grade/overview/index.php?id=' . $userid;
     $this->pbarurl = $this->baseurl;
     $this->setup_table();
 }
开发者ID:grug,项目名称:moodle,代码行数:45,代码来源:lib.php


示例11: count_unread_and_courses_messages

 /**
  * Returns unread messages count and courses
  * @return array
  */
 public static function count_unread_and_courses_messages($userid = '0')
 {
     global $DB, $USER;
     //Parameter validation
     //REQUIRED
     $params = self::validate_parameters(self::count_unread_messages_parameters(), array('userid' => $userid));
     //Context validation
     //OPTIONAL but in most web service it should present
     $context = get_context_instance(CONTEXT_USER, $USER->id);
     self::validate_context($context);
     //Capability checking
     //OPTIONAL but in most web service it should present
     if (!has_capability('moodle/user:viewdetails', $context)) {
         throw new moodle_exception('cannotviewprofile');
     }
     $messagecount = $DB->count_records_select('message', 'useridto=' . (int) $userid);
     $courses = enrol_get_users_courses($params['userid'], true, 'id, shortname, fullname, idnumber, visible');
     $result = array('messagecount' => $messagecount, 'courses' => array());
     foreach ($courses as $course) {
         $context = context_course::instance($course->id, IGNORE_MISSING);
         try {
             self::validate_context($context);
         } catch (Exception $e) {
             // current user can not access this course, sorry we can not disclose who is enrolled in this course!
             continue;
         }
         if ($userid != $USER->id and !has_capability('moodle/course:viewparticipants', $context)) {
             // we need capability to view participants
             continue;
         }
         list($enrolledsqlselect, $enrolledparams) = get_enrolled_sql($context);
         $enrolledsql = "SELECT COUNT('x') FROM ({$enrolledsqlselect}) enrolleduserids";
         $enrolledusercount = $DB->count_records_sql($enrolledsql, $enrolledparams);
         $result['courses'][] = array('id' => $course->id, 'shortname' => $course->shortname, 'fullname' => $course->fullname, 'idnumber' => $course->idnumber, 'visible' => $course->visible, 'enrolledusercount' => $enrolledusercount);
     }
     return $result;
 }
开发者ID:otago,项目名称:moodlecount,代码行数:41,代码来源:externallib.php


示例12: block_mystats_mycourses

function block_mystats_mycourses()
{
    global $USER;
    $mycourses = array();
    $count = 0;
    $enrolledcourses = enrol_get_users_courses($USER->id);
    foreach ($enrolledcourses as $course) {
        if (isset($USER->lastcourseaccess[$course->id])) {
            $course->lastaccess = $USER->lastcourseaccess[$course->id];
        } else {
            $course->lastaccess = 0;
        }
        $mycourses[$course->id] = $course;
        $count++;
    }
    if (is_enabled_auth('mnet')) {
        $remotecourses = get_my_remotecourses();
        foreach ($remotecourses as $course) {
            $mycourses[$course->id] = $course;
            $count++;
        }
    }
    return $mycourses;
}
开发者ID:bmbrands,项目名称:moodle-block_mystats,代码行数:24,代码来源:locallib.php


示例13: get_users_courses

 /**
  * Get list of courses user is enrolled in (only active enrolments are returned).
  *
  * Please note the current user must be able to access the course, otherwise the course is not included.
  *
  * @param int $userid
  * @return array of courses
  */
 public static function get_users_courses($userid)
 {
     global $USER;
     // Do basic automatic PARAM checks on incoming data, using params description
     // If any problems are found then exceptions are thrown with helpful error messages
     $params = self::validate_parameters(self::get_users_courses_parameters(), array('userid' => $userid));
     $courses = enrol_get_users_courses($params['userid'], true, 'id, shortname, fullname, idnumber, visible');
     $result = array();
     foreach ($courses as $course) {
         $context = get_context_instance(CONTEXT_COURSE, $course->id);
         try {
             self::validate_context($context);
         } catch (Exception $e) {
             // current user can not access this course, sorry we can not disclose who is enrolled in this course!
             continue;
         }
         if ($userid != $USER->id and !has_capability('moodle/course:viewparticipants', $context)) {
             // we need capability to view participants
             continue;
         }
         $result[] = array('id' => $course->id, 'shortname' => $course->shortname, 'fullname' => $course->fullname, 'idnumber' => $course->idnumber, 'visible' => $course->visible);
     }
     return $result;
 }
开发者ID:rosenclever,项目名称:moodle,代码行数:32,代码来源:externallib.php


示例14: block_mycourses_users

function block_mycourses_users()
{
    global $CFG, $DB, $USER, $OUTPUT;
    $courses = enrol_get_users_courses($USER->id);
    //print_object($courses);
    $output = '';
    foreach ($courses as $course) {
        $summary = $DB->get_record_sql("SELECT * FROM {course} WHERE id = {$course->id}");
        //print_object($summary);
        $output .= "<div>";
        $output .= html_writer::tag('b', $course->fullname, array());
        $output .= html_writer::tag('p', $summary->summary, array());
        $output .= html_writer::tag('a', get_string('launch', 'block_mycourses'), array());
        $data = array();
        $line = array();
        $user = $DB->get_record_sql("SELECT firstname FROM {user} WHERE id = {$USER->id}");
        $line[] = $user->firstname;
        $date1 = date('d/m/Y', $course->startdate);
        $line[] = $date1;
        $completed_date = $DB->get_record_sql("SELECT * FROM {course_completions} WHERE course = {$course->id}");
        $date2 = date('d/m/Y', $completed_date->timecompleted);
        if (!empty($date2)) {
            $line[] = "--";
        } else {
            $line[] = $date2;
        }
        $data[] = $line;
        $table = new html_table();
        $table->head = array(get_string('training_name', 'block_mycourses'), get_string('training_code', 'block_mycourses'), get_string('launch', 'block_mycourses'));
        $table->data = $data;
        $output .= html_writer::table($table);
        $output .= html_writer::tag('a', get_string('launch', 'block_mycourses'), array());
        $output .= "</div>";
    }
    return $output;
}
开发者ID:syedhameed,项目名称:sc,代码行数:36,代码来源:lib.php


示例15: load_for_user


//.........这里部分代码省略.........
                 $messageargs['user2'] = $user->id;
             }
             if ($course->id != $SITE->id) {
                 $messageargs['viewing'] = MESSAGE_VIEW_COURSE . $course->id;
             }
             $url = new moodle_url('/message/index.php', $messageargs);
             $usernode->add(get_string('messages', 'message'), $url, self::TYPE_SETTING, null, 'messages');
         }
         // Add the "My private files" link.
         // This link doesn't have a unique display for course context so only display it under the user's profile.
         if ($issitecourse && $iscurrentuser && has_capability('moodle/user:manageownfiles', $usercontext)) {
             $url = new moodle_url('/user/files.php');
             $usernode->add(get_string('privatefiles'), $url, self::TYPE_SETTING);
         }
         // Add a node to view the users notes if permitted.
         if (!empty($CFG->enablenotes) && has_any_capability(array('moodle/notes:manage', 'moodle/notes:view'), $coursecontext)) {
             $url = new moodle_url('/notes/index.php', array('user' => $user->id));
             if ($coursecontext->instanceid != SITEID) {
                 $url->param('course', $coursecontext->instanceid);
             }
             $usernode->add(get_string('notes', 'notes'), $url);
         }
         // Show the grades node.
         if ($issitecourse && $iscurrentuser || has_capability('moodle/user:viewdetails', $usercontext)) {
             require_once $CFG->dirroot . '/user/lib.php';
             // Set the grades node to link to the "Grades" page.
             if ($course->id == SITEID) {
                 $url = user_mygrades_url($user->id, $course->id);
             } else {
                 // Otherwise we are in a course and should redirect to the user grade report (Activity report version).
                 $url = new moodle_url('/course/user.php', array('mode' => 'grade', 'id' => $course->id, 'user' => $user->id));
             }
             if ($USER->id != $user->id) {
                 $usernode->add(get_string('grades', 'grades'), $url, self::TYPE_SETTING, null, 'usergrades');
             } else {
                 $usernode->add(get_string('grades', 'grades'), $url);
             }
         }
         // If the user is the current user add the repositories for the current user.
         $hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
         if (!$iscurrentuser && $course->id == $SITE->id && has_capability('moodle/user:viewdetails', $usercontext) && (!in_array('mycourses', $hiddenfields) || has_capability('moodle/user:viewhiddendetails', $coursecontext))) {
             // Add view grade report is permitted.
             $reports = core_component::get_plugin_list('gradereport');
             arsort($reports);
             // User is last, we want to test it first.
             $userscourses = enrol_get_users_courses($user->id);
             $userscoursesnode = $usernode->add(get_string('courses'));
             $count = 0;
             foreach ($userscourses as $usercourse) {
                 if ($count === (int) $CFG->navcourselimit) {
                     $url = new moodle_url('/user/profile.php', array('id' => $user->id, 'showallcourses' => 1));
                     $userscoursesnode->add(get_string('showallcourses'), $url);
                     break;
                 }
                 $count++;
                 $usercoursecontext = context_course::instance($usercourse->id);
                 $usercourseshortname = format_string($usercourse->shortname, true, array('context' => $usercoursecontext));
                 $usercoursenode = $userscoursesnode->add($usercourseshortname, new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $usercourse->id)), self::TYPE_CONTAINER);
                 $gradeavailable = has_capability('moodle/grade:viewall', $usercoursecontext);
                 if (!$gradeavailable && !empty($usercourse->showgrades) && is_array($reports) && !empty($reports)) {
                     foreach ($reports as $plugin => $plugindir) {
                         if (has_capability('gradereport/' . $plugin . ':view', $usercoursecontext)) {
                             // Stop when the first visible plugin is found.
                             $gradeavailable = true;
                             break;
                         }
                     }
                 }
                 if ($gradeavailable) {
                     $url = new moodle_url('/grade/report/index.php', array('id' => $usercourse->id));
                     $usercoursenode->add(get_string('grades'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/grades', ''));
                 }
                 // Add a node to view the users notes if permitted.
                 if (!empty($CFG->enablenotes) && has_any_capability(array('moodle/notes:manage', 'moodle/notes:view'), $usercoursecontext)) {
                     $url = new moodle_url('/notes/index.php', array('user' => $user->id, 'course' => $usercourse->id));
                     $usercoursenode->add(get_string('notes', 'notes'), $url, self::TYPE_SETTING);
                 }
                 if (can_access_course($usercourse, $user->id, '', true)) {
                     $usercoursenode->add(get_string('entercourse'), new moodle_url('/course/view.php', array('id' => $usercourse->id)), self::TYPE_SETTING, null, null, new pix_icon('i/course', ''));
                 }
                 $reporttab = $usercoursenode->add(get_string('activityreports'));
                 $reports = get_plugin_list_with_function('report', 'extend_navigation_user', 'lib.php');
                 foreach ($reports as $reportfunction) {
                     $reportfunction($reporttab, $user, $usercourse);
                 }
                 $reporttab->trim_if_empty();
             }
         }
         // Let plugins hook into user navigation.
         $pluginsfunction = get_plugins_with_function('extend_navigation_user', 'lib.php');
         foreach ($pluginsfunction as $plugintype => $plugins) {
             if ($plugintype != 'report') {
                 foreach ($plugins as $pluginfunction) {
                     $pluginfunction($usernode, $user, $usercontext, $course, $coursecontext);
                 }
             }
         }
     }
     return true;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:101,代码来源:navigationlib.php


示例16: att_get_user_courses_attendances

function att_get_user_courses_attendances($userid)
{
    global $DB;
    $usercourses = enrol_get_users_courses($userid);
    list($usql, $uparams) = $DB->get_in_or_equal(array_keys($usercourses), SQL_PARAMS_NAMED, 'cid0');
    $sql = "SELECT att.id as attid, att.course as courseid, course.fullname as coursefullname,\n                   course.startdate as coursestartdate, att.name as attname, att.grade as attgrade\n              FROM {attendance} att\n              JOIN {course} course\n                   ON att.course = course.id\n             WHERE att.course {$usql}\n          ORDER BY coursefullname ASC, attname ASC";
    $params = array_merge($uparams, array('uid' => $userid));
    return $DB->get_records_sql($sql, $params);
}
开发者ID:webcursosuai,项目名称:moodle-mod_attendance,代码行数:9,代码来源:locallib.php


示例17: require_once

$PAGE->requires->js('/teacher/html-table-search.js',true);

$PAGE->requires->css('/teacher/bootstrap-select.css',true);
$PAGE->requires->js('/teacher/bootstrap-select.js',true);

echo "<input id='baseurl' type='hidden' value=".$CFG->wwwroot ."/>";
require_once($CFG->dirroot.'/teacher/customlib.php');
$PAGE->requires->js('/teacher/custom.js',true);
$PAGE->requires->css('/teacher/styles.css',true);


if(user_has_role_assignment($USER->id,3)) {
    $context = context_user::instance($USER->id);
    $PAGE->set_context($context);
    $enrolledcourses = block_course_overview_get_sorted_courses();
    $cours = enrol_get_users_courses($USER->id);
    echo $OUTPUT->header();


?>
<div id="demo">

        <div id="watchlist">
<a href="<?php echo $CFG->wwwroot?>/teacher/dashboard.php" class='link'>Courses</a>
<a href="<?php echo $CFG->wwwroot?>/teacher/reports.php" class='link'>Reports</a>
   <a href="<?php echo $CFG->wwwroot?>/teacher/watchlist.php" class='current link' >Watchlist</a>
<div class="yui3-skin-sam">
    <div id="course-sel">
<?php

    $html = html_writer::start_tag('form', array('action' => new moodle_url('/teacher/inx.php'),
开发者ID:kmahesh541,项目名称:mitclone,代码行数:31,代码来源:watchlist.php


示例18: user_get_user_details_courses

/**
 * Tries to obtain user details, either recurring directly to the user's system profile
 * or through one of the user's course enrollments (course profile).
 *
 * @param object $user The user.
 * @return array if unsuccessful or the allowed user details.
 */
function user_get_user_details_courses($user)
{
    global $USER;
    $userdetails = null;
    //  Get the courses that the user is enrolled in (only active).
    $courses = enrol_get_users_courses($user->id, true);
    $systemprofile = false;
    if (can_view_user_details_cap($user) || $user->id == $USER->id || has_coursecontact_role($user->id)) {
        $systemprofile = true;
    }
    // Try using system profile.
    if ($systemprofile) {
        $userdetails = user_get_user_details($user, null);
    } else {
        // Try through course profile.
        foreach ($courses as $course) {
            if (can_view_user_details_cap($user, $course) || $user->id == $USER->id || has_coursecontact_role($user->id)) {
                $userdetails = user_get_user_details($user, $course);
            }
        }
    }
    return $userdetails;
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:30,代码来源:lib.php


示例19: format_string

            }
            if ($course->groupmode != NOGROUPS) {
                $groupstr .= ' <a href="' . $CFG->wwwroot . '/user/index.php?id=' . $course->id . '&amp;group=' . $group->id . '">' . format_string($group->name) . '</a>,';
            } else {
                $groupstr .= ' ' . format_string($group->name);
                // the user/index.php shows groups only when course in group mode
            }
        }
        if ($groupstr !== '') {
            print_row(get_string("group") . ":", rtrim($groupstr, ', '));
        }
    }
}
// Show other courses they may be in
if (!isset($hiddenfields['mycourses'])) {
    if ($mycourses = enrol_get_users_courses($user->id, true, NULL, 'visible DESC,sortorder ASC')) {
        $shown = 0;
        $courselisting = '';
        foreach ($mycourses as $mycourse) {
            if ($mycourse->category) {
                if ($mycourse->id != $course->id) {
                    $class = '';
                    if ($mycourse->visible == 0) {
                        $ccontext = get_context_instance(CONTEXT_COURSE, $mycourse->id);
                        if (!has_capability('moodle/course:viewhiddencourses', $ccontext)) {
                            continue;
                        }
                        $class = 'class="dimmed"';
                    }
                    $courselisting .= "<a href=\"{$CFG->wwwroot}/user/view.php?id={$user->id}&amp;course={$mycourse->id}\" {$class} >" . format_string($mycourse->fullname) . "</a>, ";
                } else {
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:view.php


示例20: message_print_contact_selector


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP enrol_into_course函数代码示例发布时间:2022-05-15
下一篇:
PHP enrol_get_shared_courses函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap