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


PHP get_categories_for_contexts函数代码示例

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


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

示例1: question_category_options

/**
 * Output an array of question categories.
 */
function question_category_options($contexts, $top = false, $currentcat = 0, $popupform = false, $nochildrenof = -1)
{
    global $CFG;
    $pcontexts = array();
    foreach ($contexts as $context) {
        $pcontexts[] = $context->id;
    }
    $contextslist = join($pcontexts, ', ');
    $categories = get_categories_for_contexts($contextslist);
    $categories = question_add_context_in_key($categories);
    if ($top) {
        $categories = question_add_tops($categories, $pcontexts);
    }
    $categories = add_indented_names($categories, $nochildrenof);
    // sort cats out into different contexts
    $categoriesarray = array();
    foreach ($pcontexts as $contextid) {
        $context = context::instance_by_id($contextid);
        $contextstring = $context->get_context_name(true, true);
        foreach ($categories as $category) {
            if ($category->contextid == $contextid) {
                $cid = $category->id;
                if ($currentcat != $cid || $currentcat == 0) {
                    $countstring = !empty($category->questioncount) ? " ({$category->questioncount})" : '';
                    $categoriesarray[$contextstring][$cid] = format_string($category->indentedname, true, array('context' => $context)) . $countstring;
                }
            }
        }
    }
    if ($popupform) {
        $popupcats = array();
        foreach ($categoriesarray as $contextstring => $optgroup) {
            $group = array();
            foreach ($optgroup as $key => $value) {
                $key = str_replace($CFG->wwwroot, '', $key);
                $group[$key] = $value;
            }
            $popupcats[] = array($contextstring => $group);
        }
        return $popupcats;
    } else {
        return $categoriesarray;
    }
}
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:47,代码来源:questionlib.php

示例2: question_category_options

/**
 * Output an array of question categories.
 */
function question_category_options($contexts, $top = false, $currentcat = 0, $popupform = false, $nochildrenof = -1)
{
    global $CFG;
    $pcontexts = array();
    foreach ($contexts as $context) {
        $pcontexts[] = $context->id;
    }
    $contextslist = join($pcontexts, ', ');
    $categories = get_categories_for_contexts($contextslist);
    $categories = question_add_context_in_key($categories);
    if ($top) {
        $categories = question_add_tops($categories, $pcontexts);
    }
    $categories = add_indented_names($categories, $nochildrenof);
    //sort cats out into different contexts
    $categoriesarray = array();
    foreach ($pcontexts as $pcontext) {
        $contextstring = print_context_name(get_context_instance_by_id($pcontext), true, true);
        foreach ($categories as $category) {
            if ($category->contextid == $pcontext) {
                $cid = $category->id;
                if ($currentcat != $cid || $currentcat == 0) {
                    $countstring = !empty($category->questioncount) ? " ({$category->questioncount})" : '';
                    $categoriesarray[$contextstring][$cid] = $category->indentedname . $countstring;
                }
            }
        }
    }
    if ($popupform) {
        $popupcats = array();
        foreach ($categoriesarray as $contextstring => $optgroup) {
            $popupcats[] = '--' . $contextstring;
            $popupcats = array_merge($popupcats, $optgroup);
            $popupcats[] = '--';
        }
        return $popupcats;
    } else {
        return $categoriesarray;
    }
}
开发者ID:e-rasvet,项目名称:reader,代码行数:43,代码来源:questionlib.php

示例3: require_login

require_login($course->id);
if (has_capability('mod/qcreate:grade', $modulecontext)) {
    redirect($CFG->wwwroot . '/mod/qcreate/edit.php?cmid=' . $cm->id);
}
/// Print the page header
$strqcreates = get_string("modulenameplural", "qcreate");
$strqcreate = get_string("modulename", "qcreate");
$navlinks = array();
$navlinks[] = array('name' => $strqcreates, 'link' => "index.php?id={$course->id}", 'type' => 'activity');
$navlinks[] = array('name' => format_string($qcreate->name), 'link' => '', 'type' => 'activityinstance');
$navigation = build_navigation($navlinks);
$headerargs = array(format_string($qcreate->name), "", $navigation, "", "", true, update_module_button($cm->id, $course->id, $strqcreate), navmenu($course, $cm));
if (!($cats = get_categories_for_contexts($modulecontext->id))) {
    //if it has not been made yet then make a default cat
    question_make_default_categories(array($modulecontext));
    $cats = get_categories_for_contexts($modulecontext->id);
}
$catsinctx = array();
foreach ($cats as $catinctx) {
    $catsinctx[] = $catinctx->id;
}
$catsinctxlist = join($catsinctx, ',');
$cat = array_shift($cats);
if ($delete && question_require_capability_on($delete, 'edit')) {
    if ($confirm && confirm_sesskey()) {
        if (!delete_records_select('question', "id = {$delete} AND category IN ({$catsinctxlist})")) {
            print_error('question_not_found');
        } else {
            qcreate_update_grades($qcreate, $USER->id);
            redirect($CFG->wwwroot . '/mod/qcreate/view.php?id=' . $cm->id);
        }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:31,代码来源:view.php

示例4: get_records

 public function get_records() {
     $this->records = get_categories_for_contexts($this->context->id, $this->sortby);
 }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:3,代码来源:category_class.php

示例5: RWSGUQCats

function RWSGUQCats($r_cid)
{
    global $CFG;
    global $RWSUID;
    $r_rv = RWSGSOpt("version", PARAM_ALPHANUMEXT);
    if ($r_rv === false || strlen($r_rv) == 0) {
        $r_bv = 2009093000;
    } else {
        $r_bv = intval($r_rv);
    }
    $r_ctxs = array();
    if ($r_bv >= 2010063001) {
        if (is_siteadmin($RWSUID)) {
            if (respondusws_floatcompare($CFG->version, 2013111800, 2) >= 0) {
                $r_sys = context_system::instance();
            } else {
                $r_sys = get_context_instance(CONTEXT_SYSTEM);
            }
            $r_ctxs[] = $r_sys->id;
        }
    }
    if (respondusws_floatcompare($CFG->version, 2013111800, 2) >= 0) {
        $r_ctx = context_course::instance($r_cid);
    } else {
        $r_ctx = get_context_instance(CONTEXT_COURSE, $r_cid);
    }
    $r_ctxs[] = $r_ctx->id;
    $r_qzms = RWSGUVQList($r_cid);
    if (count($r_qzms) > 0) {
        foreach ($r_qzms as $r_qzm) {
            if (respondusws_floatcompare($CFG->version, 2013111800, 2) >= 0) {
                $r_ctx = context_module::instance($r_qzm->id);
            } else {
                $r_ctx = get_context_instance(CONTEXT_MODULE, $r_qzm->id);
            }
            if ($r_ctx != false) {
                if (!in_array($r_ctx->id, $r_ctxs)) {
                    $r_ctxs[] = $r_ctx->id;
                }
            }
        }
    }
    if (count($r_ctxs) == 0) {
        return array();
    } else {
        if (count($r_ctxs) == 1) {
            $r_qcs = get_categories_for_contexts($r_ctxs[0]);
            if ($r_qcs === false || count($r_qcs) == 0) {
                return array();
            }
        } else {
            $r_ctxl = implode(", ", $r_ctxs);
            $r_qcs = get_categories_for_contexts($r_ctxl);
            if ($r_qcs === false || count($r_qcs) == 0) {
                return array();
            }
        }
    }
    return $r_qcs;
}
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:60,代码来源:servicelib.php

示例6: get_categories

 private function get_categories()
 {
     $cmid = optional_param('cmid', 0, PARAM_INT);
     $categoryparam = optional_param('category', '', PARAM_TEXT);
     $courseid = optional_param('courseid', 0, PARAM_INT);
     if ($cmid) {
         list($thispageurl, $contexts, $cmid, $cm, $quiz, $pagevars) = question_edit_setup('editq', '/mod/quiz/edit.php', true);
         if ($pagevars['cat']) {
             $categoryparam = $pagevars['cat'];
         }
     }
     if ($categoryparam) {
         $catandcontext = explode(',', $categoryparam);
         $cats = question_categorylist($catandcontext[0]);
         return $cats;
     } else {
         if ($cmid) {
             list($module, $cm) = get_module_from_cmid($cmid);
             $courseid = $cm->course;
             require_login($courseid, false, $cm);
             $thiscontext = context_module::instance($cmid);
         } else {
             $module = null;
             $cm = null;
             if ($courseid) {
                 $thiscontext = context_course::instance($courseid);
             } else {
                 $thiscontext = null;
             }
         }
     }
     $cats = get_categories_for_contexts($thiscontext->id);
     return array_keys($cats);
 }
开发者ID:advancingdesign,项目名称:moodle_local_searchbytags,代码行数:34,代码来源:lib.php

示例7: is_available_prototype

 public static function is_available_prototype($questionoptionsrow, $context)
 {
     global $DB;
     static $activeCats = null;
     if (!($question = $DB->get_record('question', array('id' => $questionoptionsrow->questionid)))) {
         throw new coderunner_exception("Missing question id = {$questionoptionsrow->questionid} in question table");
     }
     if (!($candidatecat = $DB->get_record('question_categories', array('id' => $question->category)))) {
         throw new coderunner_exception('Missing question category');
     }
     if ($activeCats === null) {
         $allContexts = $context->get_parent_context_ids(true);
         $activeCats = get_categories_for_contexts(implode(',', $allContexts));
     }
     foreach ($activeCats as $cat) {
         if ($cat->id == $candidatecat->id) {
             return true;
         }
     }
     return false;
 }
开发者ID:pac,项目名称:CodeRunner,代码行数:21,代码来源:questiontype.php


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