本文整理汇总了PHP中question_edit_form类的典型用法代码示例。如果您正苦于以下问题:PHP question_edit_form类的具体用法?PHP question_edit_form怎么用?PHP question_edit_form使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了question_edit_form类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: list
/**
* This method should be overriden if you want to include a special heading or some other
* html on a question editing page besides the question editing form.
*
* @param question_edit_form $mform a child of question_edit_form
* @param object $question
* @param string $wizardnow is '' for first page.
*/
function display_question_editing_page(&$mform, $question, $wizardnow)
{
list($heading, $langmodule) = $this->get_heading(empty($question->id));
print_heading_with_help($heading, $this->name(), $langmodule);
$permissionstrs = array();
if (!empty($question->id)) {
if ($question->formoptions->canedit) {
$permissionstrs[] = get_string('permissionedit', 'question');
}
if ($question->formoptions->canmove) {
$permissionstrs[] = get_string('permissionmove', 'question');
}
if ($question->formoptions->cansaveasnew) {
$permissionstrs[] = get_string('permissionsaveasnew', 'question');
}
}
if (!$question->formoptions->movecontext && count($permissionstrs)) {
print_heading(get_string('permissionto', 'question'), 'center', 3);
$html = '<ul>';
foreach ($permissionstrs as $permissionstr) {
$html .= '<li>' . $permissionstr . '</li>';
}
$html .= '</ul>';
print_box($html, 'boxwidthnarrow boxaligncenter generalbox');
}
$mform->display();
}
开发者ID:kai707,项目名称:ITSA-backup,代码行数:35,代码来源:questiontype.php
示例2: display_question_editing_page
/**
* This method should be overriden if you want to include a special heading or some other
* html on a question editing page besides the question editing form.
*
* @param question_edit_form $mform a child of question_edit_form
* @param object $question
* @param string $wizardnow is '' for first page.
*/
public function display_question_editing_page($mform, $question, $wizardnow) {
global $OUTPUT;
$heading = $this->get_heading(empty($question->id));
echo $OUTPUT->heading_with_help($heading, 'pluginname', $this->plugin_name());
$permissionstrs = array();
if (!empty($question->id)) {
if ($question->formoptions->canedit) {
$permissionstrs[] = get_string('permissionedit', 'question');
}
if ($question->formoptions->canmove) {
$permissionstrs[] = get_string('permissionmove', 'question');
}
if ($question->formoptions->cansaveasnew) {
$permissionstrs[] = get_string('permissionsaveasnew', 'question');
}
}
if (count($permissionstrs)) {
echo $OUTPUT->heading(get_string('permissionto', 'question'), 3);
$html = '<ul>';
foreach ($permissionstrs as $permissionstr) {
$html .= '<li>'.$permissionstr.'</li>';
}
$html .= '</ul>';
echo $OUTPUT->box($html, 'boxwidthnarrow boxaligncenter generalbox');
}
$mform->display();
}
开发者ID:rwijaya,项目名称:moodle,代码行数:37,代码来源:questiontypebase.php
示例3: display_question_editing_page
/**
* This method should be overriden if you want to include a special heading or some other
* html on a question editing page besides the question editing form.
*
* @param question_edit_form $mform a child of question_edit_form
* @param object $question
* @param string $wizardnow is '' for first page.
*/
public function display_question_editing_page($mform, $question, $wizardnow)
{
global $OUTPUT;
$heading = $this->get_heading(empty($question->id));
if (get_string_manager()->string_exists('pluginname_help', $this->plugin_name())) {
echo $OUTPUT->heading_with_help($heading, 'pluginname', $this->plugin_name());
} else {
echo $OUTPUT->heading_with_help($heading, $this->name(), $this->plugin_name());
}
//Who cares about that:
// $permissionstrs = array();
// if (!empty($question->id)) {
// if ($question->formoptions->canedit) {
// $permissionstrs[] = get_string('permissionedit', 'question');
// }
// if ($question->formoptions->canmove) {
// $permissionstrs[] = get_string('permissionmove', 'question');
// }
// if ($question->formoptions->cansaveasnew) {
// $permissionstrs[] = get_string('permissionsaveasnew', 'question');
// }
// }
// if (!$question->formoptions->movecontext && count($permissionstrs)) {
// echo $OUTPUT->heading(get_string('permissionto', 'question'), 3);
// $html = '<ul>';
// foreach ($permissionstrs as $permissionstr) {
// $html .= '<li>'.$permissionstr.'</li>';
// }
// $html .= '</ul>';
// echo $OUTPUT->box($html, 'boxwidthnarrow boxaligncenter generalbox');
// }
$mform->display();
}
开发者ID:sunilwebaccess,项目名称:moodle-question-matrix,代码行数:41,代码来源:questiontype.php
示例4: array
function set_data($question)
{
if (!empty($question->options->trueanswer)) {
$trueanswer = $question->options->answers[$question->options->trueanswer];
$draftid = file_get_submitted_draft_itemid('trueanswer');
$answerid = $question->options->trueanswer;
$text = $trueanswer->feedback;
$question->correctanswer = $trueanswer->fraction != 0;
$question->feedbacktrue = array();
$question->feedbacktrue['text'] = $trueanswer->feedback;
$question->feedbacktrue['format'] = $trueanswer->feedbackformat;
$question->feedbacktrue['text'] = file_prepare_draft_area($draftid, $this->context->id, 'question', 'answerfeedback', !empty($answerid) ? (int) $answerid : null, $this->fileoptions, $text);
$question->feedbacktrue['itemid'] = $draftid;
}
if (!empty($question->options->falseanswer)) {
$falseanswer = $question->options->answers[$question->options->falseanswer];
$draftid = file_get_submitted_draft_itemid('falseanswer');
$answerid = $question->options->falseanswer;
$text = $falseanswer->feedback;
$question->feedbackfalse = array();
$question->feedbackfalse['text'] = $falseanswer->feedback;
$question->feedbackfalse['format'] = $falseanswer->feedbackformat;
$question->feedbackfalse['text'] = file_prepare_draft_area($draftid, $this->context->id, 'question', 'answerfeedback', !empty($answerid) ? (int) $answerid : null, $this->fileoptions, $text);
$question->feedbackfalse['itemid'] = $draftid;
}
parent::set_data($question);
}
开发者ID:vuchannguyen,项目名称:web,代码行数:27,代码来源:edit_truefalse_form.php
示例5: validation
function validation($data, $files)
{
$errors = parent::validation($data, $files);
$answers = $data['subanswers'];
$questions = $data['subquestions'];
$questioncount = 0;
$answercount = 0;
foreach ($questions as $key => $question) {
$trimmedquestion = trim($question);
$trimmedanswer = trim($answers[$key]);
if ($trimmedquestion != '') {
$questioncount++;
}
if ($trimmedanswer != '' || $trimmedquestion != '') {
$answercount++;
}
if ($trimmedquestion != '' && $trimmedanswer == '') {
$errors['subanswers[' . $key . ']'] = get_string('nomatchinganswerforq', 'qtype_match', $trimmedquestion);
}
}
$numberqanda = new stdClass();
$numberqanda->q = 2;
$numberqanda->a = 3;
if ($questioncount < 1) {
$errors['subquestions[0]'] = get_string('notenoughqsandas', 'qtype_match', $numberqanda);
}
if ($questioncount < 2) {
$errors['subquestions[1]'] = get_string('notenoughqsandas', 'qtype_match', $numberqanda);
}
if ($answercount < 3) {
$errors['subanswers[2]'] = get_string('notenoughqsandas', 'qtype_match', $numberqanda);
}
return $errors;
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:34,代码来源:edit_match_form.php
示例6: validation
function validation($data, $files)
{
global $QTYPES;
$errors = parent::validation($data, $files);
// Check the answers.
$answercount = 0;
$maxgrade = false;
$answers = $data['answer'];
foreach ($answers as $key => $answer) {
$trimmedanswer = trim($answer);
if ($trimmedanswer != '') {
$answercount++;
if (!(is_numeric($trimmedanswer) || $trimmedanswer == '*')) {
$errors["answer[{$key}]"] = get_string('answermustbenumberorstar', 'qtype_numerical');
}
if ($data['fraction'][$key] == 1) {
$maxgrade = true;
}
} else {
if ($data['fraction'][$key] != 0 || !html_is_blank($data['feedback'][$key]['text'])) {
$errors["answer[{$key}]"] = get_string('answermustbenumberorstar', 'qtype_numerical');
$answercount++;
}
}
}
if ($answercount == 0) {
$errors['answer[0]'] = get_string('notenoughanswers', 'qtype_numerical');
}
if ($maxgrade == false) {
$errors['fraction[0]'] = get_string('fractionsnomax', 'question');
}
$QTYPES['numerical']->validate_numerical_options($data, $errors);
return $errors;
}
开发者ID:vuchannguyen,项目名称:web,代码行数:34,代码来源:edit_numerical_form.php
示例7: validation
public function validation($data, $files)
{
$errors = parent::validation($data, $files);
$answers = $data['answer'];
$answercount = 0;
$maxgrade = false;
foreach ($answers as $key => $answer) {
$trimmedanswer = trim($answer);
if ($trimmedanswer !== '') {
$answercount++;
if ($data['fraction'][$key] == 1) {
$maxgrade = true;
}
} else {
if ($data['fraction'][$key] != 0 || !html_is_blank($data['feedback'][$key]['text'])) {
$errors["answer[{$key}]"] = get_string('answermustbegiven', 'qtype_shortanswer');
$answercount++;
}
}
}
if ($answercount == 0) {
$errors['answer[0]'] = get_string('notenoughanswers', 'qtype_shortanswer', 1);
}
if ($maxgrade == false) {
$errors['fraction[0]'] = get_string('fractionsnomax', 'question');
}
return $errors;
}
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:28,代码来源:edit_shortanswer_form.php
示例8:
function set_data($question)
{
if (empty($question->name)) {
$question->name = get_string("random", "quiz");
}
parent::set_data($question);
}
开发者ID:veritech,项目名称:pare-project,代码行数:7,代码来源:edit_random_form.php
示例9: validation
public function validation($data, $files)
{
global $DB;
$errors = parent::validation($data, $files);
if (isset($data->categorymoveto)) {
list($category) = explode(',', $data['categorymoveto']);
} else {
list($category) = explode(',', $data['category']);
}
$saquestions = question_bank::get_qtype('randomsamatch')->get_sa_candidates($category);
$numberavailable = count($saquestions);
if ($saquestions === false) {
$a = new stdClass();
$a->catname = $DB->get_field('question_categories', 'name', array('id' => $category));
$errors['choose'] = get_string('nosaincategory', 'qtype_randomsamatch', $a);
} else {
if ($numberavailable < $data['choose']) {
$a = new stdClass();
$a->catname = $DB->get_field('question_categories', 'name', array('id' => $category));
$a->nosaquestions = $numberavailable;
$errors['choose'] = get_string('notenoughsaincategory', 'qtype_randomsamatch', $a);
}
}
return $errors;
}
开发者ID:helenagarcia90,项目名称:moodle,代码行数:25,代码来源:edit_randomsamatch_form.php
示例10: data_preprocessing
protected function data_preprocessing($question)
{
$question = parent::data_preprocessing($question);
if (empty($question->options)) {
return $question;
}
$question->responseformat = $question->options->responseformat;
$question->responsefieldlines = $question->options->responsefieldlines;
$question->attachments = $question->options->attachments;
$question->boardsize = $question->options->boardsize;
//Set backimage details, and configure a draft area to accept any uploaded pictures
//all this and this whole method does, is to load existing files into a filearea
//so it is not called when creating a new question, only when editing an existing one
//best to use file_get_submitted_draft_itemid - because copying questions gets weird otherwise
//$draftitemid =$question->options->backimage;
$draftitemid = file_get_submitted_draft_itemid('backimage');
file_prepare_draft_area($draftitemid, $this->context->id, 'qtype_poodllrecording', 'backimage', !empty($question->id) ? (int) $question->id : null, array('subdirs' => 0, 'maxbytes' => 0, 'maxfiles' => 1));
$question->backimage = $draftitemid;
$draftid = file_get_submitted_draft_itemid('graderinfo');
$question->graderinfo = array();
$question->graderinfo['text'] = file_prepare_draft_area($draftid, $this->context->id, 'qtype_poodllrecording', 'graderinfo', !empty($question->id) ? (int) $question->id : null, $this->fileoptions, $question->options->graderinfo);
$question->graderinfo['format'] = $question->options->graderinfoformat;
$question->graderinfo['itemid'] = $draftid;
return $question;
}
开发者ID:laiello,项目名称:poodll.poodll2,代码行数:25,代码来源:edit_poodllrecording_form.php
示例11: data_preprocessing
protected function data_preprocessing($question) {
$question = parent::data_preprocessing($question);
if (empty($question->options)) {
return $question;
}
$question->responseformat = $question->options->responseformat;
$question->responsefieldlines = $question->options->responsefieldlines;
$question->attachments = $question->options->attachments;
$draftid = file_get_submitted_draft_itemid('graderinfo');
$question->graderinfo = array();
$question->graderinfo['text'] = file_prepare_draft_area(
$draftid, // draftid
$this->context->id, // context
'qtype_essay', // component
'graderinfo', // filarea
!empty($question->id) ? (int) $question->id : null, // itemid
$this->fileoptions, // options
$question->options->graderinfo // text
);
$question->graderinfo['format'] = $question->options->graderinfoformat;
$question->graderinfo['itemid'] = $draftid;
$question->responselimitpolicy = $question->options->responselimitpolicy;
$question->wordlimit = $question->options->wordlimit;
$question->charlimit = $question->options->charlimit;
return $question;
}
开发者ID:nickkoeppen,项目名称:moodle,代码行数:30,代码来源:edit_essay_form.php
示例12: validation
function validation($data)
{
$errors = parent::validation($data);
$answers = $data['subanswers'];
$questions = $data['subquestions'];
$questioncount = 0;
foreach ($questions as $key => $question) {
$trimmedquestion = trim($question);
$trimmedanswer = trim($answers[$key]);
if (!empty($trimmedanswer) && !empty($trimmedquestion)) {
$questioncount++;
}
if (!empty($trimmedquestion) && empty($trimmedanswer)) {
$errors['subanswers[' . $key . ']'] = get_string('nomatchinganswerforq', 'qtype_match', $trimmedquestion);
}
}
if ($questioncount == 0) {
$errors['subquestions[0]'] = get_string('notenoughquestions', 'qtype_match', 3);
$errors['subquestions[1]'] = get_string('notenoughquestions', 'qtype_match', 3);
$errors['subquestions[2]'] = get_string('notenoughquestions', 'qtype_match', 3);
} elseif ($questioncount == 1) {
$errors['subquestions[1]'] = get_string('notenoughquestions', 'qtype_match', 3);
$errors['subquestions[2]'] = get_string('notenoughquestions', 'qtype_match', 3);
} elseif ($questioncount == 2) {
$errors['subquestions[2]'] = get_string('notenoughquestions', 'qtype_match', 3);
}
return $errors;
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:28,代码来源:edit_match_form.php
示例13: validation
function validation($data, $files)
{
$errors = parent::validation($data, $files);
$answers = $data['answer'];
$answercount = 0;
$totalfraction = 0;
$maxfraction = -1;
foreach ($answers as $key => $answer) {
//check no of choices
$trimmedanswer = trim($answer);
if (!empty($trimmedanswer)) {
$answercount++;
}
//check grades
if ($answer != '') {
if ($data['fraction'][$key] > 0) {
$totalfraction += $data['fraction'][$key];
}
if ($data['fraction'][$key] > $maxfraction) {
$maxfraction = $data['fraction'][$key];
}
}
}
if ($answercount == 0) {
$errors['answer[0]'] = get_string('notenoughanswers', 'qtype_multichoice', 1);
}
$totalfraction = round($totalfraction, 2);
if ($totalfraction != 1) {
$totalfraction = $totalfraction * 100;
$errors['fraction[0]'] = get_string('errfractionsaddwrong', 'qtype_multichoice', $totalfraction);
}
return $errors;
}
开发者ID:vuchannguyen,项目名称:web,代码行数:33,代码来源:edit_missingtype_form.php
示例14: reset
function set_data($question)
{
if (!empty($question->options) && !empty($question->options->answers)) {
$answer = reset($question->options->answers);
$question->feedback = $answer->feedback;
}
$question->penalty = 0;
parent::set_data($question);
}
开发者ID:kai707,项目名称:ITSA-backup,代码行数:9,代码来源:edit_essay_form.php
示例15:
function set_data($question)
{
if (empty($question->name)) {
$question->name = get_string("randomsamatch", "quiz");
}
if (empty($question->questiontext)) {
$question->questiontext = get_string("randomsamatchintro", "quiz");
}
parent::set_data($question);
}
开发者ID:veritech,项目名称:pare-project,代码行数:10,代码来源:edit_randomsamatch_form.php
示例16:
function set_data($question)
{
if (!empty($question->options->trueanswer)) {
$trueanswer = $question->options->answers[$question->options->trueanswer];
$question->correctanswer = $trueanswer->fraction != 0;
$question->feedbacktrue = $trueanswer->feedback;
$question->feedbackfalse = $question->options->answers[$question->options->falseanswer]->feedback;
}
parent::set_data($question);
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:10,代码来源:edit_truefalse_form.php
示例17: reset
function set_data($question)
{
if (!empty($question->options)) {
$question->essay = $question->options->essay;
$question->maxbytes = $question->options->maxbytes;
if (!empty($question->options->answers)) {
$answer = reset($question->options->answers);
$question->feedback = $answer->feedback;
}
}
$question->penalty = 0;
parent::set_data($question);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:13,代码来源:edit_imagedit_form.php
示例18: data_preprocessing
protected function data_preprocessing($question)
{
$question = parent::data_preprocessing($question);
if (empty($question->options)) {
return $question;
}
$question->responseformat = $question->options->responseformat;
$question->responsefieldlines = $question->options->responsefieldlines;
$question->attachments = $question->options->attachments;
$draftid = file_get_submitted_draft_itemid('graderinfo');
$question->graderinfo = array();
$question->graderinfo['text'] = file_prepare_draft_area($draftid, $this->context->id, 'qtype_poodllrecording', 'graderinfo', !empty($question->id) ? (int) $question->id : null, $this->fileoptions, $question->options->graderinfo);
$question->graderinfo['format'] = $question->options->graderinfoformat;
$question->graderinfo['itemid'] = $draftid;
return $question;
}
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:16,代码来源:edit_poodllrecording_form.php
示例19: validation
public function validation($data, $files)
{
$errors = parent::validation($data, $files);
$answers = $data['answer'];
$answercount = 0;
$totalfraction = 0;
$maxfraction = -1;
foreach ($answers as $key => $answer) {
//check no of choices
$trimmedanswer = trim($answer['text']);
$fraction = (double) $data['fraction'][$key];
if ($trimmedanswer === '' && empty($fraction)) {
continue;
}
if ($trimmedanswer === '') {
$errors['fraction[' . $key . ']'] = get_string('errgradesetanswerblank', 'qtype_turmultiplechoice');
}
$answercount++;
//check grades
if ($data['fraction'][$key] > 0) {
$totalfraction += $data['fraction'][$key];
}
if ($data['fraction'][$key] > $maxfraction) {
$maxfraction = $data['fraction'][$key];
}
}
if ($answercount == 0) {
$errors['answer[0]'] = get_string('notenoughanswers', 'qtype_turmultiplechoice', 2);
$errors['answer[1]'] = get_string('notenoughanswers', 'qtype_turmultiplechoice', 2);
} else {
if ($answercount == 1) {
$errors['answer[1]'] = get_string('notenoughanswers', 'qtype_turmultiplechoice', 2);
}
}
/// Perform sanity checks on fractional grades
if ($data['single']) {
if ($maxfraction != 1) {
$errors['fraction[0]'] = get_string('errfractionsnomax', 'qtype_turmultiplechoice', $maxfraction * 100);
}
} else {
$totalfraction = round($totalfraction, 2);
if ($totalfraction != 1) {
$errors['fraction[0]'] = get_string('errfractionsaddwrong', 'qtype_turmultiplechoice', $totalfraction * 100);
}
}
return $errors;
}
开发者ID:edwinphillips,项目名称:turmultiplechoice_2.7,代码行数:47,代码来源:edit_turmultiplechoice_form.php
示例20: foreach
function set_data($question)
{
if (isset($question->options)) {
$answers = $question->options->answers;
if (count($answers)) {
$key = 0;
foreach ($answers as $answer) {
$default_values['answer[' . $key . ']'] = $answer->answer;
$default_values['fraction[' . $key . ']'] = $answer->fraction;
$default_values['feedback[' . $key . ']'] = $answer->feedback;
$key++;
}
}
$question = (object) ((array) $question + $default_values);
}
parent::set_data($question);
}
开发者ID:veritech,项目名称:pare-project,代码行数:17,代码来源:edit_missingtype_form.php
注:本文中的question_edit_form类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论