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

PHP get_courses函数代码示例

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

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



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


示例16: bigbluebuttonbn_import_get_courses_for_select

function bigbluebuttonbn_import_get_courses_for_select(array $bbbsession)
{
    if ($bbbsession['administrator']) {
        $courses = get_courses('all', 'c.id ASC', 'c.id,c.shortname,c.fullname');
        //It includes the name of the site as a course (category 0), so remove the first one
        unset($courses["1"]);
    } else {
        $courses = enrol_get_users_courses($bbbsession['userID'], false, 'id,shortname,fullname');
    }
    $courses_for_select = [];
    foreach ($courses as $course) {
        if ($course->id != $bbbsession['course']->id) {
            $courses_for_select[$course->id] = $course->fullname;
        }
    }
    return $courses_for_select;
}
开发者ID:blindsidenetworks,项目名称:moodle-mod_bigbluebuttonbn,代码行数:17,代码来源:locallib.php


示例17: print_category_info

/**
 * Prints the category info in indented fashion
 * This function is only used by print_whole_category_list() above
 */
function print_category_info($category, $depth = 0, $showcourses = false)
{
    global $CFG, $DB, $OUTPUT;
    $strsummary = get_string('summary');
    $catlinkcss = null;
    if (!$category->visible) {
        $catlinkcss = array('class' => 'dimmed');
    }
    static $coursecount = null;
    if (null === $coursecount) {
        // only need to check this once
        $coursecount = $DB->count_records('course') <= FRONTPAGECOURSELIMIT;
    }
    if ($showcourses and $coursecount) {
        $catimage = '<img src="' . $OUTPUT->pix_url('i/course') . '" alt="" />';
    } else {
        $catimage = "&nbsp;";
    }
    $courses = get_courses($category->id, 'c.sortorder ASC', 'c.id,c.sortorder,c.visible,c.fullname,c.shortname,c.summary');
    $context = get_context_instance(CONTEXT_COURSECAT, $category->id);
    $fullname = format_string($category->name, true, array('context' => $context));
    if ($showcourses and $coursecount) {
        echo '<div class="categorylist clearfix">';
        $cat = '';
        $cat .= html_writer::tag('div', $catimage, array('class' => 'image'));
        $catlink = html_writer::link(new moodle_url('/course/category.php', array('id' => $category->id)), $fullname, $catlinkcss);
        $cat .= html_writer::tag('div', $catlink, array('class' => 'name'));
        $html = '';
        if ($depth > 0) {
            for ($i = 0; $i < $depth; $i++) {
                $html = html_writer::tag('div', $html . $cat, array('class' => 'indentation'));
                $cat = '';
            }
        } else {
            $html = $cat;
        }
        echo html_writer::tag('div', $html, array('class' => 'category'));
        echo html_writer::tag('div', '', array('class' => 'clearfloat'));
        // does the depth exceed maxcategorydepth
        // maxcategorydepth == 0 or unset meant no limit
        $limit = !(isset($CFG->maxcategorydepth) && $depth >= $CFG->maxcategorydepth - 1);
        if ($courses && ($limit || $CFG->maxcategorydepth == 0)) {
            foreach ($courses as $course) {
                $linkcss = null;
                if (!$course->visible) {
                    $linkcss = array('class' => 'dimmed');
                }
                $coursename = get_course_display_name_for_list($course);
                $courselink = html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), format_string($coursename), $linkcss);
                // print enrol info
                $courseicon = '';
                if ($icons = enrol_get_course_info_icons($course)) {
                    foreach ($icons as $pix_icon) {
                        $courseicon = $OUTPUT->render($pix_icon) . ' ';
                    }
                }
                $coursecontent = html_writer::tag('div', $courseicon . $courselink, array('class' => 'name'));
                if ($course->summary) {
                    $link = new moodle_url('/course/info.php?id=' . $course->id);
                    $actionlink = $OUTPUT->action_link($link, '<img alt="' . $strsummary . '" src="' . $OUTPUT->pix_url('i/info') . '" />', new popup_action('click', $link, 'courseinfo', array('height' => 400, 'width' => 500)), array('title' => $strsummary));
                    $coursecontent .= html_writer::tag('div', $actionlink, array('class' => 'info'));
                }
                $html = '';
                for ($i = 0; $i <= $depth; $i++) {
                    $html = html_writer::tag('div', $html . $coursecontent, array('class' => 'indentation'));
                    $coursecontent = '';
                }
                echo html_writer::tag('div', $html, array('class' => 'course clearfloat'));
            }
        }
        echo '</div>';
    } else {
        echo '<div class="categorylist">';
        $html = '';
        $cat = html_writer::link(new moodle_url('/course/category.php', array('id' => $category->id)), $fullname, $catlinkcss);
        if (count($courses) > 0) {
            $cat .= html_writer::tag('span', ' (' . count($courses) . ')', array('title' => get_string('numberofcourses'), 'class' => 'numberofcourse'));
        }
        if ($depth > 0) {
            for ($i = 0; $i < $depth; $i++) {
                $html = html_writer::tag('div', $html . $cat, array('class' => 'indentation'));
                $cat = '';
            }
        } else {
            $html = $cat;
        }
        echo html_writer::tag('div', $html, array('class' => 'category'));
        echo html_writer::tag('div', '', array('class' => 'clearfloat'));
        echo '</div>';
    }
}
开发者ID:numbas,项目名称:moodle,代码行数:95,代码来源:lib.php


示例18: get_context_instance

//$courseid = required_param('id', PARAM_INTEGER);
//$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$context = get_context_instance(CONTEXT_COURSECAT, $catid);
$PAGE->set_context($context);
if (!has_capability('block/timetracker:manageworkers', $context)) {
    print_error('You do not have permission to run this report.');
}
$categoryinfo = $DB->get_record('course_categories', array('id' => $catid));
$catname = str_replace(' ', '', $categoryinfo->name);
$filename = date("Y_m_d") . '_' . $catname . '_Earnings.csv';
header('Content-type: application/ms-excel');
header('Content-Disposition: attachment; filename=' . $filename);
//$headers = "Department,Last Name,First Name,Email,Earnings,Max Term Earnings,Remaining \n";
$headers = "DET,DETCode,ID,Hours,Amount,Budget,Department,Last Name,First Name,Max Term Earnings,Remaining \n";
echo $headers;
$courses = get_courses($catid, 'fullname ASC', 'c.id, c.shortname');
foreach ($courses as $course) {
    if ($active) {
        //find all active workers
        $workers = $DB->get_records('block_timetracker_workerinfo', array('active' => 1, 'courseid' => $course->id));
    } else {
        //find all workers
        $workers = $DB->get_records('block_timetracker_workerinfo', array('courseid' => $course->id));
    }
    foreach ($workers as $worker) {
        $units = get_split_units($start, $end, $worker->id, $course->id);
        //don't include the ones that aren't between $start and $end
        foreach ($units as $key => $unit) {
            if (!($unit->timein >= $start && $unit->timeout <= $end)) {
                unset($units[$key]);
            }
开发者ID:hughesbradc,项目名称:TimeTracker,代码行数:31,代码来源:batch_earnings.php


示例19: array

     $rolename->roleid = $roleid;
     $rolename->name = $value;
     $newrolenames[] = $rolename;
 }
 // This is for updating all categories and courses.
 $cats = array(coursecat::get($id));
 $courses = array();
 if ($categories = coursecat::get($id)->get_children()) {
     foreach ($categories as $cat) {
         array_push($cats, $cat);
         $cats = array_merge($cats, coursecat::get($cat->id)->get_children());
     }
 }
 // Update all the category's.
 foreach ($cats as $coursecat) {
     $courses = array_merge($courses, get_courses($coursecat->id));
     foreach ($newrolenames as $role) {
         if (!$role->name) {
             $DB->delete_records('cat_role_names', array('catid' => $coursecat->id, 'roleid' => $role->roleid));
         } else {
             if ($rolename = $DB->get_record('cat_role_names', array('catid' => $coursecat->id, 'roleid' => $role->roleid))) {
                 $rolename->name = $role->name;
                 $DB->update_record('cat_role_names', $rolename);
             } else {
                 $rolename = new stdClass();
                 $rolename->catid = $coursecat->id;
                 $rolename->roleid = $role->roleid;
                 $rolename->name = $role->name;
                 $DB->insert_record('cat_role_names', $rolename);
             }
         }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:31,代码来源:categoryroles.php


示例20: allmetadata_print_big_search_form


//.........这里部分代码省略.........
    echo '<input type="hidden" name="htoday" value="0" />';
    echo '<input type="hidden" name="htomonth" value="0" />';
    echo '<input type="hidden" name="htoyear" value="0" />';
    echo '<input type="hidden" name="htohour" value="0" />';
    echo '<input type="hidden" name="htominute" value="0" />';
    echo '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0">' . get_string('searchsubject', 'allmetadata') . ':</td>';
    echo '<td class="c1"><input type="text" size="35" name="subject" value="' . s($subject) . '" alt=""></td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0">' . get_string('searchuser', 'allmetadata') . ':</td>';
    echo '<td class="c1"><input type="text" size="35" name="user" value="' . s($user) . '" alt=""></td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0">' . get_string('searchwhichmetadatas', 'allmetadata') . ':</td>';
    echo '<td class="c1">';
    //Metadata Modules available
    //function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modnamesused)
    $allmods = get_all_mods($course->id, &$mods, &$modnames, &$modnamesplural, &$modnamesused);
    $metamods = array();
    if (array_key_exists("metadatadc", $modnamesplural)) {
        $metamods = array_merge(array("metadatadc" => get_string('modulenameplural', 'metadatadc')), $metamods);
        //array_unshift($metamods, get_string('modulenameplural', 'metadatadc'));
    }
    if (array_key_exists("metadatalom", $modnamesplural)) {
        $metamods = array_merge(array("metadatalom" => get_string('modulenameplural', 'metadatalom')), $metamods);
        //array_unshift($metamods, get_string('modulenameplural', 'metadatalom'));
    }
    if (count($metamods) == 1) {
        //choose_from_menu($options, $name, $selected='', $nothing='choose', $script='', $nothingvalue='0', $return=false, $disabled=false, $tabindex=0)
        choose_from_menu($metamods, 'metamodname', '', 'choose', '');
    } elseif (count($metamods) > 1) {
        array_unshift($metamods, get_string('allmetadata', 'allmetadata'));
        choose_from_menu($metamods, 'metamodname', '', 'choose', '');
    } else {
        echo '<strong>' . get_string('nometadata', 'allmetadata') . '</strong>';
    }
    echo '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0">' . get_string('searchwhichcourse', 'allmetadata') . ':</td>';
    echo '<td class="c1">';
    //Courses available
    //get_courses($categoryid="all", $sort="c.sortorder ASC", $fields="c.*")
    $allcourses = array();
    if ($allcs = get_courses("all", "c.id ASC", "c.id,c.fullname")) {
        foreach ($allcs as $allc) {
            $namec = $allc->fullname;
            $idc = $allc->id;
            $onecourse = array($idc => $namec);
            array_push_associative($allcourses, $onecourse);
        }
    }
    if (count($allcourses) == 1) {
        //choose_from_menu($options, $name, $selected='', $nothing='choose', $script='', $nothingvalue='0', $return=false, $disabled=false, $tabindex=0)
        choose_from_menu($allcourses, 'searchcourseid', '', get_string('allcourses', 'allmetadata'), '');
    } elseif (count($allcourses) > 1) {
        //array_unshift($allcourses, get_string('allcourses', 'allmetadata'));
        //array_push($allcourses, get_string('mycourses', 'allmetadata'));
        $mycourse = array("9999" => get_string('mycourses', 'allmetadata'));
        array_push_associative($allcourses, $mycourse);
        choose_from_menu($allcourses, 'searchcourseid', '', get_string('allcourses', 'allmetadata'), '');
    } else {
        echo '<strong>' . get_string('nocourses', 'allmetadata') . '</strong>';
    }
    echo '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0">' . get_string('searchwhichmods', 'allmetadata') . ':</td>';
    echo '<td class="c1">';
    //Resources-Activities Modules available
    $modsmetadata = array("metadatadc" => get_string('modulenameplural', 'metadatadc'), "metadatalom" => get_string('modulenameplural', 'metadatalom'));
    $modsra = array();
    //Don't show the metadatalom/metadatadc mods
    $modsra = array_diff($modnamesplural, $modsmetadata);
    if (count($modsra) == 1) {
        //choose_from_menu($options, $name, $selected='', $nothing='choose', $script='', $nothingvalue='0', $return=false, $disabled=false, $tabindex=0)
        choose_from_menu($modsra, 'modname', '', 'choose', '');
    } elseif (count($modsra) > 1) {
        array_unshift($modsra, get_string('allmods', 'allmetadata'));
        choose_from_menu($modsra, 'modname', '', 'choose', '');
    } else {
        echo '<strong>' . get_string('nomodules', 'allmetadata') . '</strong>';
    }
    echo '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="submit" colspan="2" align="center">';
    echo '<input type="submit" value="' . get_string('searchallmetadatas', 'allmetadata') . '" alt=""></td>';
    echo '</tr>';
    echo '</table>';
    echo '</form>';
    echo "<script type=\"text/javascript\">";
    echo "lockoptions('search','timefromrestrict 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP get_courses_search函数代码示例发布时间:2022-05-15
下一篇:
PHP get_coursemodules_in_course函数代码示例发布时间: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