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


PHP get_courses函数代码示例

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


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

示例1: definition

 function definition()
 {
     $mform =& $this->_form;
     $mform->addElement('header', 'general', get_string('message', 'message'));
     //$mform->addElement('htmleditor', 'messagebody', get_string('messagebody'), array('rows'=>15, 'cols'=>60));
     //$mform->addRule('messagebody', '', 'required', null, 'client');
     //$mform->setHelpButton('messagebody', array('writing', 'reading', 'questions', 'richtext'), false, 'editorhelpbutton');
     //$mform->addElement('format', 'format', get_string('format'));
     $courses = get_courses();
     foreach ($courses as $course) {
         //$mform->addElement('checkbox','courseid',get_string('course')." ".$course->shortname);
         $courselist[$course->id] = $course->shortname;
     }
     //$select = &$mform->addElement('select', 'colors', get_string('colors'), array('red', 'blue', 'green'), $attributes);
     //$select->setMultiple(true);
     $select =& $mform->addElement('select', 'courses', get_string('courses'), $courselist, 'size="15"');
     $select->setMultiple(true);
     //$mform->addElement('group', 'coursesgrp', get_string('courses'), $select , ' ', false);
     $allroles = array();
     if ($roles = get_all_roles()) {
         foreach ($roles as $role) {
             $rolename = strip_tags(format_string($role->name, true));
             $allroles[$role->id] = $rolename;
         }
     }
     $mform->addElement('select', 'role', get_string('roles'), $allroles);
     $mform->setDefault('role', 'Student');
     $this->add_action_buttons();
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:29,代码来源:user_courselist_form.php

示例2: fill_table

 function fill_table()
 {
     global $CFG;
     $numusers = $this->get_numusers();
     if ($courses = get_courses('all', null, 'c.id, c.shortname')) {
         foreach ($courses as $course) {
             // Get course grade_item
             $grade_item = grade_item::fetch(array('itemtype' => 'course', 'courseid' => $course->id));
             // Get the grade
             $finalgrade = get_field('grade_grades', 'finalgrade', 'itemid', $grade_item->id, 'userid', $this->user->id);
             /// prints rank
             if ($finalgrade) {
                 /// find the number of users with a higher grade
                 $sql = "SELECT COUNT(DISTINCT(userid))\n                            FROM {$CFG->prefix}grade_grades\n                            WHERE finalgrade > {$finalgrade}\n                            AND itemid = {$grade_item->id}";
                 $rank = count_records_sql($sql) + 1;
                 $rankdata = "{$rank}/{$numusers}";
             } else {
                 // no grade, no rank
                 $rankdata = "-";
             }
             $courselink = '<a href="' . $CFG->wwwroot . '/grade/report/user/index.php?id=' . $course->id . '">' . $course->shortname . '</a>';
             $this->table->add_data(array($courselink, round(grade_to_percentage($finalgrade, $grade_item->grademin, $grade_item->grademax), 1) . '%', $rankdata));
         }
         return true;
     } else {
         notify(get_string('nocourses', 'grades'));
         return false;
     }
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:29,代码来源:lib.php

示例3: execute

 public function execute()
 {
     $setting = trim($this->arguments[2]);
     $value = trim($this->arguments[3]);
     switch ($this->arguments[0]) {
         case 'course':
             if (!self::setCourseSetting($this->arguments[1], $setting, $value)) {
                 // the setting was not applied, exit with a non-zero exit code
                 cli_error('');
             }
             break;
         case 'category':
             //get all courses in category (recursive)
             $courselist = get_courses($this->arguments[1], '', 'c.id');
             $succeeded = 0;
             $failed = 0;
             foreach ($courselist as $course) {
                 if (self::setCourseSetting($course->id, $setting, $value)) {
                     $succeeded++;
                 } else {
                     $failed++;
                 }
             }
             if ($failed == 0) {
                 echo "OK - successfully modified {$succeeded} courses\n";
             } else {
                 echo "WARNING - failed to mofify {$failed} courses (successfully modified {$succeeded})\n";
             }
             break;
     }
 }
开发者ID:dariogs,项目名称:moosh,代码行数:31,代码来源:CourseConfigSet.php

示例4: gen_course_list

/**
* This function generates the list of courses for <select> control
* using the specified string filter and/or course id's filter
*
* @param string $strfilter The course name filter
* @param array $arrayfilter Course ID's filter, NULL by default, which means not to use id filter
* @return string
*/
function gen_course_list($strfilter = '', $arrayfilter = NULL)
{
    $courselist = array();
    $catcnt = 0;
    // get the list of course categories
    $categories = get_categories();
    foreach ($categories as $cat) {
        // for each category, add the <optgroup> to the string array first
        $courselist[$catcnt] = '<optgroup label="' . htmlspecialchars($cat->name) . '">';
        // get the course list in that category
        $courses = get_courses($cat->id, 'c.sortorder ASC', 'c.fullname, c.id');
        $coursecnt = 0;
        // for each course, check the specified filter
        foreach ($courses as $course) {
            if (!empty($strfilter) && strripos($course->fullname, $strfilter) === false || $arrayfilter !== NULL && in_array($course->id, $arrayfilter) === false) {
                continue;
            }
            // if we pass the filter, add the option to the current string
            $courselist[$catcnt] .= '<option value="' . $course->id . '">' . $course->fullname . '</option>';
            $coursecnt++;
        }
        // if no courses pass the filter in that category, delete the current string
        if ($coursecnt == 0) {
            unset($courselist[$catcnt]);
        } else {
            $courselist[$catcnt] .= '</optgroup>';
            $catcnt++;
        }
    }
    // return the html code with categorized courses
    return implode(' ', $courselist);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:40,代码来源:index.php

示例5: getStudentsByCourse

function getStudentsByCourse($courseId)
{

$courses = get_courses();
            $context = context_course::instance($courseId);//course id
   
            $students = get_role_users(5, $context); //student context
                  return   $students ;

}
开发者ID:kmahesh541,项目名称:mitclone,代码行数:10,代码来源:teacher_reports.php

示例6: get_course_options

 /**
  * Gets the list of courses that can be used used to generate a test.
  *
  * @return array The list of options as courseid => name
  */
 public static function get_course_options()
 {
     $courses = get_courses('all', 'c.sortorder ASC', 'c.id, c.shortname, c.fullname');
     if (!$courses) {
         print_error('error_nocourses', 'tool_generator');
     }
     $options = array();
     unset($courses[1]);
     foreach ($courses as $course) {
         $options[$course->id] = $course->fullname . '(' . $course->shortname . ')';
     }
     return $options;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:18,代码来源:testplan_backend.php

示例7: get_moodle_courses

function get_moodle_courses()
{
    $moodle_courses = array();
    foreach (get_courses() as $course) {
        if (isset($config->moodlecoursefieldid) && $config->moodlecoursefieldid == 'idnumber') {
            $course_identify = $course->idnumber;
        } else {
            $course_identify = $course->shortname;
        }
        $moodle_courses[] = $course_identify;
    }
    return $moodle_courses;
}
开发者ID:blionut,项目名称:elearning,代码行数:13,代码来源:courses.php

示例8: definition

 function definition()
 {
     $mform = $this->_form;
     // course
     $courses = array();
     $dbcourses = get_courses();
     foreach ($dbcourses as $dbcourseid => $dbcourse) {
         if ($dbcourse->id > 1) {
             // 1 = system course, ala front-page. probably don't want it there!
             $courses[$dbcourseid] = $dbcourse->fullname;
         }
     }
     $mform->addElement('select', 'course', get_string('promptcourse', 'block_enrol_token_manager'), $courses);
     $mform->addHelpButton('course', 'promptcourse', 'block_enrol_token_manager');
     // cohorts
     $context = context_system::instance();
     $cohorts = array();
     $dbcohorts = cohort_get_cohorts($context->id);
     foreach ($dbcohorts['cohorts'] as $dbcohort) {
         $cohorts[$dbcohort->id] = $dbcohort->name;
     }
     // cohort selection
     $mform->addElement('header', 'cohorts', get_string('cohort_selection', 'block_enrol_token_manager'));
     $mform->addElement('select', 'cohortexisting', get_string('promptcohortexisting', 'block_enrol_token_manager'), $cohorts);
     $mform->addElement('static', 'cohortor', '', 'OR');
     $mform->addHelpButton('cohortor', 'cohortor', 'block_enrol_token_manager');
     $mform->addElement('text', 'cohortnew', get_string('promptcohortnew', 'block_enrol_token_manager'), 'maxlength="253" size="25"');
     $mform->setType('cohortnew', PARAM_CLEANHTML);
     // token prefix
     $mform->addElement('header', 'tokens', get_string('token_generation', 'block_enrol_token_manager'));
     $mform->addElement('text', 'prefix', get_string('promptprefix', 'block_enrol_token_manager'), 'maxlength="4" size="4"');
     $mform->addHelpButton('prefix', 'promptprefix_help', 'block_enrol_token_manager');
     // $mform->addElement('static', 'prefixinstructions', get_string('prefixinstructions', 'block_enrol_token_manager'));
     $mform->setType('prefix', PARAM_ALPHANUMEXT);
     // seats per token
     $mform->addElement('text', 'seatspertoken', get_string('promptseats', 'block_enrol_token_manager'), 'maxlength="3" size="3"');
     $mform->addHelpButton('seatspertoken', 'promptseats', 'block_enrol_token_manager');
     $mform->setType('seatspertoken', PARAM_INT);
     // number of tokens
     $mform->addElement('text', 'tokennumber', get_string('prompttokennum', 'block_enrol_token_manager'), 'maxlength="3" size="3"');
     $mform->addHelpButton('tokennumber', 'prompttokennum', 'block_enrol_token_manager');
     $mform->setType('tokennumber', PARAM_INT);
     // expiry date
     $mform->addElement('date_selector', 'expirydate', get_string('promptexpirydate', 'block_enrol_token_manager'), array('optional' => true));
     // email to
     $mform->addElement('text', 'emailaddress', get_string('emailaddressprompt', 'block_enrol_token_manager'), 'maxlength="128" size="50"');
     $mform->setType('emailaddress', PARAM_EMAIL);
     // buttons
     $this->add_action_buttons(false, get_string('createtokens', 'block_enrol_token_manager'));
 }
开发者ID:frumbert,项目名称:moodle-token-enrolment,代码行数:50,代码来源:create_tokens.php

示例9: check_semester

/**
 * Function to check if a semester is already known in the MUMIE
 * 
 * @param object $semester - the semester to be checked
 */
function check_semester($semester)
{
    global $CFG;
    $delimiter = 'moodle-' . $CFG->prefix . 'course_categories-';
    $sync_id_parts = explode($delimiter, $semester->syncid);
    $sort = 'c.sortorder ASC';
    $cat_classes = get_courses($sync_id_parts[1], $sort, $fields = 'c.id');
    //TODO: isn't this deprecated???
    foreach ($cat_classes as $cat_class) {
        if (record_exists('mumiemodule', 'course', $cat_class->id)) {
            return true;
            break;
        }
    }
    return false;
}
开发者ID:TU-Berlin,项目名称:Mumie,代码行数:21,代码来源:internalchecks.php

示例10: execute

 public function execute()
 {
     global $CFG, $DB;
     //require_once($CFG->dirroot . '/lib/accesslib.php');
     $mode = $this->arguments[0];
     $id = $this->arguments[1];
     $blocktype = $this->arguments[2];
     // name of the block (in English)
     $pagetypepattern = $this->arguments[3];
     // in which page types it will be available ('course-*' , 'mod-*' ...)
     $region = $this->arguments[4];
     // into which page region it will be inserted ('side-pre' , 'side-post' ...)
     $weight = $this->arguments[5];
     // sort/insert order
     //$showinsubcontexts = $this->arguments[6]; // show block in sub context?
     if ($this->expandedOptions['showinsubcontexts']) {
         $showinsubcontexts = true;
     } else {
         $showinsubcontexts = false;
     }
     switch ($mode) {
         case 'category':
             $context = context_coursecat::instance($id, MUST_EXIST);
             self::blockAdd($context->id, $blocktype, $pagetypepattern, $region, $weight, $showinsubcontexts);
             break;
         case 'course':
             $context = context_course::instance($id, MUST_EXIST);
             self::blockAdd($context->id, $blocktype, $pagetypepattern, $region, $weight, $showinsubcontexts);
             break;
         case 'categorycourses':
             //get all courses in category (recursive)
             $courselist = get_courses($id, '', 'c.id');
             foreach ($courselist as $course) {
                 $context = context_course::instance($course->id, MUST_EXIST);
                 self::blockAdd($context->id, $blocktype, $pagetypepattern, $region, $weight, $showinsubcontexts);
                 echo "debug: courseid={$course->id} \n";
             }
             break;
     }
 }
开发者ID:dariogs,项目名称:moosh,代码行数:40,代码来源:BlockAdd.php

示例11: print_log_ods

function print_log_ods($course, $user, $date, $order = 'l.time DESC', $modname, $modid, $modaction, $groupid)
{
    global $CFG, $DB;
    require_once "{$CFG->libdir}/odslib.class.php";
    if (!($logs = build_logs_array($course, $user, $date, $order, '', '', $modname, $modid, $modaction, $groupid))) {
        return false;
    }
    $courses = array();
    if ($course->id == SITEID) {
        $courses[0] = '';
        if ($ccc = get_courses('all', 'c.id ASC', 'c.id,c.shortname')) {
            foreach ($ccc as $cc) {
                $courses[$cc->id] = $cc->shortname;
            }
        }
    } else {
        $courses[$course->id] = $course->shortname;
    }
    $count = 0;
    $ldcache = array();
    $tt = getdate(time());
    $today = mktime(0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]);
    $strftimedatetime = get_string("strftimedatetime");
    $nroPages = ceil(count($logs) / (EXCELROWS - FIRSTUSEDEXCELROW + 1));
    $filename = 'logs_' . userdate(time(), get_string('backupnameformat', 'langconfig'), 99, false);
    $filename .= '.ods';
    $workbook = new MoodleODSWorkbook('-');
    $workbook->send($filename);
    $worksheet = array();
    $headers = array(get_string('course'), get_string('time'), get_string('ip_address'), get_string('fullnameuser'), get_string('action'), get_string('info'));
    // Creating worksheets
    for ($wsnumber = 1; $wsnumber <= $nroPages; $wsnumber++) {
        $sheettitle = get_string('logs') . ' ' . $wsnumber . '-' . $nroPages;
        $worksheet[$wsnumber] = $workbook->add_worksheet($sheettitle);
        $worksheet[$wsnumber]->set_column(1, 1, 30);
        $worksheet[$wsnumber]->write_string(0, 0, get_string('savedat') . userdate(time(), $strftimedatetime));
        $col = 0;
        foreach ($headers as $item) {
            $worksheet[$wsnumber]->write(FIRSTUSEDEXCELROW - 1, $col, $item, '');
            $col++;
        }
    }
    if (empty($logs['logs'])) {
        $workbook->close();
        return true;
    }
    $formatDate =& $workbook->add_format();
    $formatDate->set_num_format(get_string('log_excel_date_format'));
    $row = FIRSTUSEDEXCELROW;
    $wsnumber = 1;
    $myxls =& $worksheet[$wsnumber];
    foreach ($logs['logs'] as $log) {
        if (isset($ldcache[$log->module][$log->action])) {
            $ld = $ldcache[$log->module][$log->action];
        } else {
            $ld = $DB->get_record('log_display', array('module' => $log->module, 'action' => $log->action));
            $ldcache[$log->module][$log->action] = $ld;
        }
        if ($ld && is_numeric($log->info)) {
            // ugly hack to make sure fullname is shown correctly
            if ($ld->mtable == 'user' and $ld->field == $DB->sql_concat('firstname', "' '", 'lastname')) {
                $log->info = fullname($DB->get_record($ld->mtable, array('id' => $log->info)), true);
            } else {
                $log->info = $DB->get_field($ld->mtable, $ld->field, array('id' => $log->info));
            }
        }
        // Filter log->info
        $log->info = format_string($log->info);
        $log->info = strip_tags(urldecode($log->info));
        // Some XSS protection
        if ($nroPages > 1) {
            if ($row > EXCELROWS) {
                $wsnumber++;
                $myxls =& $worksheet[$wsnumber];
                $row = FIRSTUSEDEXCELROW;
            }
        }
        $coursecontext = context_course::instance($course->id);
        $myxls->write_string($row, 0, format_string($courses[$log->course], true, array('context' => $coursecontext)));
        $myxls->write_date($row, 1, $log->time);
        $myxls->write_string($row, 2, $log->ip);
        $fullname = fullname($log, has_capability('moodle/site:viewfullnames', $coursecontext));
        $myxls->write_string($row, 3, $fullname);
        $actionurl = $CFG->wwwroot . make_log_url($log->module, $log->url);
        $myxls->write_string($row, 4, $log->module . ' ' . $log->action . ' (' . $actionurl . ')');
        $myxls->write_string($row, 5, $log->info);
        $row++;
    }
    $workbook->close();
    return true;
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:91,代码来源:lib.php

示例12: site_scale_used

/**
 * This function returns the number of activities using scaleid in the entire site
 *
 * @deprecated since Moodle 3.1
 * @param int $scaleid
 * @param array $courses
 * @return int
 */
function site_scale_used($scaleid, &$courses)
{
    $return = 0;
    debugging('site_scale_used() is deprecated and never used, plugins can implement <modname>_scale_used_anywhere, ' . 'all implementations of <modname>_scale_used are now ignored', DEBUG_DEVELOPER);
    if (!is_array($courses) || count($courses) == 0) {
        $courses = get_courses("all", false, "c.id, c.shortname");
    }
    if (!empty($scaleid)) {
        if (is_array($courses) && count($courses) > 0) {
            foreach ($courses as $course) {
                $return += course_scale_used($course->id, $scaleid);
            }
        }
    }
    return $return;
}
开发者ID:evltuma,项目名称:moodle,代码行数:24,代码来源:deprecatedlib.php

示例13: notify

             notify(get_string('missingfield', 'error', $key));
             $headersOk = false;
         }
     }
 }
 if ($headersOk) {
     $usersnew = 0;
     $usersupdated = 0;
     $userserrors = 0;
     $usersdeleted = 0;
     $renames = 0;
     $renameerrors = 0;
     $deleteerrors = 0;
     $newusernames = array();
     // We'll need courses a lot, so fetch it early and keep it in memory, indexed by their shortname
     $tmp =& get_courses('all', '', 'id,shortname,visible');
     $courses = array();
     foreach ($tmp as $c) {
         $courses[$c->shortname] = $c;
     }
     unset($tmp);
     echo '<p id="results">';
     while (!feof($fp)) {
         $errors = '';
         $user = new object();
         // by default, use the local mnet id (this may be changed in the file)
         $user->mnethostid = $CFG->mnet_localhost_id;
         $line = explode($csv_delimiter, fgets($fp, LINE_MAX_SIZE));
         ++$linenum;
         // add fields to user object
         foreach ($line as $key => $value) {
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:31,代码来源:uploaduser.php

示例14: array

        }
    }
    if ($swapcategory and $movecategory) {
        $DB->set_field('course_categories', 'sortorder', $swapcategory->sortorder, array('id' => $movecategory->id));
        $DB->set_field('course_categories', 'sortorder', $movecategory->sortorder, array('id' => $swapcategory->id));
        cache_helper::purge_by_event('changesincoursecat');
        add_to_log(SITEID, "category", "move", "editcategory.php?id=$movecategory->id", $movecategory->id);
    }

    // Finally reorder courses.
    fix_course_sortorder();
}

if ($coursecat->id && $canmanage && $resort && confirm_sesskey()) {
    // Resort the category.
    if ($courses = get_courses($coursecat->id, '', 'c.id,c.fullname,c.sortorder')) {
        core_collator::asort_objects_by_property($courses, 'fullname', core_collator::SORT_NATURAL);
        $i = 1;
        foreach ($courses as $course) {
            $DB->set_field('course', 'sortorder', $coursecat->sortorder + $i, array('id' => $course->id));
            $i++;
        }
        // This should not be needed but we do it just to be safe.
        fix_course_sortorder();
        cache_helper::purge_by_event('changesincourse');
    }
}

if (!empty($moveto) && ($data = data_submitted()) && confirm_sesskey()) {
    // Move a specified course to a new category.
    // User must have category update in both cats to perform this.
开发者ID:number33,项目名称:moodle,代码行数:31,代码来源:manage.php

示例15: calendar_course_filter_selector

function calendar_course_filter_selector($getvars = '')
{
    global $USER, $SESSION;
    if (empty($USER->id) or isguest()) {
        return '';
    }
    if (has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_SYSTEM)) && !empty($CFG->calendar_adminseesall)) {
        $courses = get_courses('all', 'c.shortname', 'c.id,c.shortname');
    } else {
        $courses = get_my_courses($USER->id, 'shortname');
    }
    unset($courses[SITEID]);
    $courseoptions[SITEID] = get_string('fulllistofcourses');
    foreach ($courses as $course) {
        $courseoptions[$course->id] = format_string($course->shortname);
    }
    if (is_numeric($SESSION->cal_courses_shown)) {
        $selected = $SESSION->cal_courses_shown;
    } else {
        $selected = '';
    }
    return popup_form(CALENDAR_URL . 'set.php?var=setcourse&amp;' . $getvars . '&amp;id=', $courseoptions, 'cal_course_flt', $selected, '', '', '', true);
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:23,代码来源:view.php


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