本文整理汇总了PHP中default_questiontype类的典型用法代码示例。如果您正苦于以下问题:PHP default_questiontype类的具体用法?PHP default_questiontype怎么用?PHP default_questiontype使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了default_questiontype类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate_test
/**
* Runs all the code required to set up and save an essay question for testing purposes.
* Alternate DB table prefix may be used to facilitate data deletion.
*/
function generate_test($name, $courseid = null)
{
global $DB;
list($form, $question) = default_questiontype::generate_test($name, $courseid);
$question->category = $form->category;
$form->questiontext = "What is 674 * 36?";
$form->generalfeedback = "Thank you";
$form->penalty = 0.1;
$form->defaultgrade = 1;
$form->noanswers = 3;
$form->answer = array('24264', '24264', '1');
$form->tolerance = array(10, 100, 0);
$form->fraction = array(1, 0.5, 0);
$form->nounits = 2;
$form->unit = array(0 => null, 1 => null);
$form->multiplier = array(1, 0);
$form->feedback = array('Very good', 'Close, but not quite there', 'Well at least you tried....');
if ($courseid) {
$course = $DB->get_record('course', array('id' => $courseid));
}
return $this->save_question($question, $form);
}
示例2: save_question
function save_question($authorizedquestion, $form, $course)
{
wrsqz_presave_question('multianswer', 'wmansprom', $authorizedquestion, $form, $course);
global $CFG;
require_once $CFG->dirroot . '/wiris-quizzes/lib/libquestiontype.php';
$question = wrsqz_qtype_multianswer_extract_question($form);
if (isset($authorizedquestion->id)) {
$question->id = $authorizedquestion->id;
}
$question->category = $authorizedquestion->category;
$form->course = $course;
// To pass the course object to
// save_question_options, where it is
// needed to call type specific
// save_question methods.
$form->defaultgrade = $question->defaultgrade;
$form->questiontext = $question->questiontext;
// We do not force MOODLE_FORMAT: it is incoherent with default
// multianswer behavior, but MOODLE_FORMAT will introduce links,
// smileys and other undesired features, and it is coherent with
// default questiontype behavior.
// $form->questiontextformat = 0;
$form->options = clone $question->options;
unset($question->options);
return default_questiontype::save_question($question, $form, $course);
}
示例3:
function save_question($question, $form, $course)
{
// Make very sure that descriptions can'e be created with a grade of
// anything other than 0.
$form->defaultgrade = 0;
return parent::save_question($question, $form, $course);
}
示例4: notify
/**
* Loads the question type specific options for the question.
*
* @return boolean to indicate success or failure
*/
function get_question_options(&$question)
{
// Get additional information from database
// and attach it to the question object
if (!($question->options = get_record('question_imagedit', 'question', $question->id))) {
notify('Error: Missing question options!');
return false;
}
// Get data from question_answers (for feedback)
parent::get_question_options($question);
return true;
}
示例5: addslashes
function get_correct_responses(&$question, &$state)
{
$response = parent::get_correct_responses($question, $state);
if (is_array($response)) {
$response[''] = addslashes(str_replace('\\*', '*', stripslashes($response[''])));
}
return $response;
}
示例6: list
/**
* Runs all the code required to set up and save an essay question for testing purposes.
* Alternate DB table prefix may be used to facilitate data deletion.
*/
function generate_test($name, $courseid = null)
{
list($form, $question) = parent::generate_test($name, $courseid);
$question->category = $form->category;
$form->questiontext = "How old is the sun?";
$form->generalfeedback = "General feedback";
$form->penalty = 0.1;
$form->single = 1;
$form->shuffleanswers = 1;
$form->answernumbering = 'abc';
$form->noanswers = 3;
$form->answer = array('Ancient', '5 billion years old', '4.5 billion years old');
$form->fraction = array(0.3, 0.9, 1);
$form->feedback = array('True, but lacking in accuracy', 'Close, but no cigar!', 'Yep, that is it!');
$form->correctfeedback = 'Excellent!';
$form->incorrectfeedback = 'Nope!';
$form->partiallycorrectfeedback = 'Not bad';
if ($courseid) {
$course = get_record('course', 'id', $courseid);
}
return $this->save_question($question, $form, $course);
}
示例7: reset
function check_file_access($question, $state, $options, $contextid, $component, $filearea, $args)
{
if ($component == 'question' && $filearea == 'answerfeedback') {
$answerid = reset($args);
// itemid is answer id.
$answers =& $question->options->answers;
if (isset($state->responses[''])) {
$response = $state->responses[''];
} else {
$response = '';
}
return $options->feedback && !empty($response);
} else {
return parent::check_file_access($question, $state, $options, $contextid, $component, $filearea, $args);
}
}
示例8: foreach
function replace_file_links($question, $fromcourseid, $tocourseid, $url, $destination)
{
parent::replace_file_links($question, $fromcourseid, $tocourseid, $url, $destination);
// replace links in the question_match_sub table.
if (isset($question->options->subquestions)) {
foreach ($question->options->subquestions as $subquestion) {
$subquestionchanged = false;
$subquestion->questiontext = question_replace_file_links_in_html($subquestion->questiontext, $fromcourseid, $tocourseid, $url, $destination, $subquestionchanged);
if ($subquestionchanged) {
//need to update rec in db
if (!update_record('question_match_sub', addslashes_recursive($subquestion))) {
error('Couldn\'t update \'question_match_sub\' record ' . $subquestion->id);
}
}
}
}
}
示例9:
/**
* @desc Prints the questions buttons.
* @param $question object The question object.
* @param $state object The state object.
* @param $cmoptions object The quizzes or other mods options
* @param $options object The questions options.
*/
function print_question_submit_buttons(&$question, &$state, $cmoptions, $options)
{
$courseid = $cmoptions->course;
$seed = $state->responses['seed'];
$attempt = $state->attempt;
echo "<table><tr><td>";
parent::print_question_submit_buttons($question, $state, $cmoptions, $options);
echo "</td><td>";
if (!$options->readonly && $courseid != 1) {
echo link_to_popup_window('/question/type/webwork/emailinstructor.php?qid=' . $question->id . '&aid=' . $attempt, 'emailinstructor', "<input type=\"button\" value=\"Email Instructor\" class=\"submit btn\">", 600, 700, "Email Instructor");
}
echo "</td></tr></table>";
}
示例10:
/**
* If this question type requires extra CSS or JavaScript to function,
* then this method will return an array of <link ...> tags that reference
* those stylesheets. This function will also call require_js()
* from ajaxlib.php, to get any necessary JavaScript linked in too.
*
* The YUI libraries needed for dragdrop have been added to the default
* set of libraries.
*
* The two parameters match the first two parameters of print_question.
*
* @param object $question The question object.
* @param object $state The state object.
*
* @return an array of bits of HTML to add to the head of pages where
* this question is print_question-ed in the body. The array should use
* integer array keys, which have no significance.
*/
function get_html_head_contributions(&$question, &$state)
{
// Load YUI libraries
require_js("yui_yahoo");
require_js("yui_event");
require_js("yui_dom");
require_js("yui_dragdrop");
require_js("yui_animation");
$contributions = parent::get_html_head_contributions($question, $state);
return $contributions;
}
示例11:
/**
* Add styles.css to the page's header
*/
function get_html_head_contributions(&$question, &$state)
{
return parent::get_html_head_contributions($question, $state);
}
示例12: reset
function check_file_access($question, $state, $options, $contextid, $component, $filearea, $args)
{
$itemid = reset($args);
if ($component == 'question' && $filearea == 'answerfeedback') {
// check if answer id exists
$result = $options->feedback && array_key_exists($itemid, $question->options->answers);
if (!$result) {
return false;
}
// check response
if (!$this->check_response($question, $state)) {
return false;
}
return true;
} else {
if ($filearea == 'instruction') {
// TODO: should it be display all the time like questiontext?
// check if question id exists
if ($itemid != $question->id) {
return false;
} else {
return true;
}
} else {
if (in_array($filearea, array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback'))) {
// TODO: calculated type doesn't display question feedback yet
return false;
} else {
return parent::check_file_access($question, $state, $options, $contextid, $component, $filearea, $args);
}
}
}
}
示例13: switch
/**
* this version save the available data at the different steps of the question editing process
* without using global $SESSION as storage between steps
* at the first step $wizardnow = 'question'
* when creating a new question
* when modifying a question
* when copying as a new question
* the general parameters and answers are saved using parent::save_question
* then the datasets are prepared and saved
* at the second step $wizardnow = 'datasetdefinitions'
* the datadefs final type are defined as private, category or not a datadef
* at the third step $wizardnow = 'datasetitems'
* the datadefs parameters and the data items are created or defined
*
* @param object question
* @param object $form
* @param int $course
* @param PARAM_ALPHA $wizardnow should be added as we are coming from question2.php
*/
function save_question($question, $form, $course)
{
$wizardnow = optional_param('wizardnow', '', PARAM_ALPHA);
$id = optional_param('id', 0, PARAM_INT);
// question id
// in case 'question'
// for a new question $form->id is empty
// when saving as new question
// $question->id = 0, $form is $data from question2.php
// and $data->makecopy is defined as $data->id is the initial question id
// edit case. If it is a new question we don't necessarily need to
// return a valid question object
// See where we're coming from
switch ($wizardnow) {
case '':
case 'question':
// coming from the first page, creating the second
if (empty($form->id)) {
// for a new question $form->id is empty
$question = parent::save_question($question, $form, $course);
//prepare the datasets using default $questionfromid
$this->preparedatasets($form);
$form->id = $question->id;
$this->save_dataset_definitions($form);
} else {
if (!empty($form->makecopy)) {
$questionfromid = $form->id;
$question = parent::save_question($question, $form, $course);
//prepare the datasets
$this->preparedatasets($form, $questionfromid);
$form->id = $question->id;
$this->save_as_new_dataset_definitions($form, $questionfromid);
} else {
// editing a question
$question = parent::save_question($question, $form, $course);
//prepare the datasets
$this->preparedatasets($form, $question->id);
$form->id = $question->id;
$this->save_dataset_definitions($form);
}
}
break;
case 'datasetdefinitions':
$this->save_dataset_definitions($form);
break;
case 'datasetitems':
$this->save_dataset_items($question, $form);
break;
default:
error('Incorrect or no wizard page specified!');
break;
}
return $question;
}
示例14: list
/**
* Runs all the code required to set up and save an essay question for testing purposes.
* Alternate DB table prefix may be used to facilitate data deletion.
*/
function generate_test($name, $courseid = null)
{
global $DB;
list($form, $question) = parent::generate_test($name, $courseid);
$form->shuffleanswers = 1;
$form->noanswers = 3;
$form->subquestions = array('cat', 'dog', 'cow');
$form->subanswers = array('feline', 'canine', 'bovine');
if ($courseid) {
$course = $DB->get_record('course', array('id' => $courseid));
}
return $this->save_question($question, $form, $course);
}
示例15:
function display_question_editing_page(&$mform, $question, $wizardnow)
{
parent::display_question_editing_page($mform, $question, $wizardnow);
}