本文整理汇总了PHP中editors_get_preferred_format函数的典型用法代码示例。如果您正苦于以下问题:PHP editors_get_preferred_format函数的具体用法?PHP editors_get_preferred_format怎么用?PHP editors_get_preferred_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了editors_get_preferred_format函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(dialogue $dialogue = null, conversation $conversation = null)
{
global $USER;
$this->_dialogue = $dialogue;
$this->_conversation = $conversation;
$this->_authorid = $USER->id;
$this->_bodyformat = editors_get_preferred_format();
$this->_timecreated = time();
$this->_timemodified = time();
}
示例2: redirect
$event = \mod_mediagallery\event\item_updated::create($params);
$event->add_record_snapshot('mediagallery_item', $item->get_record());
$event->trigger();
}
}
redirect(new moodle_url('/mod/mediagallery/view.php', array('g' => $gallery->id, 'editing' => 1)));
} else {
if ($item) {
$data = $item->get_record();
$draftitemid = file_get_submitted_draft_itemid('content');
file_prepare_draft_area($draftitemid, $context->id, 'mod_mediagallery', 'item', $data->id);
if ($gallery->galleryfocus == \mod_mediagallery\base::TYPE_AUDIO) {
$draftitemidthumb = file_get_submitted_draft_itemid('customthumbnail');
$data->customthumbnail = $draftitemidthumb;
}
$draftideditor = file_get_submitted_draft_itemid('description');
$currenttext = file_prepare_draft_area($draftideditor, $context->id, 'mod_mediagallery', 'description', empty($data->id) ? null : $data->id, array('subdirs' => 0), empty($data->description) ? '' : $data->description);
$data->content = $draftitemid;
$data->description = array('text' => $currenttext, 'format' => editors_get_preferred_format(), 'itemid' => $draftideditor);
$data->tags = $item->get_tags();
$mform->set_data($data);
}
}
}
$maxitems = $mediagallery->maxitems;
if (!$item && $maxitems != 0 && count($gallery->get_items()) >= $maxitems) {
print_error('errortoomanyitems', 'mediagallery', '', $maxitems);
}
echo $OUTPUT->header();
$mform->display();
echo $OUTPUT->footer();
示例3: add_allocation
/**
* Allocate a submission to a user for review
*
* @param stdClass $submission Submission object with at least id property
* @param int $reviewerid User ID
* @param int $weight of the new assessment, from 0 to 16
* @param bool $bulk repeated inserts into DB expected
* @return int ID of the new assessment or an error code
*/
public function add_allocation(stdclass $submission, $reviewerid, $weight=1, $bulk=false) {
global $DB;
if ($DB->record_exists('workshop_assessments', array('submissionid' => $submission->id, 'reviewerid' => $reviewerid))) {
return self::ALLOCATION_EXISTS;
}
$weight = (int)$weight;
if ($weight < 0) {
$weight = 0;
}
if ($weight > 16) {
$weight = 16;
}
$now = time();
$assessment = new stdclass();
$assessment->submissionid = $submission->id;
$assessment->reviewerid = $reviewerid;
$assessment->timecreated = $now; // do not set timemodified here
$assessment->weight = $weight;
$assessment->generalcommentformat = editors_get_preferred_format();
$assessment->feedbackreviewerformat = editors_get_preferred_format();
return $DB->insert_record('workshop_assessments', $assessment, true, $bulk);
}
示例4: create_forum_discussion
/**
* Function to create a dummy discussion.
*
* @param array|stdClass $record
* @return stdClass the discussion object
*/
public function create_forum_discussion($record = null) {
global $DB;
// Increment the forum discussion count.
$this->forumdiscussioncount++;
$record = (array) $record;
if (!isset($record['course'])) {
throw new coding_exception('course must be present in phpunit_util::create_forum_discussion() $record');
}
if (!isset($record['forum'])) {
throw new coding_exception('forum must be present in phpunit_util::create_forum_discussion() $record');
}
if (!isset($record['userid'])) {
throw new coding_exception('userid must be present in phpunit_util::create_forum_discussion() $record');
}
if (!isset($record['name'])) {
$record['name'] = "Discussion " . $this->forumdiscussioncount;
}
if (!isset($record['subject'])) {
$record['subject'] = "Subject for discussion " . $this->forumdiscussioncount;
}
if (!isset($record['message'])) {
$record['message'] = html_writer::tag('p', 'Message for discussion ' . $this->forumdiscussioncount);
}
if (!isset($record['messageformat'])) {
$record['messageformat'] = editors_get_preferred_format();
}
if (!isset($record['messagetrust'])) {
$record['messagetrust'] = "";
}
if (!isset($record['assessed'])) {
$record['assessed'] = '1';
}
if (!isset($record['groupid'])) {
$record['groupid'] = "-1";
}
if (!isset($record['timestart'])) {
$record['timestart'] = "0";
}
if (!isset($record['timeend'])) {
$record['timeend'] = "0";
}
if (!isset($record['mailnow'])) {
$record['mailnow'] = "0";
}
$record = (object) $record;
// Add the discussion.
$record->id = forum_add_discussion($record, null, null, $record->userid);
return $record;
}
示例5: __construct
/**
* Instantiates a new event and optionally populates its properties with the
* data provided
*
* @param stdClass $data Optional. An object containing the properties to for
* an event
*/
public function __construct($data = null)
{
global $CFG, $USER;
// First convert to object if it is not already (should either be object or assoc array)
if (!is_object($data)) {
$data = (object) $data;
}
$this->editoroptions['maxbytes'] = $CFG->maxbytes;
$data->eventrepeats = 0;
if (empty($data->id)) {
$data->id = null;
}
if (!empty($data->subscriptionid)) {
$data->subscription = calendar_get_subscription($data->subscriptionid);
}
// Default to a user event
if (empty($data->eventtype)) {
$data->eventtype = 'user';
}
// Default to the current user
if (empty($data->userid)) {
$data->userid = $USER->id;
}
if (!empty($data->timeduration) && is_array($data->timeduration)) {
$data->timeduration = make_timestamp($data->timeduration['year'], $data->timeduration['month'], $data->timeduration['day'], $data->timeduration['hour'], $data->timeduration['minute']) - $data->timestart;
}
if (!empty($data->description) && is_array($data->description)) {
$data->format = $data->description['format'];
$data->description = $data->description['text'];
} else {
if (empty($data->description)) {
$data->description = '';
$data->format = editors_get_preferred_format();
}
}
// Ensure form is defaulted correctly
if (empty($data->format)) {
$data->format = editors_get_preferred_format();
}
if (empty($data->context)) {
$data->context = $this->calculate_context($data);
}
$this->properties = $data;
}
示例6: data_preprocessing
/**
* Prepares the form before data are set
*
* Additional wysiwyg editors are prepared here
* along with the stopbutton switch, type and text
*
* @param array $data to be set
* @return void
*/
function data_preprocessing(&$data)
{
// Note: if you call "file_prepare_draft_area()" without setting itemid
// (the first argument), then it will be assigned automatically, and the files
// for this context will be transferred automatically, which is what we want
$data['sourceitemid'] = 0;
if ($this->is_add()) {
$contextid = null;
} else {
$contextid = $this->context->id;
}
$options = hotpot::sourcefile_options();
// array('subdirs' => 1, 'maxbytes' => 0, 'maxfiles' => -1);
file_prepare_draft_area($data['sourceitemid'], $contextid, 'mod_hotpot', 'sourcefile', 0, $options);
if ($this->is_add()) {
// set fields from user preferences, where possible
foreach (hotpot::user_preferences_fieldnames() as $fieldname) {
if (!isset($data[$fieldname])) {
$data[$fieldname] = get_user_preferences('hotpot_' . $fieldname, '');
}
}
}
// set entry/exit page settings
foreach (hotpot::text_page_types() as $type) {
// extract boolean switches for page options
foreach (hotpot::text_page_options($type) as $name => $mask) {
$data[$type . '_' . $name] = $data[$type . 'options'] & $mask;
}
// setup custom wysiwyg editor
$draftitemid = 0;
if ($this->is_add()) {
// adding a new hotpot instance
$data[$type . 'editor'] = array('text' => file_prepare_draft_area($draftitemid, $contextid, 'mod_hotpot', $type, 0), 'format' => editors_get_preferred_format(), 'itemid' => file_get_submitted_draft_itemid($type));
} else {
// editing an existing hotpot
$data[$type . 'editor'] = array('text' => file_prepare_draft_area($draftitemid, $contextid, 'mod_hotpot', $type, 0, $options, $data[$type . 'text']), 'format' => $data[$type . 'format'], 'itemid' => file_get_submitted_draft_itemid($type));
}
}
// timelimit
if ($data['timelimit'] > 0) {
$data['timelimitspecific'] = $data['timelimit'];
$data['timelimit'] = hotpot::TIME_SPECIFIC;
} else {
$data['timelimitspecific'] = 0;
}
// delay3
if ($data['delay3'] > 0) {
$data['delay3specific'] = $data['delay3'];
$data['delay3'] = hotpot::TIME_SPECIFIC;
} else {
$data['delay3specific'] = 0;
}
// set stopbutton options
switch ($data['stopbutton']) {
case hotpot::STOPBUTTON_SPECIFIC:
$data['stopbutton_yesno'] = 1;
$data['stopbutton_type'] = 'specific';
$data['stopbutton_text'] = $data['stoptext'];
break;
case hotpot::STOPBUTTON_LANGPACK:
$data['stopbutton_yesno'] = 1;
$data['stopbutton_type'] = $data['stoptext'];
$data['stopbutton_text'] = '';
break;
case hotpot::STOPBUTTON_NONE:
default:
$data['stopbutton_yesno'] = 0;
$data['stopbutton_type'] = '';
$data['stopbutton_text'] = '';
}
// set review options
if (empty($data['reviewoptions'])) {
$default = 0;
} else {
$default = $data['reviewoptions'];
}
list($times, $items) = hotpot::reviewoptions_times_items();
foreach ($times as $timename => $timevalue) {
foreach ($items as $itemname => $itemvalue) {
$data[$timename . $itemname] = min(1, $default & $timevalue & $itemvalue);
}
}
}
示例7: 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)
{
if ($this->current->instance) {
// editing an existing workshop - let us prepare the added editor elements (intro done automatically)
$draftitemid = file_get_submitted_draft_itemid('instructauthors');
$data['instructauthorseditor']['text'] = file_prepare_draft_area($draftitemid, $this->context->id, 'mod_workshop', 'instructauthors', 0, workshop::instruction_editors_options($this->context), $data['instructauthors']);
$data['instructauthorseditor']['format'] = $data['instructauthorsformat'];
$data['instructauthorseditor']['itemid'] = $draftitemid;
$draftitemid = file_get_submitted_draft_itemid('instructreviewers');
$data['instructreviewerseditor']['text'] = file_prepare_draft_area($draftitemid, $this->context->id, 'mod_workshop', 'instructreviewers', 0, workshop::instruction_editors_options($this->context), $data['instructreviewers']);
$data['instructreviewerseditor']['format'] = $data['instructreviewersformat'];
$data['instructreviewerseditor']['itemid'] = $draftitemid;
$draftitemid = file_get_submitted_draft_itemid('conclusion');
$data['conclusioneditor']['text'] = file_prepare_draft_area($draftitemid, $this->context->id, 'mod_workshop', 'conclusion', 0, workshop::instruction_editors_options($this->context), $data['conclusion']);
$data['conclusioneditor']['format'] = $data['conclusionformat'];
$data['conclusioneditor']['itemid'] = $draftitemid;
} else {
// adding a new workshop instance
$draftitemid = file_get_submitted_draft_itemid('instructauthors');
file_prepare_draft_area($draftitemid, null, 'mod_workshop', 'instructauthors', 0);
// no context yet, itemid not used
$data['instructauthorseditor'] = array('text' => '', 'format' => editors_get_preferred_format(), 'itemid' => $draftitemid);
$draftitemid = file_get_submitted_draft_itemid('instructreviewers');
file_prepare_draft_area($draftitemid, null, 'mod_workshop', 'instructreviewers', 0);
// no context yet, itemid not used
$data['instructreviewerseditor'] = array('text' => '', 'format' => editors_get_preferred_format(), 'itemid' => $draftitemid);
$draftitemid = file_get_submitted_draft_itemid('conclusion');
file_prepare_draft_area($draftitemid, null, 'mod_workshop', 'conclusion', 0);
// no context yet, itemid not used
$data['conclusioneditor'] = array('text' => '', 'format' => editors_get_preferred_format(), 'itemid' => $draftitemid);
}
}
示例8: if
$discussionsubscribe = true;
} else if (!isset($discussion) && \mod_forum\subscriptions::is_subscribed($USER->id, $forum, null, $cm)) {
// Starting a new discussion, and the user is subscribed to the forum - subscribe to the discussion.
$discussionsubscribe = true;
} else {
// User is not subscribed to either forum or discussion. Follow user preference.
$discussionsubscribe = $USER->autosubscribe;
}
}
$mform_post->set_data(array( 'attachments'=>$draftitemid,
'general'=>$heading,
'subject'=>$post->subject,
'message'=>array(
'text'=>$currenttext,
'format'=>empty($post->messageformat) ? editors_get_preferred_format() : $post->messageformat,
'itemid'=>$draftid_editor
),
'discussionsubscribe' => $discussionsubscribe,
'mailnow'=>!empty($post->mailnow),
'userid'=>$post->userid,
'parent'=>$post->parent,
'discussion'=>$post->discussion,
'course'=>$course->id) +
$page_params +
(isset($post->format)?array(
'format'=>$post->format):
array())+
(isset($discussion->timestart)?array(
示例9: data_preprocessing
function data_preprocessing($question)
{
global $QTYPES;
$answer = $this->answer;
$default_values = array();
if (count($answer)) {
$key = 0;
foreach ($answer as $answer) {
$default_values['answer[' . $key . ']'] = $answer->answer;
// is necessary ? to-do test it
$default_values['fraction[' . $key . ']'] = $answer->fraction;
$default_values['tolerance[' . $key . ']'] = $answer->tolerance;
$default_values['tolerancetype[' . $key . ']'] = $answer->tolerancetype;
$default_values['correctanswerlength[' . $key . ']'] = $answer->correctanswerlength;
$default_values['correctanswerformat[' . $key . ']'] = $answer->correctanswerformat;
// prepare draft files
$draftid = file_get_submitted_draft_itemid('feedback[' . $key . ']');
$default_values['feedback[' . $key . ']']['text'] = file_prepare_draft_area($draftid, $this->context->id, 'question', 'answerfeedback', !empty($answer->id) ? (int) $answer->id : null, $this->fileoptions, !empty($answer->feedback) ? $answer->feedback : '');
$default_values['feedback[' . $key . ']']['format'] = !empty($answer->feedbackformat) ? $answer->feedbackformat : editors_get_preferred_format();
$default_values['feedback[' . $key . ']']['itemid'] = $draftid;
$key++;
}
}
$default_values['synchronize'] = 0;
$QTYPES['numerical']->set_numerical_unit_data($this, $question, $default_values);
/* if (isset($question->options)){
$default_values['unitgradingtype'] = $question->options->unitgradingtype ;
$default_values['unitpenalty'] = $question->options->unitpenalty ;
switch ($question->options->showunits){
case 'O' :
case '1' :
$default_values['showunits0'] = $question->options->showunits ;
$default_values['unitrole'] = 0 ;
break;
case '2' :
case '3' :
$default_values['showunits1'] = $question->options->showunits ;
$default_values['unitrole'] = 1 ;
break;
}
$default_values['unitsleft'] = $question->options->unitsleft ;
$default_values['instructions'] = $question->options->instructions ;
if (isset($question->options->units)){
$units = array_values($question->options->units);
if (!empty($units)) {
foreach ($units as $key => $unit){
$default_values['unit['.$key.']'] = $unit->unit;
$default_values['multiplier['.$key.']'] = $unit->multiplier;
}
}
}
}
*/
$key = 0;
$formdata = array();
$fromform = new stdClass();
//this should be done before the elements are created and stored as $this->formdata ;
//fill out all data sets and also the fields for the next item to add.
/* if(!empty($this->datasetdefs)){
$j = $this->noofitems * count($this->datasetdefs);
for ($itemnumber = $this->noofitems; $itemnumber >= 1; $itemnumber--){
$data = array();
foreach ($this->datasetdefs as $defid => $datasetdef){
if (isset($datasetdef->items[$itemnumber])){
$formdata["number[$j]"] = $datasetdef->items[$itemnumber]->value;
$formdata["definition[$j]"] = $defid;
$formdata["itemid[$j]"] = $datasetdef->items[$itemnumber]->id;
$data[$datasetdef->name] = $datasetdef->items[$itemnumber]->value;
}
$j--;
}
// echo "<p>answers avant comment <pre>";print_r($answer);echo"</pre></p>";
// echo "<p>data avant comment <pre>";print_r($data);echo"</pre></p>";
if($this->noofitems != 0 ) {
if(!isset($question->id)) $question->id = 0 ;
$comment = $this->qtypeobj->comment_on_datasetitems($question->id,$this->nonemptyanswer, $data, $itemnumber);//$this->
if ($comment->outsidelimit) {
$this->outsidelimit=$comment->outsidelimit ;
}
$totalcomment='';
// echo "<p> comment <pre>";print_r($comment);echo"</pre></p>";
foreach ($this->nonemptyanswer as $key => $answer) {
$totalcomment .= $comment->stranswers[$key].'<br/>';
}
$formdata['answercomment['.$itemnumber.']'] = $totalcomment ;
}
}
// $formdata['reload'] = '1';
// $formdata['nextpageparam[forceregeneration]'] = $this->regenerate;
$formdata['selectdelete'] = '1';
$formdata['selectadd'] = '1';
$j = $this->noofitems * count($this->datasetdefs)+1;
$data = array(); // data for comment_on_datasetitems later
$idx =1 ;
foreach ($this->datasetdefs as $defid => $datasetdef){
$formdata["datasetdef[$idx]"] = $defid;
//.........这里部分代码省略.........
示例10: get_string
print get_string('advice_edit', 'ouwiki', $OUTPUT->help_icon('createlinkedwiki', 'ouwiki'));
if ($ouwiki->timeout) {
$countdowntext = get_string('countdowntext', 'ouwiki', $ouwiki->timeout / 60);
print "<script type='text/javascript'>\n document.write('<p><div id=\"ouw_countdown\"></div>{$countdowntext}<span id=\"ouw_countdownurgent\"></span></p>');\n </script>";
}
// Set up basic form data
$data = new StdClass();
$data->id = $cm->id;
$data->startversionid = $pageversion->versionid;
$data->page = $pagename;
$data->frompage = $frompage;
$data->newsection = $newsection;
$data->section = $section;
$data->user = $subwiki->userid;
// Prepare form file manager attachments
if ($useattachments) {
$attachmentsdraftid = file_get_submitted_draft_itemid('attachments');
file_prepare_draft_area($attachmentsdraftid, $context->id, 'mod_ouwiki', 'attachment', empty($pageversion->versionid) ? null : $pageversion->versionid);
$data->attachments = $attachmentsdraftid;
}
// Prepare form editor attachments
$contentdraftid = file_get_submitted_draft_itemid('content');
$currenttext = file_prepare_draft_area($contentdraftid, $context->id, 'mod_ouwiki', 'content', empty($pageversion->versionid) ? null : $pageversion->versionid, array('subdirs' => false), empty($existing) ? '' : $existing);
$data->content = array('text' => $currenttext, 'format' => empty($pageversion->xhtmlformat) ? editors_get_preferred_format() : $pageversion->xhtmlformat, 'itemid' => $contentdraftid);
$mform->set_data($data);
$mform->display();
$stringlist = array(array('savefailnetwork', 'ouwiki'), array('savefailtitle', 'ouwiki'));
$jsmodule = array('name' => 'mod_ouwiki_edit', 'fullpath' => '/mod/ouwiki/module.js', 'requires' => array('base', 'event', 'io', 'node', 'anim', 'moodle-core-notification-alert', 'button'), 'strings' => $stringlist);
$PAGE->requires->js_init_call('M.mod_ouwiki_edit.init', null, true, $jsmodule);
// Footer
ouwiki_print_footer($course, $cm, $subwiki, $pagename);
示例11: local_mail_setup_page
$url->param('m', $message->id());
local_mail_setup_page($message->course(), $url);
// Remove recipients
if ($remove) {
require_sesskey();
$message->remove_recipient(key($remove));
}
// Set up form
$data = array();
$customdata = array();
$customdata['message'] = $message;
$customdata['context'] = $PAGE->context;
$mform = new mail_compose_form($url, $customdata);
$draftareaid = file_get_submitted_draft_itemid('message');
$content = file_prepare_draft_area($draftareaid, $PAGE->context->id, 'local_mail', 'message', $message->id(), mail_compose_form::file_options(), $message->content());
$format = $message->format() >= 0 ? $message->format() : editors_get_preferred_format();
$data['course'] = $message->course()->id;
$data['subject'] = $message->subject();
$data['content']['format'] = $format;
$data['content']['text'] = $content;
$data['content']['itemid'] = $draftareaid;
$data['attachments'] = $draftareaid;
$mform->set_data($data);
// Process form
if ($data = $mform->get_data()) {
$fs = get_file_storage();
// Discard message
if (!empty($data->discard)) {
$fs->delete_area_files($PAGE->context->id, 'local_mail', 'message', $message->id());
$message->discard();
$params = array('t' => 'course', 'c' => $message->course()->id);
示例12: get_numerical_options
function get_numerical_options(&$question) {
global $DB;
if (!$options = $DB->get_record('question_numerical_options', array('question' => $question->id))) {
$question->options->unitgradingtype = 0; // total grade
$question->options->unitpenalty = 0.1; // default for old questions
// the default
if ($defaultunit = $this->get_default_numerical_unit($question)) {
// so units can be graded
$question->options->showunits = NUMERICALQUESTIONUNITTEXTINPUTDISPLAY ;
}else {
// only numerical will be graded
$question->options->showunits = NUMERICALQUESTIONUNITNODISPLAY ;
}
$question->options->unitsleft = 0 ;
$question->options->instructions = '';
$question->options->instructionsformat = editors_get_preferred_format();
} else {
$question->options->unitgradingtype = $options->unitgradingtype;
$question->options->unitpenalty = $options->unitpenalty;
$question->options->showunits = $options->showunits;
$question->options->unitsleft = $options->unitsleft;
$question->options->instructions = $options->instructions;
$question->options->instructionsformat = $options->instructionsformat;
}
return true;
}
示例13: set_data
function set_data($question)
{
global $QTYPES;
// prepare question text
$draftid = file_get_submitted_draft_itemid('questiontext');
if (!empty($question->questiontext)) {
$questiontext = $question->questiontext;
} else {
$questiontext = '';
}
$questiontext = file_prepare_draft_area($draftid, $this->context->id, 'question', 'questiontext', empty($question->id) ? null : (int) $question->id, $this->fileoptions, $questiontext);
$question->questiontext = array();
$question->questiontext['text'] = $questiontext;
$question->questiontext['format'] = empty($question->questiontextformat) ? editors_get_preferred_format() : $question->questiontextformat;
$question->questiontext['itemid'] = $draftid;
// prepare general feedback
$draftid = file_get_submitted_draft_itemid('generalfeedback');
if (empty($question->generalfeedback)) {
$question->generalfeedback = '';
}
$feedback = file_prepare_draft_area($draftid, $this->context->id, 'question', 'generalfeedback', empty($question->id) ? null : (int) $question->id, $this->fileoptions, $question->generalfeedback);
$question->generalfeedback = array();
$question->generalfeedback['text'] = $feedback;
$question->generalfeedback['format'] = empty($question->generalfeedbackformat) ? editors_get_preferred_format() : $question->generalfeedbackformat;
$question->generalfeedback['itemid'] = $draftid;
// Remove unnecessary trailing 0s form grade fields.
if (isset($question->defaultgrade)) {
$question->defaultgrade = 0 + $question->defaultgrade;
}
if (isset($question->penalty)) {
$question->penalty = 0 + $question->penalty;
}
// Set any options.
$extra_question_fields = $QTYPES[$question->qtype]->extra_question_fields();
if (is_array($extra_question_fields) && !empty($question->options)) {
array_shift($extra_question_fields);
foreach ($extra_question_fields as $field) {
if (isset($question->options->{$field})) {
$question->{$field} = $question->options->{$field};
}
}
}
// subclass adds data_preprocessing code here
$question = $this->data_preprocessing($question);
parent::set_data($question);
}
示例14: referentiel
/**
* Constructor for the base referentiel class
*
* Constructor for the base referentiel class.
* If cmid is set create the cm, course, referentiel objects.
* If the referentiel is hidden and the user is not a teacher then
* this prints a page header and notice.
*
* @global object
* @global object
* @param int $cmid the current course module id - not set for new assignments
* @param object $referentiel usually null, but if we have it we pass it to save db access
* @param object $cm usually null, but if we have it we pass it to save db access
* @param object $course usually null, but if we have it we pass it to save db access
*/
function referentiel($cmid = 'staticonly', $referentiel = NULL, $cm = NULL, $course = NULL)
{
global $COURSE, $DB;
if ($cmid == 'staticonly') {
//use static functions only!
return;
}
global $CFG;
if ($cm) {
$this->cm = $cm;
} else {
if (!($this->cm = get_coursemodule_from_id('referentiel', $cmid))) {
print_error('invalidcoursemodule');
}
}
// Valable pour Moodle 2.1 et Moodle 2.2
////if ($CFG->version < 2011120100) {
$this->context = context_module::instance($this->cm->id);
//} else {
// // $this->context = context_module::instance($this->cm);
//}
if ($course) {
$this->course = $course;
} else {
if ($this->cm->course == $COURSE->id) {
$this->course = $COURSE;
} else {
if (!($this->course = $DB->get_record('course', array('id' => $this->cm->course)))) {
print_error('invalidid', 'referentiel');
}
}
}
// valeurs par defaut
$this->referentiel = new stdClass();
$this->referentiel->name = "";
$this->referentiel->description_instance = "";
$this->referentiel->label_domaine = trim(get_string('domaine', 'referentiel'));
$this->referentiel->label_competence = trim(get_string('competence', 'referentiel'));
$this->referentiel->label_item = trim(get_string('item', 'referentiel'));
$this->referentiel->label_item = trim(get_string('item', 'referentiel'));
$this->referentiel->config = $this->creer_configuration('config');
$this->referentiel->config_impression = $this->creer_configuration('configuration_impression');
$this->referentiel->config_globale = $this->referentiel->config;
$this->referentiel->config_impression_globale = $this->referentiel->config_impression;
$this->referentiel->ref_referentiel = 0;
$this->referentiel->visible = 1;
$this->referentiel->intro = "";
$this->referentiel->introformat = 1;
$this->referentiel->maxbytes = 1048576;
if ($referentiel) {
$this->referentiel = $referentiel;
} else {
if (!($this->referentiel = $DB->get_record('referentiel', array('id' => $this->cm->instance)))) {
print_error('invalidid', 'referentiel');
}
}
$this->referentiel->cmidnumber = $this->cm->idnumber;
// compatibility with modedit referentiel obj
$this->referentiel->course = $this->course->id;
// compatibility with modedit referentiel obj
if (!empty($this->referentiel->ref_referentiel)) {
// occurrence associe
$this->referentiel_referentiel = $DB->get_record('referentiel_referentiel', array('id' => $this->referentiel->ref_referentiel));
}
$this->strreferentiel = get_string('modulename', 'referentiel');
$this->strreferentiels = get_string('modulenameplural', 'referentiel');
$this->strsubmissions = get_string('submissions', 'referentiel');
$this->strlastmodified = get_string('lastmodified');
$this->pagetitle = strip_tags($this->course->shortname . ': ' . $this->strreferentiel . ': ' . format_string($this->referentiel->name, true));
// visibility handled by require_login() with $cm parameter
// get current group only when really needed
/// Set up things for a HTML editor if it's needed
$this->defaultformat = editors_get_preferred_format();
}
示例15: upgrade
/**
* Upgrade the submission from the old assignment to the new one
*
* @param context $oldcontext - the database for the old assignment context
* @param stdClass $oldassignment The data record for the old assignment
* @param stdClass $oldsubmission The data record for the old submission
* @param stdClass $submission The data record for the new submission
* @param string $log Record upgrade messages in the log
* @return bool true or false - false will trigger a rollback
*/
public function upgrade(context $oldcontext, stdClass $oldassignment, stdClass $oldsubmission, stdClass $submission, &$log)
{
global $DB;
$onlinetextsubmission = new stdClass();
$onlinetextsubmission->onlinetext = $oldsubmission->data1;
$onlinetextsubmission->onlineformat = $oldsubmission->data2;
$onlinetextsubmission->submission = $submission->id;
$onlinetextsubmission->assignment = $this->assignment->get_instance()->id;
if ($onlinetextsubmission->onlinetext === null) {
$onlinetextsubmission->onlinetext = '';
}
if ($onlinetextsubmission->onlineformat === null) {
$onlinetextsubmission->onlineformat = editors_get_preferred_format();
}
if (!$DB->insert_record('assignsubmission_onlinetext', $onlinetextsubmission) > 0) {
$log .= get_string('couldnotconvertsubmission', 'mod_assign', $submission->userid);
return false;
}
// now copy the area files
$this->assignment->copy_area_files_for_upgrade($oldcontext->id, 'mod_assignment', 'submission', $oldsubmission->id, $this->assignment->get_context()->id, 'assignsubmission_onlinetext', ASSIGNSUBMISSION_ONLINETEXT_FILEAREA, $submission->id);
return true;
}