本文整理汇总了PHP中moodleform_mod::data_preprocessing方法的典型用法代码示例。如果您正苦于以下问题:PHP moodleform_mod::data_preprocessing方法的具体用法?PHP moodleform_mod::data_preprocessing怎么用?PHP moodleform_mod::data_preprocessing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moodleform_mod
的用法示例。
在下文中一共展示了moodleform_mod::data_preprocessing方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function data_preprocessing(&$default_values)
{
parent::data_preprocessing($default_values);
// Fallsback on the default setting if 'Entries shown per page' has been left blank.
// This prevents the field from being required and expand its section which should not
// be the case if there is a default value defined.
if (empty($default_values['entbypage']) || $default_values['entbypage'] < 0) {
$default_values['entbypage'] = $this->get_default_entbypage();
}
// Set up the completion checkboxes which aren't part of standard data.
// We also make the default value (if you turn on the checkbox) for those
// numbers to be 1, this will not apply unless checkbox is ticked.
$default_values['completionentriesenabled'] = !empty($default_values['completionentries']) ? 1 : 0;
if (empty($default_values['completionentries'])) {
$default_values['completionentries'] = 1;
}
}
示例2:
function data_preprocessing(&$default_values)
{
parent::data_preprocessing($default_values);
// Set up the completion checkboxes which aren't part of standard data.
// We also make the default value (if you turn on the checkbox) for those
// numbers to be 1, this will not apply unless checkbox is ticked.
$default_values['completiondiscussionsenabled'] = !empty($default_values['completiondiscussions']) ? 1 : 0;
if (empty($default_values['completiondiscussions'])) {
$default_values['completiondiscussions'] = 1;
}
$default_values['completionrepliesenabled'] = !empty($default_values['completionreplies']) ? 1 : 0;
if (empty($default_values['completionreplies'])) {
$default_values['completionreplies'] = 1;
}
$default_values['completionpostsenabled'] = !empty($default_values['completionposts']) ? 1 : 0;
if (empty($default_values['completionposts'])) {
$default_values['completionposts'] = 1;
}
}
示例3:
/**
* Prepare completion checkboxes when form is displayed
*/
function data_preprocessing(&$default_values)
{
parent::data_preprocessing($default_values);
// Set up the completion checkboxes which aren't part of standard data.
// We also make the default value (if you turn on the checkbox) for those
// numbers to be 1, this will not apply unless checkbox is ticked.
$default_values['completiontotaldurationenabled'] = !empty($default_values['completiontotaldurationmins']) ? 1 : 0;
if (empty($default_values['completiontotaldurationmins'])) {
$default_values['completiontotaldurationmins'] = ATTENDANCEREGISTER_DEFAULT_COMPLETION_TOTAL_DURATION_MINS;
}
// ... when more tracked values will be supported, set default value here
}
示例4:
function data_preprocessing(&$default_values)
{
parent::data_preprocessing($default_values);
}
示例5: data_preprocessing
public function data_preprocessing(&$default_values)
{
parent::data_preprocessing($default_values);
// Set up the completion checkboxes which aren't part of standard data.
// We also make the default value (if you turn on the checkbox) for those
// numbers to be 1, this will not apply unless checkbox is ticked.
$default_values['completionallviewedenabled'] = !empty($default_values['completionallviewed']) ? 1 : 0;
if (empty($default_values['completionallviewed'])) {
$default_values['completionallviewed'] = 999;
}
$default_values['completionallgoodenabled'] = !empty($default_values['completionallgood']) ? 1 : 0;
}
示例6: data_preprocessing
/**
*
*/
public function data_preprocessing(&$data)
{
$data = (array) $data;
parent::data_preprocessing($data);
// Set up the completion checkboxes which aren't part of standard data.
$data['completionentriesenabled'] = (int) (!empty($data['completionentries']));
$data['completionspecificgradeenabled'] = (int) (!empty($data['completionspecificgrade']));
// Set up the grade calc and grade guide.
if ($this->_instance) {
$df = \mod_dataform_dataform::instance($this->_instance);
if ($gradeitems = $df->grade_items) {
if (!empty($gradeitems[0]['ca'])) {
$data['gradecalc'] = $gradeitems[0]['ca'];
}
if (!empty($gradeitems[0]['ru'])) {
$data['gradeguide'] = $gradeitems[0]['ru'];
}
}
}
}
示例7: data_preprocessing
public function data_preprocessing(&$defaultvalues)
{
global $DB, $CFG;
parent::data_preprocessing($defaultvalues);
if (isset($_COOKIE["emarking_headerqr"])) {
$defaultvalues["headerqr"] = $_COOKIE["emarking_headerqr"];
}
if (isset($_COOKIE["emarking_exam_defaults"]) && ($json = json_decode($_COOKIE["emarking_exam_defaults"]))) {
$defaultvalues["headerqr"] = $json->headerqr;
$defaultvalues["printrandom"] = $json->printrandom;
$defaultvalues["printlist"] = $json->printlist;
$defaultvalues["extrasheets"] = $json->extrasheets;
$defaultvalues["extraexams"] = $json->extraexams;
$defaultvalues["usebackside"] = $json->usebackside;
$defaultvalues["enrolments"] = $json->enrolments;
}
$defaultvalues["visible"] = 0;
if ($this->_instance) {
$markers = $DB->get_records('emarking_markers', array('emarking' => $this->_instance));
foreach ($markers as $marker) {
$defaultvalues['marker-' . $marker->marker] = 1;
}
if ($exam = $DB->get_record("emarking_exams", array("emarking" => $this->_instance))) {
$defaultvalues["examdate"] = $exam->examdate;
$defaultvalues["printlist"] = $exam->printlist;
$defaultvalues["printdoublesided"] = $exam->usebackside;
$defaultvalues["headerqr"] = $exam->headerqr;
$defaultvalues["comment"] = $exam->comment;
$defaultvalues["extrasheets"] = $exam->extrasheets;
$defaultvalues["extraexams"] = $exam->extraexams;
// If we are editing, we use the previous enrolments.
$enrolincludes = explode(",", $exam->enrolments);
} else {
$enrolincludes = array();
}
} else {
if (isset($CFG->emarking_enrolincludes)) {
$enrolincludes = explode(",", $CFG->emarking_enrolincludes);
} else {
$enrolincludes = array();
}
}
// We set the default enrolments to use the previous ones or the default ones.
$enrolavailables = $this->get_available_enrolments();
foreach ($enrolincludes as $enroldefault) {
if (in_array($enroldefault, $enrolavailables)) {
$defaultvalues["enrolments[{$enroldefault}]"] = true;
}
}
}
示例8: array
function data_preprocessing(&$default_values)
{
global $DB;
parent::data_preprocessing($default_values);
if (isset($_COOKIE["emarking_headerqr"])) {
if ($_COOKIE["emarking_headerqr"] == 1) {
$default_values["headerqr"] = 1;
} else {
$default_values["headerqr"] = 0;
}
}
if (isset($_COOKIE["emarking_exam_defaults"])) {
if ($json = json_decode($_COOKIE["emarking_exam_defaults"])) {
$default_values["headerqr"] = $json->headerqr;
$default_values["printrandom"] = $json->printrandom;
$default_values["printlist"] = $json->printlist;
$default_values["extrasheets"] = $json->extrasheets;
$default_values["extraexams"] = $json->extraexams;
$default_values["usebackside"] = $json->usebackside;
$default_values["enrolments"] = $json->enrolments;
}
}
$default_values["visible"] = 0;
if ($this->_instance) {
$markers = $DB->get_records('emarking_markers', array('emarking' => $this->_instance));
foreach ($markers as $marker) {
$default_values['marker-' . $marker->marker] = 1;
}
$exam = $DB->get_record("emarking_exams", array("emarking" => $this->_instance));
if ($exam) {
$default_values["examdate"] = $exam->examdate;
$default_values["printlist"] = $exam->printlist;
$default_values["printdoublesided"] = $exam->usebackside;
$default_values["headerqr"] = $exam->headerqr;
$default_values["extrasheets"] = $exam->extrasheets;
$default_values["extraexams"] = $exam->extraexams;
$enrolavailables = $this->getAvailableEnrolments();
// If we are editing, we use the previous enrolments
if (isset($exam->enrolments)) {
$enrolincludes = explode(",", $exam->enrolments);
foreach ($enrolincludes as $enroldefault) {
if (in_array($enroldefault, $enrolavailables)) {
$default_values["enrolments[{$enroldefault}]"] = true;
}
}
// If we are creating a new one, the default comes from the plugin settings
} else {
if ($CFG->emarking_enrolincludes && strlen($CFG->emarking_enrolincludes) > 1) {
$enrolincludes = explode(",", $CFG->emarking_enrolincludes);
foreach ($enrolincludes as $enroldefault) {
if (in_array($enroldefault, $enrolavailables)) {
$default_values["enrolments[{$enroldefault}]"] = true;
}
}
}
}
}
}
}
示例9: data_preprocessing
/**
* Prepares the form before data are set
*
* Additional wysiwyg editor are prepared here, the introeditor is prepared automatically by core.
* Grade items are set here because the core modedit supports single grade item only.
*
* @param array $data to be set
* @return void
*/
public function data_preprocessing(&$data)
{
global $CFG;
require_once dirname(__FILE__) . '/locallib.php';
parent::data_preprocessing($data);
if ($this->current->instance) {
// editing an existing certificate - let us prepare the added editor elements (intro done automatically), and files
//First Page
//Get firstimage
$imagedraftitemid = file_get_submitted_draft_itemid('certificateimage');
//Get firtsimage filearea information
$imagefileinfo = simplecertificate::get_certificate_image_fileinfo($this->context);
file_prepare_draft_area($imagedraftitemid, $imagefileinfo['contextid'], $imagefileinfo['component'], $imagefileinfo['filearea'], $imagefileinfo['itemid'], $this->get_filemanager_options_array());
$data['certificateimage'] = $imagedraftitemid;
//Prepare certificate text
$data['certificatetext'] = array('text' => $data['certificatetext'], 'format' => FORMAT_HTML);
//Second page
//Get Back image
$secondimagedraftitemid = file_get_submitted_draft_itemid('secondimage');
//Get secondimage filearea info
$secondimagefileinfo = simplecertificate::get_certificate_secondimage_fileinfo($this->context);
file_prepare_draft_area($secondimagedraftitemid, $secondimagefileinfo['contextid'], $secondimagefileinfo['component'], $secondimagefileinfo['filearea'], $secondimagefileinfo['itemid'], $this->get_filemanager_options_array());
$data['secondimage'] = $secondimagedraftitemid;
//Get backpage text
if (!empty($data['secondpagetext'])) {
$data['secondpagetext'] = array('text' => $data['secondpagetext'], 'format' => FORMAT_HTML);
} else {
$data['secondpagetext'] = array('text' => '', 'format' => FORMAT_HTML);
}
} else {
//Load default
$data['certificatetext'] = array('text' => '', 'format' => FORMAT_HTML);
$data['secondpagetext'] = array('text' => '', 'format' => FORMAT_HTML);
}
//completion rules
$data['completiontimeenabled'] = !empty($data['requiredtime']) ? 1 : 0;
}
示例10:
function data_preprocessing(&$defaultvalues)
{
parent::data_preprocessing($defaultvalues);
if (array_key_exists('scale', $defaultvalues)) {
$defaultvalues['grade'] = $defaultvalues['scale'];
}
}
示例11: array
function data_preprocessing(&$default_values)
{
parent::data_preprocessing($default_values);
if ($this->current->instance) {
// editing existing instance - copy existing files into draft area
$draftitemid = file_get_submitted_draft_itemid('id');
file_prepare_draft_area($draftitemid, $this->context->id, 'mod_pcast', 'logo', 0, array('subdirs' => false));
$default_values['image'] = $draftitemid;
// convert topcategory and nested to a single category
$default_values['category'] = (int) $default_values['topcategory'] * 1000 + (int) $default_values['nestedcategory'];
}
}
示例12: array
function data_preprocessing(&$default_values)
{
parent::data_preprocessing($default_values);
global $DB;
//determine if default lrs settings were overriden
if (!empty($default_values['overridedefaults'])) {
if ($default_values['overridedefaults'] == '1') {
//retrieve activity lrs settings from DB
$tincanlaunch_lrs = $DB->get_record('tincanlaunch_lrs', array('tincanlaunchid' => $default_values['instance']), $fields = '*', $strictness = IGNORE_MISSING);
$default_values['tincanlaunchlrsendpoint'] = $tincanlaunch_lrs->lrsendpoint;
$default_values['tincanlaunchlrsauthentication'] = $tincanlaunch_lrs->lrsauthentication;
$default_values['tincanlaunchlrslogin'] = $tincanlaunch_lrs->lrslogin;
$default_values['tincanlaunchlrspass'] = $tincanlaunch_lrs->lrspass;
$default_values['tincanlaunchcustomacchp'] = $tincanlaunch_lrs->customacchp;
$default_values['tincanlaunchuseactoremail'] = $tincanlaunch_lrs->useactoremail;
$default_values['tincanlaunchlrsduration'] = $tincanlaunch_lrs->lrsduration;
}
}
$draftitemid = file_get_submitted_draft_itemid('packagefile');
file_prepare_draft_area($draftitemid, $this->context->id, 'mod_tincanlaunch', 'package', 0, array('subdirs' => 0, 'maxfiles' => 1));
$defaultvalues['packagefile'] = $draftitemid;
// Set up the completion checkboxes which aren't part of standard data.
// We also make the default value (if you turn on the checkbox) for those
// numbers to be 1, this will not apply unless checkbox is ticked.
$default_values['completionverbenabled'] = !empty($default_values['tincanverbid']) ? 1 : 0;
if (empty($default_values['tincanverbid'])) {
$default_values['completionverbenabled'] = 1;
}
}