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


PHP question_category_options函数代码示例

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


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

示例1: run_all_tests_for_context

 /**
  * Run all the question tests for all variants of all questions belonging to
  * a given context.
  *
  * Does output as we go along.
  *
  * @param context $context the context to run the tests for.
  * @return array with two elements:
  *              bool true if all the tests passed, else false.
  *              array of messages relating to the questions with failures.
  */
 public function run_all_tests_for_context(context $context)
 {
     global $DB, $OUTPUT;
     // Load the necessary data.
     $categories = question_category_options(array($context));
     $categories = reset($categories);
     $questiontestsurl = new moodle_url('/question/type/stack/questiontestrun.php');
     if ($context->contextlevel == CONTEXT_COURSE) {
         $questiontestsurl->param('courseid', $context->instanceid);
     } else {
         if ($context->contextlevel == CONTEXT_MODULE) {
             $questiontestsurl->param('cmid', $context->instanceid);
         }
     }
     $allpassed = true;
     $failingtests = array();
     foreach ($categories as $key => $category) {
         list($categoryid) = explode(',', $key);
         echo $OUTPUT->heading($category, 3);
         $questionids = $DB->get_records_menu('question', array('category' => $categoryid, 'qtype' => 'stack'), 'name', 'id,name');
         if (!$questionids) {
             continue;
         }
         echo html_writer::tag('p', stack_string('replacedollarscount', count($questionids)));
         foreach ($questionids as $questionid => $name) {
             $tests = question_bank::get_qtype('stack')->load_question_tests($questionid);
             if (!$tests) {
                 echo $OUTPUT->heading(html_writer::link(new moodle_url($questiontestsurl, array('questionid' => $questionid)), format_string($name)), 4);
                 echo html_writer::tag('p', stack_string('bulktestnotests'));
                 continue;
             }
             $question = question_bank::load_question($questionid);
             $questionname = format_string($name);
             $previewurl = new moodle_url($questiontestsurl, array('questionid' => $questionid));
             if (empty($question->deployedseeds)) {
                 $questionnamelink = html_writer::link($previewurl, $questionname);
                 echo $OUTPUT->heading($questionnamelink, 4);
                 list($ok, $message) = $this->qtype_stack_test_question($question, $tests);
                 if (!$ok) {
                     $allpassed = false;
                     $failingtests[] = $questionnamelink . ': ' . $message;
                 }
             } else {
                 echo $OUTPUT->heading(format_string($name), 4);
                 foreach ($question->deployedseeds as $seed) {
                     $previewurl->param('seed', $seed);
                     $questionnamelink = html_writer::link($previewurl, stack_string('seedx', $seed));
                     echo $OUTPUT->heading($questionnamelink, 4);
                     list($ok, $message) = $this->qtype_stack_test_question($question, $tests, $seed);
                     if (!$ok) {
                         $allpassed = false;
                         $failingtests[] = $questionname . ' ' . $questionnamelink . ': ' . $message;
                     }
                 }
             }
         }
     }
     return array($allpassed, $failingtests);
 }
开发者ID:sowirepo,项目名称:moodle-qtype_stack,代码行数:70,代码来源:bulktester.class.php

示例2: __construct

 /**
  * Constructor
  *
  * @param string $elementName Select name attribute
  * @param mixed $elementLabel Label(s) for the select
  * @param array $options additional options. Recognised options are courseid, published and
  *              only_editable, corresponding to the arguments of question_category_options
  *              from moodlelib.php.
  * @param mixed $attributes Either a typical HTML attribute string or an associative array
  */
 public function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null)
 {
     parent::__construct($elementName, $elementLabel, array(), $attributes);
     $this->_type = 'questioncategory';
     if (is_array($options)) {
         $this->_options = $options + $this->_options;
         $this->loadArrayOptGroups(question_category_options($this->_options['contexts'], $this->_options['top'], $this->_options['currentcat'], false, $this->_options['nochildrenof']));
     }
 }
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:19,代码来源:questioncategory.php

示例3: onQuickFormEvent

 /**
  * Called by HTML_QuickForm whenever form event is made on this element
  *
  * @param string $event Name of event
  * @param mixed $arg event arguments
  * @param object $caller calling object
  * @access public
  * @return mixed
  */
 function onQuickFormEvent($event, $arg, &$caller)
 {
     switch ($event) {
         case 'createElement':
             $this->load(question_category_options($this->_courseid, $this->_published, $this->_only_editable));
             break;
     }
     return parent::onQuickFormEvent($event, $arg, $caller);
 }
开发者ID:veritech,项目名称:pare-project,代码行数:18,代码来源:questioncategory.php

示例4: MoodleQuickForm_questioncategory

 /**
  * Constructor
  *
  * @param string $elementName Select name attribute
  * @param mixed $elementLabel Label(s) for the select
  * @param array $options additional options. Recognised options are courseid, published and
  *              only_editable, corresponding to the arguments of question_category_options
  *              from moodlelib.php.
  * @param mixed $attributes Either a typical HTML attribute string or an associative array
  */
 function MoodleQuickForm_questioncategory($elementName = null, $elementLabel = null, $options = null, $attributes = null)
 {
     MoodleQuickForm_selectgroups::MoodleQuickForm_selectgroups($elementName, $elementLabel, array(), $attributes);
     $this->_type = 'questioncategory';
     if (is_array($options)) {
         $this->_options = $options + $this->_options;
         $this->loadArrayOptGroups(question_category_options($this->_options['contexts'], $this->_options['top'], $this->_options['currentcat'], false, $this->_options['nochildrenof']));
     }
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:19,代码来源:questioncategory.php

示例5: display_category_form

    /**
     * Display the drop down to select the category.
     *
     * @param array $contexts of contexts that can be accessed from here.
     * @param \moodle_url $pageurl the URL of this page.
     * @param string $current 'categoryID,contextID'.
     */
    protected function display_category_form($contexts, $pageurl, $current) {
        global $OUTPUT;

        echo \html_writer::start_div('choosecategory');
        $catmenu = question_category_options($contexts, false, 0, true);
        $select = new \single_select($this->baseurl, 'category', $catmenu, $current, null, 'catmenu');
        $select->set_label(get_string('selectacategory', 'question'));
        echo $OUTPUT->render($select);
        echo \html_writer::end_div() . "\n";
    }
开发者ID:rwijaya,项目名称:moodle,代码行数:17,代码来源:category_condition.php

示例6: display_category_form

 /**
  * Prints a form to choose categories
  * @deprecated since Moodle 2.7 MDL-40313.
  * @see \core_question\bank\search\condition
  * @todo MDL-41978 This will be deleted in Moodle 2.8
  */
 protected function display_category_form($contexts, $pageurl, $current)
 {
     global $OUTPUT;
     debugging('display_category_form() is deprecated, please use ' . '\\core_question\\bank\\search\\condition instead.', DEBUG_DEVELOPER);
     // Get all the existing categories now.
     echo '<div class="choosecategory">';
     $catmenu = question_category_options($contexts, false, 0, true);
     $select = new \single_select($this->baseurl, 'category', $catmenu, $current, null, 'catmenu');
     $select->set_label(get_string('selectacategory', 'question'));
     echo $OUTPUT->render($select);
     echo "</div>\n";
 }
开发者ID:Gavinthisisit,项目名称:Moodle,代码行数:18,代码来源:view.php

示例7: error

        // In case anything needs to be done after
        if (!$qformat->importpostprocess()) {
            error($txt->importerror, "{$CFG->wwwroot}/question/import.php?courseid={$course->id}&amp;category={$category->id}");
        }
        echo "<hr />";
        print_continue("edit.php?courseid={$course->id}");
        print_footer($course);
        exit;
    }
}
/// Print upload form
// get list of available import formats
$fileformatnames = get_import_export_formats('import');
print_heading_with_help($txt->importquestions, "import", "quiz");
/// Get all the existing categories now
$catmenu = question_category_options($course->id, false, true);
//==========
// DISPLAY
//==========
?>

    <form id="form" enctype="multipart/form-data" method="post" action="import.php">
        <fieldset class="invisiblefieldset" style="display: block;">
            <input type="hidden" name="sesskey" value="<?php 
echo sesskey();
?>
" />
            <input type="hidden" name="courseid" value="<?php 
echo $localcourseid;
?>
" />
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:import.php

示例8: question_category_select_menu

/**
 * Output a select menu of question categories.
 *
 * Categories from this course and (optionally) published categories from other courses
 * are included. Optionally, only categories the current user may edit can be included.
 *
 * @param integer $courseid the id of the course to get the categories for.
 * @param integer $published if true, include publised categories from other courses.
 * @param integer $only_editable if true, exclude categories this user is not allowed to edit.
 * @param integer $selected optionally, the id of a category to be selected by default in the dropdown.
 */
function question_category_select_menu($contexts, $top = false, $currentcat = 0, $selected = "", $nochildrenof = -1)
{
    global $OUTPUT;
    $categoriesarray = question_category_options($contexts, $top, $currentcat, false, $nochildrenof);
    if ($selected) {
        $nothing = '';
    } else {
        $nothing = 'choosedots';
    }
    $select = html_select::make($categoriesarray, 'category', $selected);
    $select->nothingvalue = $nothing;
    $select->nested = true;
    echo $OUTPUT->select($select);
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:25,代码来源:questionlib.php

示例9: question_category_select_menu

/**
 * Output a select menu of question categories.
 *
 * Categories from this course and (optionally) published categories from other courses
 * are included. Optionally, only categories the current user may edit can be included.
 *
 * @param integer $courseid the id of the course to get the categories for.
 * @param integer $published if true, include publised categories from other courses.
 * @param integer $only_editable if true, exclude categories this user is not allowed to edit.
 * @param integer $selected optionally, the id of a category to be selected by default in the dropdown.
 */
function question_category_select_menu($contexts, $top = false, $currentcat = 0, $selected = "", $nochildrenof = -1)
{
    $categoriesarray = question_category_options($contexts, $top, $currentcat, false, $nochildrenof);
    if ($selected) {
        $nothing = '';
    } else {
        $nothing = 'choose';
    }
    choose_from_menu_nested($categoriesarray, 'category', $selected, $nothing);
}
开发者ID:e-rasvet,项目名称:reader,代码行数:21,代码来源:questionlib.php

示例10: get_default_question_category

}
if (!($category = get_record("question_categories", "id", $categoryid))) {
    $category = get_default_question_category($courseid);
}
if (!($categorycourse = get_record("course", "id", $category->course))) {
    print_error('nocategory', 'quiz');
}
require_login($course->id, false);
// check role capability
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('moodle/question:export', $context);
// ensure the files area exists for this course
make_upload_directory("{$course->id}");
// check category is valid
if (!empty($categoryid)) {
    $validcats = question_category_options($course->id, true, false);
    if (!array_key_exists($categoryid, $validcats)) {
        print_error('invalidcategory', 'quiz');
    }
}
/// Header
if (isset($SESSION->modform->instance) and $quiz = get_record('quiz', 'id', $SESSION->modform->instance)) {
    $strupdatemodule = has_capability('moodle/course:manageactivities', $context) ? update_module_button($SESSION->modform->cmid, $course->id, $txt->modulename) : "";
    print_header_simple($txt->exportquestions, '', "<a href=\"{$CFG->wwwroot}/mod/quiz/index.php?id={$course->id}\">{$txt->modulenameplural}</a>" . " -> <a href=\"{$CFG->wwwroot}/mod/quiz/view.php?q={$quiz->id}\">" . format_string($quiz->name) . '</a>' . ' -> ' . $txt->exportquestions, "", "", true, $strupdatemodule);
    $currenttab = 'edit';
    $mode = 'export';
    include $CFG->dirroot . '/mod/quiz/tabs.php';
} else {
    print_header_simple($txt->exportquestions, '', $txt->exportquestions);
    // print tabs
    $currenttab = 'export';
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:export.php

示例11: question_category_select_menu

/**
 * Output a select menu of question categories.
 *
 * Categories from this course and (optionally) published categories from other courses
 * are included. Optionally, only categories the current user may edit can be included.
 *
 * @param integer $courseid the id of the course to get the categories for.
 * @param integer $published if true, include publised categories from other courses.
 * @param integer $only_editable if true, exclude categories this user is not allowed to edit.
 * @param integer $selected optionally, the id of a category to be selected by default in the dropdown.
 */
function question_category_select_menu($courseid, $published = false, $only_editable = false, $selected = "")
{
    $categoriesarray = question_category_options($courseid, $published, $only_editable);
    if ($selected) {
        $nothing = '';
    } else {
        $nothing = 'choose';
    }
    choose_from_menu($categoriesarray, 'category', $selected, $nothing);
}
开发者ID:veritech,项目名称:pare-project,代码行数:21,代码来源:questionlib.php

示例12: display_category_form

 /**
  * prints a form to choose categories
  */
 protected function display_category_form($contexts, $pageurl, $current)
 {
     global $CFG;
     /// Get all the existing categories now
     echo '<div class="choosecategory">';
     $catmenu = question_category_options($contexts, false, 0, true);
     popup_form('edit.php?' . $pageurl->get_query_string() . '&amp;category=', $catmenu, 'catmenu', $current, '', '', '', false, 'self', get_string('selectacategory', 'question'));
     echo "</div>\n";
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:12,代码来源:editlib.php

示例13: question_category_select_menu

/**
 * Output a select menu of question categories.
 *
 * Categories from this course and (optionally) published categories from other courses
 * are included. Optionally, only categories the current user may edit can be included.
 *
 * @param integer $courseid the id of the course to get the categories for.
 * @param integer $published if true, include publised categories from other courses.
 * @param integer $only_editable if true, exclude categories this user is not allowed to edit.
 * @param integer $selected optionally, the id of a category to be selected by
 *      default in the dropdown.
 */
function question_category_select_menu($contexts, $top = false, $currentcat = 0, $selected = "", $nochildrenof = -1)
{
    global $OUTPUT;
    $categoriesarray = question_category_options($contexts, $top, $currentcat, false, $nochildrenof);
    if ($selected) {
        $choose = '';
    } else {
        $choose = 'choosedots';
    }
    $options = array();
    foreach ($categoriesarray as $group => $opts) {
        $options[] = array($group => $opts);
    }
    echo html_writer::label(get_string('questioncategory', 'core_question'), 'id_movetocategory', false, array('class' => 'accesshide'));
    $attrs = array('id' => 'id_movetocategory', 'class' => 'custom-select');
    echo html_writer::select($options, 'category', $selected, $choose, $attrs);
}
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:29,代码来源:questionlib.php

示例14: display_category_form

    /**
     * prints a form to choose categories
     */
    protected function display_category_form($contexts, $pageurl, $current) {
        global $CFG, $OUTPUT;

    /// Get all the existing categories now
        echo '<div class="choosecategory">';
        $catmenu = question_category_options($contexts, false, 0, true);

        $select = new single_select($this->baseurl, 'category', $catmenu, $current, null, 'catmenu');
        $select->set_label(get_string('selectacategory', 'question'));
        echo $OUTPUT->render($select);
        echo "</div>\n";
    }
开发者ID:verbazend,项目名称:AWFA,代码行数:15,代码来源:editlib.php

示例15: importprocess

 function importprocess($filename)
 {
     global $CFG, $USER, $strimportquestions, $form, $question_category, $category, $COURSE, $hostname, $mdapath, $mdbpath;
     if (PHP_OS == "Linux" and isset($hostname)) {
         $hostname = trim($hostname);
         // test the ODBC socket server connection
         // if failure, unset hostname and set hostname_access_error
         $question_categories = $this->getquestioncategories($mdbpath, $mdapath, $hostname);
         if (!$question_categories) {
             $hostname_access_error = $hostname . " ";
             unset($hostname);
         } else {
             $hostname_access_error = 0;
         }
     }
     if (PHP_OS == "Linux" and !isset($hostname)) {
         // copy the file to a semi-permanent location
         if (!($basedir = make_upload_directory("{$COURSE->id}"))) {
             error("The site administrator needs to fix the file permissions for the data directory");
         }
         if (!isset($hostname_access_error)) {
             $bname = basename($filename);
             $cleanfilename = clean_filename($bname);
             if ($cleanfilename) {
                 $newfile = "{$basedir}/{$cleanfilename}";
                 if (move_uploaded_file($filename, $newfile)) {
                     chmod($newfile, 0666);
                     clam_log_upload($newfile, $COURSE);
                 } else {
                     notify(get_string("uploadproblem", "", $filename));
                 }
             }
             $filename = $newfile;
         }
         print_heading_with_help($strimportquestions, "import", "quiz");
         print_simple_box_start("center");
         if ($hostname_access_error) {
             notify("couldn't connect to ODBC Socket Server on " . $hostname_access_error);
         }
         echo "<form method=\"post\" action=\"import.php\">";
         echo '<fieldset class="invisiblefieldset">';
         echo "<table cellpadding=\"5\">";
         echo "<tr><td align=\"right\">";
         echo "What is the hostname or IP address of the ODBC Socket Server:</td><td>";
         echo " <input name=\"hostname\" type=\"text\" size=\"50\" value=\"" . stripslashes($hostname_access_error) . "\" />";
         echo " <input name=\"filename\" type=\"hidden\" value=\"" . $filename . "\" />";
         echo " <input name=\"category\" type=\"hidden\" value=\"" . $category->id . "\" />";
         echo " <input name=\"format\" type=\"hidden\" value=\"" . $form->format . "\" />";
         echo "</td><td>&nbsp;</td></tr>";
         echo "<tr><td align=\"right\">";
         echo "What is the location of the database (.mdb file) on the Socket Server:</td><td>";
         echo " <input name=\"mdbpath\" type=\"text\" size=\"50\" value=\"" . stripslashes($mdbpath) . "\" />";
         echo "</td><td>&nbsp;</td></tr>";
         echo "<tr><td align=\"right\">";
         echo "What is the location of the system database (System.mda file) on the Socket Server:</td><td>";
         echo " <input name=\"mdapath\" type=\"text\" size=\"50\" value=\"" . stripslashes($mdapath) . "\" />";
         echo "</td><td>&nbsp;</td></tr>";
         echo "<tr><td>&nbsp;</td><td>";
         echo " <input type=\"submit\" name=\"save\" value=\"Connect to Server\" />";
         echo "</td></tr>";
         echo "</table>";
         echo '</fieldset>';
         echo "</form>";
         print_simple_box_end();
         print_footer($COURSE);
         exit;
     }
     // we get here if running windows or after connect to ODBC socket server on linux
     //
     // this generates the page to choose categories of questions to import
     //
     if (!isset($question_category)) {
         if (PHP_OS == "WINNT") {
             // copy the file to a semi-permanent location
             if (!($basedir = make_upload_directory("{$COURSE->id}"))) {
                 error("The site administrator needs to fix the file permissions for the data directory");
             }
             $bname = basename($filename);
             $cleanfilename = clean_filename($bname);
             if ($cleanfilename) {
                 $newfile = "{$basedir}/{$cleanfilename}";
                 if (move_uploaded_file($filename, $newfile)) {
                     chmod($newfile, 0666);
                     clam_log_upload($newfile, $COURSE);
                 } else {
                     notify(get_string("uploadproblem", "", $filename));
                 }
             }
             $filename = $newfile;
         }
         // end of file copy
         // don't have to do this on linux, since it's alreay been done in the test above
         if (PHP_OS == "WINNT") {
             $question_categories = $this->getquestioncategories($filename);
         }
         // print the intermediary form
         if (!($categories = question_category_options($COURSE->id, true))) {
             error("No categories!");
         }
         print_heading_with_help($strimportquestions, "import", "quiz");
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:101,代码来源:format.php


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