本文整理汇总了PHP中moodleform_mod::set_data方法的典型用法代码示例。如果您正苦于以下问题:PHP moodleform_mod::set_data方法的具体用法?PHP moodleform_mod::set_data怎么用?PHP moodleform_mod::set_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moodleform_mod
的用法示例。
在下文中一共展示了moodleform_mod::set_data方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
/**
* Load in existing data as form defaults. Usually new entry defaults are stored directly in
* form definition (new entry form); this function is used to load in data where values
* already exist and data is being edited (edit entry form).
*
* @see: /course/moodleform.php
*/
function set_data($default_values)
{
if (is_object($default_values)) {
$default_values = (array) $default_values;
}
$default_values['details']['text'] = $default_values['intro'];
parent::set_data($default_values);
}
示例2: switch
function set_data($default_values)
{
$default_values = (array) $default_values;
if (isset($default_values['scormtype']) and isset($default_values['reference'])) {
switch ($default_values['scormtype']) {
case SCORM_TYPE_LOCALSYNC:
case SCORM_TYPE_EXTERNAL:
case SCORM_TYPE_IMSREPOSITORY:
$default_values['packageurl'] = $default_values['reference'];
}
}
unset($default_values['reference']);
if (!empty($default_values['options'])) {
$options = explode(',', $default_values['options']);
foreach ($options as $option) {
$opt = explode('=', $option);
if (isset($opt[1])) {
$default_values[$opt[0]] = $opt[1];
}
}
}
$this->data_preprocessing($default_values);
parent::set_data($default_values);
}
示例3: unset
function set_data($default_values)
{
$default_values = (array) $default_values;
if (isset($default_values['url'])) {
if (jclic_is_valid_external_url($default_values['url'])) {
$default_values['filetype'] = JCLIC_FILE_TYPE_EXTERNAL;
$default_values['url'] = $default_values['url'];
} else {
$default_values['filetype'] = JCLIC_FILE_TYPE_LOCAL;
$default_values['jclicfile'] = $default_values['url'];
unset($default_values['url']);
}
}
$this->data_preprocessing($default_values);
parent::set_data($default_values);
}
示例4: set_data
public function set_data($data)
{
if ($data->coursemodule) {
$context = context_module::instance($data->coursemodule);
$draftitemid = file_get_submitted_draft_itemid('customfront');
$maxbytes = 100000;
file_prepare_draft_area($draftitemid, $context->id, 'mod_flashcard', 'customfront', 0, array('subdirs' => 0, 'maxbytes' => $maxbytes, 'maxfiles' => 1));
$data->customfrontfileid = $draftitemid;
$draftitemid = file_get_submitted_draft_itemid('customback');
$maxbytes = 100000;
file_prepare_draft_area($draftitemid, $context->id, 'mod_flashcard', 'customback', 0, array('subdirs' => 0, 'maxbytes' => $maxbytes, 'maxfiles' => 1));
$data->custombackfileid = $draftitemid;
$draftitemid = file_get_submitted_draft_itemid('customempty');
$maxbytes = 100000;
file_prepare_draft_area($draftitemid, $context->id, 'mod_flashcard', 'customempty', 0, array('subdirs' => 0, 'maxbytes' => $maxbytes, 'maxfiles' => 1));
$data->customemptyfileid = $draftitemid;
$draftitemid = file_get_submitted_draft_itemid('customreview');
$maxbytes = 100000;
file_prepare_draft_area($draftitemid, $context->id, 'mod_flashcard', 'customreview', 0, array('subdirs' => 0, 'maxbytes' => $maxbytes, 'maxfiles' => 1));
$data->customreviewfileid = $draftitemid;
$draftitemid = file_get_submitted_draft_itemid('customreview');
$maxbytes = 100000;
file_prepare_draft_area($draftitemid, $context->id, 'mod_flashcard', 'customreviewed', 0, array('subdirs' => 0, 'maxbytes' => $maxbytes, 'maxfiles' => 1));
$data->customreviewedfileid = $draftitemid;
$draftitemid = file_get_submitted_draft_itemid('customreviewempty');
$maxbytes = 100000;
file_prepare_draft_area($draftitemid, $context->id, 'mod_flashcard', 'customreviewempty', 0, array('subdirs' => 0, 'maxbytes' => $maxbytes, 'maxfiles' => 1));
$data->customreviewemptyfileid = $draftitemid;
}
if (empty($data->extracss)) {
$data->extracss = '
/* panel div for question */
.flashcard-question{
}
/* panel div for answer */
.flashcard-answer{
}
';
}
parent::set_data($data);
}
示例5: explode
function set_data($default_values)
{
if (is_object($default_values)) {
if (!empty($default_values->options)) {
$options = explode(',', $default_values->options);
foreach ($options as $option) {
$opt = explode('=', $option);
if (isset($opt[1])) {
$default_values->{$opt}[0] = $opt[1];
}
}
}
$default_values = (array) $default_values;
}
$this->data_preprocessing($default_values);
parent::set_data($default_values);
//never slashed for moodleform_mod
}
示例6: substr
function set_data($default_values)
{
global $DB;
if (isset($default_values->type)) {
//Default values for every game.
if ($default_values->type == 'hangman') {
$default_values->param10 = 6;
//maximum number of wrongs
} else {
if ($default_values->type == 'snakes') {
$default_values->gamekind = $default_values->type;
$default_values->param3 = 1;
$default_values->questioncategoryid = 0;
} else {
if ($default_values->type == 'millionaire') {
$default_values->shuffle = 1;
}
}
}
}
if (isset($default_values->gamekind)) {
if ($default_values->gamekind == 'hangman') {
if ($default_values->param10 == 0) {
$default_values->param10 = 6;
}
} else {
if ($default_values->gamekind == 'millionaire') {
if (isset($default_values->param8)) {
$default_values->param8 = '#' . substr('000000' . strtoupper(dechex($default_values->param8)), -6);
}
}
}
//repair questioncategoryid
$categoryid = $default_values->questioncategoryid;
$contextid = $DB->get_field('question_categories', 'contextid', array('id' => $categoryid));
$default_values->questioncategoryid = $categoryid . ',' . $contextid;
if ($default_values->gamekind == 'snakes') {
if (isset($default_values->param9)) {
$a = explode('#', $default_values->param9);
foreach ($a as $s) {
$pos = strpos($s, ':');
if ($pos) {
$name = substr($s, 0, $pos);
$default_values->{$name} = substr($s, $pos + 1);
}
}
}
}
}
if (isset($default_values->param3)) {
$board = $default_values->param3;
if ($board != 0) {
$rec = $DB->get_record('game_snakes_database', array('id' => $board));
$default_values->snakes_data = $rec->data;
$default_values->snakes_cols = $rec->cols;
$default_values->snakes_rows = $rec->rows;
$default_values->snakes_headerx = $rec->headerx;
$default_values->snakes_headery = $rec->headery;
$default_values->snakes_footerx = $rec->footerx;
$default_values->snakes_footery = $rec->footery;
}
}
parent::set_data($default_values);
}
示例7: set_data
/**
*
*/
public function set_data($data)
{
$this->data_preprocessing($data);
parent::set_data($data);
}
示例8:
function set_data($data)
{
global $USER;
// insert some default values
if (!isset($data->instance) || !$data->instance || !isset($data->managingeditor)) {
$data->showpreview = 1;
$data->managingeditor = $USER->email . ' (' . $USER->firstname . ' ' . $USER->lastname . ')';
}
return parent::set_data($data);
}
示例9: strtoupper
function set_data($default_values)
{
global $DB;
if (isset($default_values->gamekind)) {
if ($default_values->gamekind == 'millionaire') {
if (isset($default_values->param8)) {
$default_values->param8 = '#' . strtoupper(dechex($default_values->param8));
}
}
if ($default_values->gamekind == 'snakes') {
if (isset($default_values->param9)) {
$a = explode('#', $default_values->param9);
foreach ($a as $s) {
$pos = strpos($s, ':');
if ($pos) {
$name = substr($s, 0, $pos);
$default_values->{$name} = substr($s, $pos + 1);
}
}
}
}
}
if (isset($default_values->param3)) {
$board = $default_values->param3;
if ($board != 0) {
$rec = $DB->get_record('game_snakes_database', array('id' => $board));
$default_values->snakes_board = $rec->data;
$default_values->snakes_cols = $rec->cols;
$default_values->snakes_rows = $rec->rows;
$default_values->snakes_headerx = $rec->headerx;
$default_values->snakes_headery = $rec->headery;
$default_values->snakes_footerx = $rec->footerx;
$default_values->snakes_footery = $rec->footery;
}
}
parent::set_data($default_values);
}
示例10: isset
function set_data($values)
{
global $CFG;
$values = (array) $values;
if (isset($values['url'])) {
// Need to translate the "url" field
if (geogebra_is_valid_external_url($values['url'])) {
$values['filetype'] = GEOGEBRA_FILE_TYPE_EXTERNAL;
$values['geogebraurl'] = $values['url'];
} else {
$values['filetype'] = GEOGEBRA_FILE_TYPE_LOCAL;
$values['geogebrafile'] = $values['url'];
}
// Load attributes
parse_str($values['attributes'], $attributes);
$values['enableRightClick'] = isset($attributes['enableRightClick']) ? $attributes['enableRightClick'] : 0;
$values['enableLabelDrags'] = isset($attributes['enableLabelDrags']) ? $attributes['enableLabelDrags'] : 0;
$values['showResetIcon'] = isset($attributes['showResetIcon']) ? $attributes['showResetIcon'] : 0;
$values['showMenuBar'] = isset($attributes['showMenuBar']) ? $attributes['showMenuBar'] : 0;
$values['showToolBar'] = isset($attributes['showToolBar']) ? $attributes['showToolBar'] : 0;
$values['showToolBarHelp'] = isset($attributes['showToolBarHelp']) ? $attributes['showToolBarHelp'] : 0;
$values['showAlgebraInput'] = isset($attributes['showAlgebraInput']) ? $attributes['showAlgebraInput'] : 0;
$values['language'] = isset($attributes['language']) ? $attributes['language'] : 0;
}
unset($values['url']);
$this->data_preprocessing($values);
parent::set_data($values);
}
示例11: set_data
public function set_data($data)
{
if (!empty($data->id)) {
$collection = new \mod_mediagallery\collection($data);
$data->tags = $collection->get_tags();
if ($collection->count_galleries() && $collection->is_assessable()) {
$this->_form->hardFreeze('colltype');
}
}
parent::set_data($data);
}
示例12:
function set_data($data)
{
$this->form = $data;
parent::set_data($data);
}