コード例 #1
0
 function build_editform($item, $feedback, $cm)
 {
     global $DB, $CFG;
     require_once 'label_form.php';
     //get the lastposition number of the feedback_items
     $position = $item->position;
     $lastposition = $DB->count_records('feedback_item', array('feedback' => $feedback->id));
     if ($position == -1) {
         $i_formselect_last = $lastposition + 1;
         $i_formselect_value = $lastposition + 1;
         $item->position = $lastposition + 1;
     } else {
         $i_formselect_last = $lastposition;
         $i_formselect_value = $item->position;
     }
     //the elements for position dropdownlist
     $positionlist = array_slice(range(0, $i_formselect_last), 1, $i_formselect_last, true);
     //all items for dependitem
     $feedbackitems = feedback_get_depend_candidates_for_item($feedback, $item);
     $commonparams = array('cmid' => $cm->id, 'id' => isset($item->id) ? $item->id : NULL, 'typ' => $item->typ, 'items' => $feedbackitems, 'feedback' => $feedback->id);
     $this->context = get_context_instance(CONTEXT_MODULE, $cm->id);
     //preparing the editor for new file-api
     $item->presentationformat = FORMAT_HTML;
     $item->presentationtrust = 1;
     $item = file_prepare_standard_editor($item, 'presentation', $this->presentationoptions, $this->context, 'mod_feedback', 'item', $item->id);
     //build the form
     $this->item_form = new feedback_label_form('edit_item.php', array('item' => $item, 'common' => $commonparams, 'positionlist' => $positionlist, 'position' => $position, 'presentationoptions' => $this->presentationoptions));
 }
コード例 #2
0
 /**
  * Called to define this moodle form
  *
  * @return void
  */
 public function definition()
 {
     global $DB;
     $mform =& $this->_form;
     $course = $this->_customdata['course'];
     $cm = $this->_customdata['cm'];
     $modcontext = $this->_customdata['modcontext'];
     $sessionid = $this->_customdata['sessionid'];
     if (!($sess = $DB->get_record('attendance_sessions', array('id' => $sessionid)))) {
         error('No such session in this course');
     }
     $dhours = floor($sess->duration / HOURSECS);
     $dmins = floor(($sess->duration - $dhours * HOURSECS) / MINSECS);
     $defopts = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean' => true, 'context' => $modcontext);
     $sess = file_prepare_standard_editor($sess, 'description', $defopts, $modcontext, 'mod_attendance', 'session', $sess->id);
     $data = array('sessiondate' => $sess->sessdate, 'durtime' => array('hours' => $dhours, 'minutes' => $dmins), 'sdescription' => $sess->description_editor);
     $mform->addElement('header', 'general', get_string('changesession', 'attendance'));
     $mform->addElement('static', 'olddate', get_string('olddate', 'attendance'), userdate($sess->sessdate, get_string('strftimedmyhm', 'attendance')));
     $mform->addElement('date_time_selector', 'sessiondate', get_string('newdate', 'attendance'));
     for ($i = 0; $i <= 23; $i++) {
         $hours[$i] = sprintf("%02d", $i);
     }
     for ($i = 0; $i < 60; $i += 5) {
         $minutes[$i] = sprintf("%02d", $i);
     }
     $durselect[] =& $mform->createElement('select', 'hours', '', $hours);
     $durselect[] =& $mform->createElement('select', 'minutes', '', $minutes, false, true);
     $mform->addGroup($durselect, 'durtime', get_string('duration', 'attendance'), array(' '), true);
     $mform->addElement('editor', 'sdescription', get_string('description', 'attendance'), null, $defopts);
     $mform->setType('sdescription', PARAM_RAW);
     $mform->setDefaults($data);
     $submit_string = get_string('update', 'attendance');
     $this->add_action_buttons(true, $submit_string);
 }
コード例 #3
0
ファイル: editsection_form.php プロジェクト: evltuma/moodle
 /**
  * Load in existing data as form defaults
  *
  * @param stdClass|array $default_values object or array of default values
  */
 function set_data($default_values)
 {
     if (!is_object($default_values)) {
         // we need object for file_prepare_standard_editor
         $default_values = (object) $default_values;
     }
     $editoroptions = $this->_customdata['editoroptions'];
     $default_values = file_prepare_standard_editor($default_values, 'summary', $editoroptions, $editoroptions['context'], 'course', 'section', $default_values->id);
     $default_values->usedefaultname = strval($default_values->name) === '';
     parent::set_data($default_values);
 }
コード例 #4
0
ファイル: lib.php プロジェクト: narasimhaeabyas/tataaiapro
    public function build_editform($item, $evaluation, $cm,$classid) {
        global $DB, $CFG;
        require_once('label_form.php');

        //get the lastposition number of the evaluation_items
        $position = $item->position;
        $lastposition = $DB->count_records('evaluation_item', array('evaluation'=>$evaluation->id));
        if ($position == -1) {
            $i_formselect_last = $lastposition + 1;
            $i_formselect_value = $lastposition + 1;
            $item->position = $lastposition + 1;
        } else {
            $i_formselect_last = $lastposition;
            $i_formselect_value = $item->position;
        }
        //the elements for position dropdownlist
        $positionlist = array_slice(range(0, $i_formselect_last), 1, $i_formselect_last, true);

        //all items for dependitem
        $evaluationitems = evaluation_get_depend_candidates_for_item($evaluation, $item);
        $commonparams = array('cmid'=>$cm,
                              'clid'=>$classid,
                             'id'=>isset($item->id) ? $item->id : null,
                             'typ'=>$item->typ,
                             'items'=>$evaluationitems,
                             'evaluation'=>$evaluation->id);

     //   $this->context = context_localule::instance($cm->id);

        //preparing the editor for new file-api
        $item->presentationformat = FORMAT_HTML;
        $item->presentationtrust = 1;

        // Append editor context to presentation options, giving preference to existing context.
        $this->presentationoptions = array_merge(array('context' => $this->context),
                                                 $this->presentationoptions);

        $item = file_prepare_standard_editor($item,
                                            'presentation', //name of the form element
                                            $this->presentationoptions,
                                            $this->context,
                                            'local_evaluations',
                                            'item', //the filearea
                                            $item->id);

        //build the form
        $customdata = array('item' => $item,
                            'common' => $commonparams,
                            'positionlist' => $positionlist,
                            'position' => $position,
                            'presentationoptions' => $this->presentationoptions);

        $this->item_form = new evaluation_label_form('edit_item.php', $customdata);
    }
コード例 #5
0
ファイル: locallib.php プロジェクト: vinoth4891/clinique
 /**
  * Add form elements for settings
  *
  * @param mixed $submission can be null
  * @param MoodleQuickForm $mform
  * @param stdClass $data
  * @return true if elements were added to the form
  */
 public function get_form_elements($submission, MoodleQuickForm $mform, stdClass $data)
 {
     $elements = array();
     $editoroptions = $this->get_edit_options();
     $submissionid = $submission ? $submission->id : 0;
     if (!isset($data->onlinetext)) {
         $data->onlinetext = '';
     }
     if (!isset($data->onlinetextformat)) {
         $data->onlinetextformat = editors_get_preferred_format();
     }
     if ($submission) {
         $onlinetextsubmission = $this->get_onlinetext_submission($submission->id);
         if ($onlinetextsubmission) {
             $data->onlinetext = $onlinetextsubmission->onlinetext;
             $data->onlinetextformat = $onlinetextsubmission->onlineformat;
         }
     }
     $data = file_prepare_standard_editor($data, 'onlinetext', $editoroptions, $this->assignment->get_context(), 'assignsubmission_onlinetext', ASSIGNSUBMISSION_ONLINETEXT_FILEAREA, $submissionid);
     $mform->addElement('editor', 'onlinetext_editor', '', null, $editoroptions);
     return true;
 }
コード例 #6
0
ファイル: edit.php プロジェクト: EmmanuelYupit/educursos
$PAGE->set_subpage($tag->id);
$PAGE->set_context($systemcontext);
$PAGE->set_blocks_editing_capability('moodle/tag:editblocks');
$PAGE->set_pagelayout('base');
$tagname = tag_display_name($tag);
// set the relatedtags field of the $tag object that will be passed to the form
$tag->relatedtags = tag_get_related_tags_csv(tag_get_related_tags($tag->id, TAG_RELATED_MANUAL), TAG_RETURN_TEXT);
$options = new stdClass();
$options->smiley = false;
$options->filter = false;
// convert and remove any XSS
$tag->description = format_text($tag->description, $tag->descriptionformat, $options);
$tag->descriptionformat = FORMAT_HTML;
$errorstring = '';
$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'context' => $systemcontext, 'subdirs' => file_area_contains_subdirs($systemcontext, 'tag', 'description', $tag->id));
$tag = file_prepare_standard_editor($tag, 'description', $editoroptions, $systemcontext, 'tag', 'description', $tag->id);
$tagform = new tag_edit_form(null, compact('editoroptions'));
if ($tag->tagtype == 'official') {
    $tag->tagtype = '1';
} else {
    $tag->tagtype = '0';
}
$tagform->set_data($tag);
// If new data has been sent, update the tag record
if ($tagnew = $tagform->get_data()) {
    if (has_capability('moodle/tag:manage', $systemcontext)) {
        if ($tag->tagtype != 'default' && (!isset($tagnew->tagtype) || $tagnew->tagtype != '1')) {
            tag_type_set($tag->id, 'default');
        } elseif ($tag->tagtype != 'official' && $tagnew->tagtype == '1') {
            tag_type_set($tag->id, 'official');
        }
コード例 #7
0
ファイル: exsubmission.php プロジェクト: rushi963/moodle
        $asid = $workshop->add_allocation($example, $USER->id, 0);
    }
    if ($asid == workshop::ALLOCATION_EXISTS) {
        // the training assessment of the example was not found but the allocation already
        // exists. this probably means that the user is the author of the reference assessment.
        echo $output->header();
        echo $output->box(get_string('assessmentreferenceconflict', 'workshop'));
        echo $output->continue_button($workshop->view_url());
        echo $output->footer();
        die;
    }
    redirect($workshop->exassess_url($asid));
}
if ($edit and $canmanage) {
    require_once dirname(__FILE__) . '/submission_form.php';
    $example = file_prepare_standard_editor($example, 'content', $workshop->submission_content_options(), $workshop->context, 'mod_workshop', 'submission_content', $example->id);
    $example = file_prepare_standard_filemanager($example, 'attachment', $workshop->submission_attachment_options(), $workshop->context, 'mod_workshop', 'submission_attachment', $example->id);
    $mform = new workshop_submission_form($PAGE->url, array('current' => $example, 'workshop' => $workshop, 'contentopts' => $workshop->submission_content_options(), 'attachmentopts' => $workshop->submission_attachment_options()));
    if ($mform->is_cancelled()) {
        redirect($workshop->view_url());
    } elseif ($canmanage and $formdata = $mform->get_data()) {
        if ($formdata->example == 1) {
            // this was used just for validation, it must be set to one when dealing with example submissions
            unset($formdata->example);
        } else {
            throw new coding_exception('Invalid submission form data value: example');
        }
        $timenow = time();
        if (is_null($example->id)) {
            $formdata->workshopid = $workshop->id;
            $formdata->example = 1;
コード例 #8
0
} else {
    if ($node = $PAGE->navigation->find('myprofile', navigation_node::TYPE_ROOTNODE)) {
        $node->force_open();
    }
}
// Process email change cancellation.
if ($cancelemailchange) {
    cancel_email_update($user->id);
}
// Load user preferences.
useredit_load_preferences($user);
// Load custom profile fields data.
profile_load_data($user);
// Prepare the editor and create form.
$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'forcehttps' => false, 'context' => $personalcontext);
$user = file_prepare_standard_editor($user, 'description', $editoroptions, $personalcontext, 'user', 'profile', 0);
// Prepare filemanager draft area.
$draftitemid = 0;
$filemanagercontext = $editoroptions['context'];
$filemanageroptions = array('maxbytes' => $CFG->maxbytes, 'subdirs' => 0, 'maxfiles' => 1, 'accepted_types' => 'web_image');
file_prepare_draft_area($draftitemid, $filemanagercontext->id, 'user', 'newicon', 0, $filemanageroptions);
$user->imagefile = $draftitemid;
// Create form.
$userform = new user_edit_form(new moodle_url($PAGE->url, array('returnto' => $returnto)), array('editoroptions' => $editoroptions, 'filemanageroptions' => $filemanageroptions, 'user' => $user));
$emailchanged = false;
if ($usernew = $userform->get_data()) {
    // Deciding where to send the user back in most cases.
    if ($returnto === 'profile') {
        if ($course->id != SITEID) {
            $returnurl = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $course->id));
        } else {
コード例 #9
0
ファイル: mod_form.php プロジェクト: OctaveBabel/moodle-itop
 public function set_data($customlabel)
 {
     if (empty($customlabel->labelclass)) {
         $customlabel->labelclass = 'text';
         $customlabel->content = '';
         $customlabel->processedcontent = '';
         $customlabel->intro = '';
         $customlabel->introformat = 0;
     }
     $instance = customlabel_load_class($customlabel, $customlabel->labelclass);
     $formdata = $customlabel;
     // Get dynamic part of data and add to fixed model part from customlabel record.
     $formdatadyn = (array) json_decode(base64_decode($customlabel->content));
     foreach ($formdatadyn as $key => $value) {
         // Discard all moodle core data that should be there.
         if (in_array($key, array('coursemodule', 'instance', 'sesskey', 'module', 'section'))) {
             continue;
         }
         // Ignore old Moodle 1.9 stuff.
         if (in_array($key, array('safe_content', 'usesafe'))) {
             continue;
         }
         $formdata->{$key} = $value;
         if (is_object($formdata->{$key}) && isset($formdata->{$key}->text)) {
             $formdata->{$key} = (array) $formdata->{$key};
         }
     }
     // Prepare editor for intro standard field.
     // Prepare editors for all textarea|editor dynamic fields prepared in model.
     foreach ($instance->fields as $field) {
         if (preg_match('/editor|textarea/', $field->type)) {
             $fieldname = $field->name;
             $editorname = $fieldname . '_editor';
             $formdata->{$editorname} = array('text' => @$formdata->{$fieldname}, 'format' => FORMAT_HTML);
             $editoroptions = self::editor_options();
             $editoroptions['context'] = $this->context;
             // Fakes format field.
             $fieldnameformat = $fieldname . 'format';
             $customlabel->{$fieldnameformat} = FORMAT_HTML;
             $defaults = file_prepare_standard_editor($customlabel, $fieldname, $editoroptions, $this->context, 'mod_customlabel', 'contentfiles', @$customlabel->{$fieldname});
         }
         if (preg_match('/datasource$/', $field->type)) {
             $name = $field->name;
             $formdata->{$name} = @$formdatadyn[$name . 'option'];
         }
         // Todo : limit upload size on course settings
         $maxbytes = -1;
         if ($field->type == 'filepicker') {
             $draftitemid = file_get_submitted_draft_itemid($field->name);
             $groupname = $field->name . 'group';
             $maxfiles = 1;
             file_prepare_draft_area($draftitemid, $this->context->id, 'mod_customlabel', $field->name, 0, array('subdirs' => 0, 'maxbytes' => $maxbytes, 'maxfiles' => $maxfiles));
             $formdata->{$groupname} = array($field->name => $draftitemid);
         }
     }
     // Prepare type selector value.
     if ($tomodel = optional_param('type', '', PARAM_TEXT)) {
         $formdata->labelclass = $tomodel;
     }
     $formdata->sesskey = sesskey();
     parent::set_data($formdata);
 }
コード例 #10
0
ファイル: essay.php プロジェクト: Hirenvaghasiya/moodle
        $table->data[] = array(' ', ' ', $emailalllink);
        echo html_writer::table($table);
        break;
    case 'grade':
        // Trigger the essay grade viewed event.
        $event = \mod_lesson\event\essay_attempt_viewed::create(array('objectid' => $attempt->id, 'relateduserid' => $attempt->userid, 'context' => $context, 'courseid' => $course->id));
        $event->add_record_snapshot('lesson_attempts', $attempt);
        $event->trigger();
        // Grading form
        // Expects the following to be set: $attemptid, $answer, $user, $page, $attempt
        $essayinfo = lesson_page_type_essay::extract_useranswer($attempt->useranswer);
        $currentpage = $lesson->load_page($attempt->pageid);
        $mform = new essay_grading_form(null, array('scoreoptions' => $scoreoptions, 'user' => $user));
        $data = new stdClass();
        $data->id = $cm->id;
        $data->attemptid = $attemptid;
        $data->score = $essayinfo->score;
        $data->question = format_text($currentpage->contents, $currentpage->contentsformat, $formattextdefoptions);
        $data->studentanswer = format_text($essayinfo->answer, $essayinfo->answerformat, array('context' => $context, 'para' => true));
        $data->response = $essayinfo->response;
        $data->responseformat = $essayinfo->responseformat;
        $editoroptions = array('noclean' => true, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'context' => $context);
        $data = file_prepare_standard_editor($data, 'response', $editoroptions, $context, 'mod_lesson', 'essay_responses', $attempt->id);
        $mform->set_data($data);
        $mform->display();
        break;
    default:
        groups_print_activity_menu($cm, $url);
        break;
}
echo $OUTPUT->footer();
コード例 #11
0
ファイル: exassessment.php プロジェクト: verbazend/AWFA
    $assessmenteditable = false;
}

// load the grading strategy logic
$strategy = $workshop->grading_strategy_instance();

// load the assessment form and process the submitted data eventually
$mform = $strategy->get_assessment_form($PAGE->url, 'assessment', $assessment, $assessmenteditable);

// Set data managed by the workshop core, subplugins set their own data themselves.
$currentdata = (object)array(
    'feedbackauthor' => $assessment->feedbackauthor,
    'feedbackauthorformat' => $assessment->feedbackauthorformat,
);
if ($assessmenteditable and $workshop->overallfeedbackmode) {
    $currentdata = file_prepare_standard_editor($currentdata, 'feedbackauthor', $workshop->overall_feedback_content_options(),
        $workshop->context, 'mod_workshop', 'overallfeedback_content', $assessment->id);
    if ($workshop->overallfeedbackfiles) {
        $currentdata = file_prepare_standard_filemanager($currentdata, 'feedbackauthorattachment',
            $workshop->overall_feedback_attachment_options(), $workshop->context, 'mod_workshop', 'overallfeedback_attachment',
            $assessment->id);
    }
}
$mform->set_data($currentdata);

if ($mform->is_cancelled()) {
    redirect($workshop->view_url());
} elseif ($assessmenteditable and ($data = $mform->get_data())) {
    if ($canmanage) {
        if (is_null($assessment->grade)) {
            $workshop->log('add reference assessment', $workshop->exassess_url($assessment->id), $assessment->submissionid);
        } else {
コード例 #12
0
ファイル: edit.php プロジェクト: pzhu2004/moodle
    }
}
if (!$courseid) {
    require_once $CFG->libdir . '/adminlib.php';
    admin_externalpage_setup('scales');
}
// default return url
$gpr = new grade_plugin_return();
$returnurl = $gpr->get_return_url('index.php?id=' . $courseid);
$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'noclean' => true, 'context' => $systemcontext);
if (!empty($scale_rec->id)) {
    $editoroptions['subdirs'] = file_area_contains_subdirs($systemcontext, 'grade', 'scale', $scale_rec->id);
    $scale_rec = file_prepare_standard_editor($scale_rec, 'description', $editoroptions, $systemcontext, 'grade', 'scale', $scale_rec->id);
} else {
    $editoroptions['subdirs'] = false;
    $scale_rec = file_prepare_standard_editor($scale_rec, 'description', $editoroptions, $systemcontext, 'grade', 'scale', null);
}
$mform = new edit_scale_form(null, compact('gpr', 'editoroptions'));
$mform->set_data($scale_rec);
if ($mform->is_cancelled()) {
    redirect($returnurl);
} else {
    if ($data = $mform->get_data()) {
        $scale = new grade_scale(array('id' => $id));
        $data->userid = $USER->id;
        if (empty($scale->id)) {
            $data->description = $data->description_editor['text'];
            $data->descriptionformat = $data->description_editor['format'];
            grade_scale::set_properties($scale, $data);
            if (!has_capability('moodle/grade:manage', $systemcontext)) {
                $data->standard = 0;
コード例 #13
0
ファイル: edit.php プロジェクト: ncsu-delta/moodle
} else {
    require_login();
    print_error('needcoursecategroyid');
}

// Prepare course and the editor
$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes'=>$CFG->maxbytes, 'trusttext'=>false, 'noclean'=>true);
if (!empty($course)) {
    //add context for editor
    $editoroptions['context'] = $coursecontext;
    $course = file_prepare_standard_editor($course, 'summary', $editoroptions, $coursecontext, 'course', 'summary', 0);

} else {
    //editor should respect category context if course context is not set.
    $editoroptions['context'] = $catcontext;
    $course = file_prepare_standard_editor($course, 'summary', $editoroptions, null, 'course', 'summary', null);
}

// first create the form
$editform = new course_edit_form(NULL, array('course'=>$course, 'category'=>$category, 'editoroptions'=>$editoroptions, 'returnto'=>$returnto));
if ($editform->is_cancelled()) {
        switch ($returnto) {
            case 'category':
                $url = new moodle_url($CFG->wwwroot.'/course/category.php', array('id'=>$categoryid));
                break;
            case 'topcat':
                $url = new moodle_url($CFG->wwwroot.'/course/');
                break;
            default:
                if (!empty($course->id)) {
                    $url = new moodle_url($CFG->wwwroot.'/course/view.php', array('id'=>$course->id));
コード例 #14
0
ファイル: email.php プロジェクト: sryder/clampmail
    $email = new stdClass();
    $email->id = null;
    $email->subject = optional_param('subject', '', PARAM_TEXT);
    $email->message = optional_param('message_editor[text]', '', PARAM_RAW);
    $email->mailto = optional_param('mailto', '', PARAM_TEXT);
    $email->format = $USER->mailformat;
}
$email->messageformat = $email->format;
$email->messagetext = $email->message;
$default_sigid = $DB->get_field('block_clampmail_signatures', 'id', array('userid' => $USER->id, 'default_flag' => 1));
$email->sigid = $default_sigid ? $default_sigid : -1;
// Some setters for the form.
$email->type = $type;
$email->typeid = $typeid;
$editor_options = array('trusttext' => true, 'subdirs' => true, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'context' => $context);
$email = file_prepare_standard_editor($email, 'message', $editor_options, $context, 'block_clampmail', $type, $email->id);
$selected = array();
if (!empty($email->mailto)) {
    foreach (explode(',', $email->mailto) as $id) {
        $selected[$id] = $users[$id];
        unset($users[$id]);
    }
}
$form = new email_form(null, array('editor_options' => $editor_options, 'selected' => $selected, 'users' => $users, 'roles' => $roles, 'groups' => $groups, 'users_to_roles' => $users_to_roles, 'users_to_groups' => $users_to_groups, 'sigs' => array_map(function ($sig) {
    return $sig->title;
}, $sigs), 'alternates' => $alternates));
$warnings = array();
if ($form->is_cancelled()) {
    redirect(new moodle_url('/course/view.php?id=' . $courseid));
} else {
    if ($data = $form->get_data()) {
コード例 #15
0
ファイル: group.php プロジェクト: saurabh947/MoodleLearning
}
if ($id !== 0) {
    $PAGE->set_url('/group/group.php', array('id' => $id));
} else {
    $PAGE->set_url('/group/group.php', array('courseid' => $courseid));
}
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('moodle/course:managegroups', $context);
$returnurl = $CFG->wwwroot . '/group/index.php?id=' . $course->id . '&group=' . $id;
// Prepare the description editor: We do support files for group descriptions
$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $course->maxbytes, 'trust' => false, 'context' => $context, 'noclean' => true);
if (!empty($group->id)) {
    $group = file_prepare_standard_editor($group, 'description', $editoroptions, $context, 'group', 'description', $group->id);
} else {
    $group = file_prepare_standard_editor($group, 'description', $editoroptions, $context, 'group', 'description', null);
}
/// First create the form
$editform = new group_form(null, array('editoroptions' => $editoroptions));
$editform->set_data($group);
if ($editform->is_cancelled()) {
    redirect($returnurl);
} elseif ($data = $editform->get_data()) {
    if (!has_capability('moodle/course:changeidnumber', $context)) {
        // Remove the idnumber if the user doesn't have permission to modify it
        unset($data->idnumber);
    }
    if ($data->id) {
        groups_update_group($data, $editform, $editoroptions);
    } else {
        $id = groups_create_group($data, $editform, $editoroptions);
コード例 #16
0
ファイル: user.php プロジェクト: narasimhaeabyas/tataaiapro
        $tool->costcenterid = $tool->costcenterid;
        $tool->costcenter_name = $DB->get_field('local_costcenter', 'fullname', array('id' => $tool->costcenterid));
    } else {
        //$tool->role_name = 'Manager';
        $tool->costcenter_name = 'All';
    }
    $usercontext = context_user::instance($tool->id);
    $editoroptions = array(
        'maxfiles' => EDITOR_UNLIMITED_FILES,
        'maxbytes' => $CFG->maxbytes,
        'trusttext' => false,
        'forcehttps' => false,
        'context' => $usercontext
    );

    $tool = file_prepare_standard_editor($tool, 'description', $editoroptions, $usercontext, 'user', 'profile', 0);
} else {
	 require_capability('moodle/user:update', $systemcontext);
    $tool = new stdClass();
    $tool->id = $id;
    $usercontext = null;
    // This is a new user, we don't want to add files here
    $editoroptions = array(
        'maxfiles' => 0,
        'maxbytes' => 0,
        'trusttext' => false,
        'forcehttps' => false,
        'context' => context_system::instance()
    );
}
// Prepare filemanager draft area.
コード例 #17
0
ファイル: lib.php プロジェクト: JP-Git/moodle
 /**
  * Converts the current definition into an object suitable for the editor form's set_data()
  *
  * @param boolean $addemptycriterion whether to add an empty criterion if the rubric is completely empty (just being created)
  * @return stdClass
  */
 public function get_definition_for_editing($addemptycriterion = false)
 {
     $definition = $this->get_definition();
     $properties = new stdClass();
     $properties->areaid = $this->areaid;
     if ($definition) {
         foreach (array('id', 'name', 'description', 'descriptionformat', 'status') as $key) {
             $properties->{$key} = $definition->{$key};
         }
         $options = self::description_form_field_options($this->get_context());
         $properties = file_prepare_standard_editor($properties, 'description', $options, $this->get_context(), 'grading', 'description', $definition->id);
     }
     $properties->rubric = array('criteria' => array(), 'options' => $this->get_options());
     if (!empty($definition->rubric_criteria)) {
         $properties->rubric['criteria'] = $definition->rubric_criteria;
     } else {
         if (!$definition && $addemptycriterion) {
             $properties->rubric['criteria'] = array('addcriterion' => 1);
         }
     }
     return $properties;
 }
コード例 #18
0
ファイル: edit.php プロジェクト: saurabh947/MoodleLearning
    echo $OUTPUT->header();
    echo $OUTPUT->heading($strheading);
    $yesurl = new moodle_url('/cohort/edit.php', array('id' => $cohort->id, 'delete' => 1, 'confirm' => 1, 'sesskey' => sesskey()));
    $message = get_string('delconfirm', 'cohort', format_string($cohort->name));
    echo $OUTPUT->confirm($message, $yesurl, $returnurl);
    echo $OUTPUT->footer();
    die;
}
$editoroptions = array('maxfiles' => 0, 'context' => $context);
if ($cohort->id) {
    // edit existing
    $cohort = file_prepare_standard_editor($cohort, 'description', $editoroptions, $context);
    $strheading = get_string('editcohort', 'cohort');
} else {
    // add new
    $cohort = file_prepare_standard_editor($cohort, 'description', $editoroptions, $context);
    $strheading = get_string('addcohort', 'cohort');
}
$PAGE->set_title($strheading);
$PAGE->set_heading($COURSE->fullname);
$PAGE->navbar->add($strheading);
$editform = new cohort_edit_form(null, array('editoroptions' => $editoroptions, 'data' => $cohort));
if ($editform->is_cancelled()) {
    redirect($returnurl);
} else {
    if ($data = $editform->get_data()) {
        $data = file_postupdate_standard_editor($data, 'description', $editoroptions, $context);
        if ($data->id) {
            cohort_update_cohort($data);
        } else {
            cohort_add_cohort($data);
コード例 #19
0
ファイル: lib.php プロジェクト: numbas/moodle
 /**
  * Static function to prepare the summary editor for working with a course
  * request.
  *
  * @static
  * @param null|stdClass $data Optional, an object containing the default values
  *                       for the form, these may be modified when preparing the
  *                       editor so this should be called before creating the form
  * @return stdClass An object that can be used to set the default values for
  *                   an mforms form
  */
 public static function prepare($data = null)
 {
     if ($data === null) {
         $data = new stdClass();
     }
     $data = file_prepare_standard_editor($data, 'summary', self::summary_editor_options());
     return $data;
 }
コード例 #20
0
ファイル: locallib.php プロジェクト: nuckey/moodle
    /**
     * Returns the mform the teachers use to put a feedback for the author on their submission
     *
     * @param moodle_url $actionurl
     * @param stdClass $submission
     * @param array $options editable
     * @return workshop_feedbackauthor_form
     */
    public function get_feedbackauthor_form(moodle_url $actionurl, stdclass $submission, $options=array()) {
        global $CFG;
        require_once(dirname(__FILE__) . '/feedbackauthor_form.php');

        $current = new stdclass();
        $current->submissionid          = $submission->id;
        $current->published             = $submission->published;
        $current->grade                 = $this->real_grade($submission->grade);
        $current->gradeover             = $this->real_grade($submission->gradeover);
        $current->feedbackauthor        = $submission->feedbackauthor;
        $current->feedbackauthorformat  = $submission->feedbackauthorformat;
        if (is_null($current->grade)) {
            $current->grade = get_string('nullgrade', 'workshop');
        }
        if (!isset($options['editable'])) {
            $editable = true;   // by default
        } else {
            $editable = (bool)$options['editable'];
        }

        // prepare wysiwyg editor
        $current = file_prepare_standard_editor($current, 'feedbackauthor', array());

        return new workshop_feedbackauthor_form($actionurl,
                array('workshop' => $this, 'current' => $current, 'editoropts' => array(), 'options' => $options),
                'post', '', null, $editable);
    }
コード例 #21
0
ファイル: lib.php プロジェクト: narasimhaeabyas/tataaiapro
/**
 * Print the details of a session
 *
 * @param object $session         Record from facetoface_sessions
 * @param boolean $showcapacity   Show the capacity (true) or only the seats available (false)
 * @param boolean $calendaroutput Whether the output should be formatted for a calendar event
 * @param boolean $return         Whether to return (true) the html or print it directly (true)
 * @param boolean $hidesignup     Hide any messages relating to signing up
 */
function facetoface_print_session($session, $showcapacity, $calendaroutput=false, $return=false, $hidesignup=false) {
    global $CFG, $DB;

    $table = new html_table();
    $table->summary = get_string('sessionsdetailstablesummary', 'facetoface');
    $table->attributes['class'] = 'generaltable f2fsession';
    $table->align = array('right', 'left');
    if ($calendaroutput) {
        $table->tablealign = 'left';
    }

    $customfields = facetoface_get_session_customfields();
    $customdata = $DB->get_records('facetoface_session_data', array('sessionid' => $session->id), '', 'fieldid, data');
    foreach ($customfields as $field) {
        $data = '';
        if (!empty($customdata[$field->id])) {
            if (CUSTOMFIELD_TYPE_MULTISELECT == $field->type) {
                $values = explode(CUSTOMFIELD_DELIMITER, format_string($customdata[$field->id]->data));
                $data = implode(html_writer::empty_tag('br'), $values);
            }
            else {
                $data = format_string($customdata[$field->id]->data);
            }
        }
        $table->data[] = array(str_replace(' ', '&nbsp;', format_string($field->name)), $data);
    }

    $strdatetime = str_replace(' ', '&nbsp;', get_string('sessiondatetime', 'facetoface'));
    if ($session->datetimeknown) {
        $html = '';
        foreach ($session->sessiondates as $date) {
            if (!empty($html)) {
                $html .= html_writer::empty_tag('br');
            }
            $sessionobj = facetoface_format_session_times($date->timestart, $date->timefinish, $date->sessiontimezone);
            if ($sessionobj->startdate == $sessionobj->enddate) {
                $html .= $sessionobj->startdate . ', ';
            } else {
                $html .= $sessionobj->startdate . ' - ' . $sessionobj->enddate . ', ';
            }
            $html .= $sessionobj->starttime . ' - ' . $sessionobj->endtime . ' ' . $sessionobj->timezone;
        }
        $table->data[] = array($strdatetime, $html);
    } else {
        $table->data[] = array($strdatetime, html_writer::tag('i', get_string('wait-listed', 'facetoface')));
    }

    $signupcount = facetoface_get_num_attendees($session->id);
    $placesleft = $session->capacity - $signupcount;

    if ($showcapacity) {
        if ($session->allowoverbook) {
            $table->data[] = array(get_string('capacity', 'facetoface'), get_string('capacityallowoverbook', 'facetoface', $session->capacity));
        } else {
            $table->data[] = array(get_string('capacity', 'facetoface'), $session->capacity);
        }
    }
    elseif (!$calendaroutput) {
        $table->data[] = array(get_string('seatsavailable', 'facetoface'), max(0, $placesleft));
    }

    // Display requires approval notification
    $facetoface = $DB->get_record('facetoface', array('id' => $session->facetoface));

    if ($facetoface->approvalreqd) {
        $table->data[] = array('', get_string('sessionrequiresmanagerapproval', 'facetoface'));
    }

    // Display waitlist notification
    if (!$hidesignup && $session->allowoverbook && $placesleft < 1) {
        $table->data[] = array('', get_string('userwillbewaitlisted', 'facetoface'));
    }

    if (!empty($session->duration)) {
        $table->data[] = array(get_string('duration', 'facetoface'), format_duration($session->duration));
    }

    // Display room information
    $session->room = $DB->get_record('facetoface_room', array('id' => $session->roomid));
    if (!empty($session->room)) {
        $roomstring = '';
        $roomstring = isset($session->room->name) ? format_string($session->room->name) . ', '. html_writer::empty_tag('br') : '';
        $roomstring .= isset($session->room->building) ? format_string($session->room->building) . ', ' . html_writer::empty_tag('br') : '';
        $roomstring .= isset($session->room->address) ? format_string($session->room->address) . html_writer::empty_tag('br') : '';

        $systemcontext = context_system::instance();
        $editoroptions = array(
            'noclean'  => false,
            'maxfiles' => EDITOR_UNLIMITED_FILES,
            'context'  => $systemcontext,
        );

        $session->room->descriptionformat = FORMAT_HTML;
        $session->room = file_prepare_standard_editor($session->room, 'description', $editoroptions, $systemcontext, 'facetoface', 'room', $session->room->id);

        $roomstring .= $session->room->description_editor['text'];

        $table->data[] = array(get_string('room', 'facetoface'), $roomstring);
    }

    if (!empty($session->normalcost)) {
        $table->data[] = array(get_string('normalcost', 'facetoface'), format_string($session->normalcost));
    }
    if (!empty($session->discountcost)) {
        $table->data[] = array(get_string('discountcost', 'facetoface'), format_string($session->discountcost));
    }

    // Display trainers.
    $courseid = $DB->get_field('facetoface', 'course', array('id' => $session->facetoface));
    $coursecontext = context_course::instance($courseid);

    if (!empty($session->details)) {
        if ($cm = get_coursemodule_from_instance('facetoface', $facetoface->id, $courseid)) {
            $context = context_module::instance($cm->id);
            $session->details = file_rewrite_pluginfile_urls($session->details, 'pluginfile.php', $context->id, 'mod_facetoface', 'session', $session->id);
        }
        $details = format_text($session->details, FORMAT_HTML);
        $table->data[] = array(get_string('details', 'facetoface'), $details);
    }

    $trainerroles = facetoface_get_trainer_roles($coursecontext);

    if ($trainerroles) {
        // Get trainers.
        $trainers = facetoface_get_trainers($session->id);

        foreach ($trainerroles as $role => $rolename) {
            $rolename = $rolename->localname;

            if (empty($trainers[$role])) {
                continue;
            }

            $trainer_names = array();
            foreach ($trainers[$role] as $trainer) {
                $trainer_url = new moodle_url('/user/view.php', array('id' => $trainer->id));
                $trainer_names[] = html_writer::link($trainer_url, fullname($trainer));
            }

            $table->data[] = array($rolename, implode(', ', $trainer_names));
        }
    }

    return html_writer::table($table, $return);
}
コード例 #22
0
ファイル: edit.php プロジェクト: tyleung/CMPUT401MoodleExams
            switch ($context->contextlevel) {
                case CONTEXT_COURSE:
                    $entry->courseassoc = $assocrec->contextid;
                    break;
                case CONTEXT_MODULE:
                    $entry->modassoc = $assocrec->contextid;
                    break;
            }
        }
    }
}
require_once 'edit_form.php';
$summaryoptions = array('maxfiles' => 99, 'maxbytes' => $CFG->maxbytes, 'trusttext' => true, 'context' => $sitecontext, 'subdirs' => file_area_contains_subdirs($sitecontext, 'blog', 'post', $entry->id));
$attachmentoptions = array('subdirs' => false, 'maxfiles' => 99, 'maxbytes' => $CFG->maxbytes);
$blogeditform = new blog_edit_form(null, compact('entry', 'summaryoptions', 'attachmentoptions', 'sitecontext', 'courseid', 'modid'));
$entry = file_prepare_standard_editor($entry, 'summary', $summaryoptions, $sitecontext, 'blog', 'post', $entry->id);
$entry = file_prepare_standard_filemanager($entry, 'attachment', $attachmentoptions, $sitecontext, 'blog', 'attachment', $entry->id);
if (!empty($CFG->usetags) && !empty($entry->id)) {
    include_once $CFG->dirroot . '/tag/lib.php';
    $entry->tags = tag_get_tags_array('post', $entry->id);
}
$entry->action = $action;
// set defaults
$blogeditform->set_data($entry);
if ($blogeditform->is_cancelled()) {
    redirect($returnurl);
} else {
    if ($data = $blogeditform->get_data()) {
        switch ($action) {
            case 'add':
                $blogentry = new blog_entry(null, $data, $blogeditform);
コード例 #23
0
ファイル: lib.php プロジェクト: nuckey/moodle
    public function set_data($data) {
        $editoroptions = $this->get_editor_options();
        if (!isset($data->text)) {
            $data->text = '';
        }
        if (!isset($data->format)) {
            $data->textformat = FORMAT_HTML;
        } else {
            $data->textformat = $data->format;
        }

        if (!empty($this->_customdata->submission->id)) {
            $itemid = $this->_customdata->submission->id;
        } else {
            $itemid = null;
        }

        switch ($this->_customdata->assignment->assignmenttype) {
                case 'upload' :
                case 'uploadsingle' :
                    $data = file_prepare_standard_filemanager($data, 'files', $editoroptions, $this->_customdata->context, 'mod_assignment', 'response', $itemid);
                    break;
                default :
                    break;
        }

        $data = file_prepare_standard_editor($data, 'submissioncomment', $editoroptions, $this->_customdata->context, $editoroptions['component'], $editoroptions['filearea'], $itemid);
        return parent::set_data($data);
    }
コード例 #24
0
ファイル: edit.php プロジェクト: abhilash1994/moodle
        $entry->categories = array_values($categoriesarr);
    }
} else {
    // new entry
    require_capability('mod/glossary:write', $context);
    // note: guest user does not have any write capability
    $entry = new stdClass();
    $entry->id = null;
}
$maxfiles = 99;
// TODO: add some setting
$maxbytes = $course->maxbytes;
// TODO: add some setting
$definitionoptions = array('trusttext' => true, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes, 'context' => $context, 'subdirs' => file_area_contains_subdirs($context, 'mod_glossary', 'entry', $entry->id));
$attachmentoptions = array('subdirs' => false, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes);
$entry = file_prepare_standard_editor($entry, 'definition', $definitionoptions, $context, 'mod_glossary', 'entry', $entry->id);
$entry = file_prepare_standard_filemanager($entry, 'attachment', $attachmentoptions, $context, 'mod_glossary', 'attachment', $entry->id);
$entry->cmid = $cm->id;
// create form and set initial data
$mform = new mod_glossary_entry_form(null, array('current' => $entry, 'cm' => $cm, 'glossary' => $glossary, 'definitionoptions' => $definitionoptions, 'attachmentoptions' => $attachmentoptions));
if ($mform->is_cancelled()) {
    if ($id) {
        redirect("view.php?id={$cm->id}&mode=entry&hook={$id}");
    } else {
        redirect("view.php?id={$cm->id}");
    }
} else {
    if ($entry = $mform->get_data()) {
        $timenow = time();
        $categories = empty($entry->categories) ? array() : $entry->categories;
        unset($entry->categories);
コード例 #25
0
ファイル: pagelib.php プロジェクト: Burick/moodle
    protected function print_edit($content = null) {
        global $CFG, $OUTPUT, $USER, $PAGE;

        if (!$this->check_locks()) {
            return;
        }

        //delete old locks (> 1 hour)
        wiki_delete_old_locks();

        $version = wiki_get_current_version($this->page->id);
        $format = $version->contentformat;

        if ($content == null) {
            if (empty($this->section)) {
                $content = $version->content;
            } else {
                $content = $this->sectioncontent;
            }
        }

        $versionnumber = $version->version;
        if ($this->versionnumber >= 0) {
            if ($version->version != $this->versionnumber) {
                print $OUTPUT->box(get_string('wrongversionlock', 'wiki'), 'errorbox');
                $versionnumber = $this->versionnumber;
            }
        }

        $url = $CFG->wwwroot . '/mod/wiki/edit.php?pageid=' . $this->page->id;
        if (!empty($this->section)) {
            $url .= "&section=" . urlencode($this->section);
        }

        $params = array(
            'attachmentoptions' => page_wiki_edit::$attachmentoptions,
            'format' => $version->contentformat,
            'version' => $versionnumber,
            'pagetitle' => $this->page->title,
            'contextid' => $this->modcontext->id
        );

        $data = new StdClass();
        $data->newcontent = $content;
        $data->version = $versionnumber;
        $data->format = $format;

        switch ($format) {
        case 'html':
            $data->newcontentformat = FORMAT_HTML;
            // Append editor context to editor options, giving preference to existing context.
            page_wiki_edit::$attachmentoptions = array_merge(array('context' => $this->modcontext), page_wiki_edit::$attachmentoptions);
            $data = file_prepare_standard_editor($data, 'newcontent', page_wiki_edit::$attachmentoptions, $this->modcontext, 'mod_wiki', 'attachments', $this->subwiki->id);
            break;
        default:
            break;
        }

        if ($version->contentformat != 'html') {
            $params['fileitemid'] = $this->subwiki->id;
            $params['component']  = 'mod_wiki';
            $params['filearea']   = 'attachments';
        }

        if (!empty($CFG->usetags)) {
            $params['tags'] = tag_get_tags_csv('wiki_pages', $this->page->id, TAG_RETURN_TEXT);
        }

        $form = new mod_wiki_edit_form($url, $params);

        if ($formdata = $form->get_data()) {
            if (!empty($CFG->usetags)) {
                $data->tags = $formdata->tags;
            }
        } else {
            if (!empty($CFG->usetags)) {
                $data->tags = tag_get_tags_array('wiki', $this->page->id);
            }
        }

        $form->set_data($data);
        $form->display();
    }
コード例 #26
0
ファイル: assignment.class.php プロジェクト: vuchannguyen/web
 function view()
 {
     global $OUTPUT, $CFG, $USER, $PAGE;
     $edit = optional_param('edit', 0, PARAM_BOOL);
     $saved = optional_param('saved', 0, PARAM_BOOL);
     $context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
     require_capability('mod/assignment:view', $context);
     $submission = $this->get_submission($USER->id, false);
     //Guest can not submit nor edit an assignment (bug: 4604)
     if (!is_enrolled($this->context, $USER, 'mod/assignment:submit')) {
         $editable = false;
     } else {
         $editable = $this->isopen() && (!$submission || $this->assignment->resubmit || !$submission->timemarked);
     }
     $editmode = ($editable and $edit);
     if ($editmode) {
         // prepare form and process submitted data
         $editoroptions = array('noclean' => false, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $this->course->maxbytes);
         $data = new stdClass();
         $data->id = $this->cm->id;
         $data->edit = 1;
         if ($submission) {
             $data->sid = $submission->id;
             $data->text = $submission->data1;
             $data->textformat = $submission->data2;
         } else {
             $data->sid = NULL;
             $data->text = '';
             $data->textformat = NULL;
         }
         $data = file_prepare_standard_editor($data, 'text', $editoroptions, $this->context, 'mod_assignment', $this->filearea, $data->sid);
         $mform = new mod_assignment_online_edit_form(null, array($data, $editoroptions));
         if ($mform->is_cancelled()) {
             redirect($PAGE->url);
         }
         if ($data = $mform->get_data()) {
             $submission = $this->get_submission($USER->id, true);
             //create the submission if needed & its id
             $data = file_postupdate_standard_editor($data, 'text', $editoroptions, $this->context, 'mod_assignment', $this->filearea, $submission->id);
             $submission = $this->update_submission($data);
             //TODO fix log actions - needs db upgrade
             add_to_log($this->course->id, 'assignment', 'upload', 'view.php?a=' . $this->assignment->id, $this->assignment->id, $this->cm->id);
             $this->email_teachers($submission);
             //redirect to get updated submission date and word count
             redirect(new moodle_url($PAGE->url, array('saved' => 1)));
         }
     }
     add_to_log($this->course->id, "assignment", "view", "view.php?id={$this->cm->id}", $this->assignment->id, $this->cm->id);
     /// print header, etc. and display form if needed
     if ($editmode) {
         $this->view_header(get_string('editmysubmission', 'assignment'));
     } else {
         $this->view_header();
     }
     $this->view_intro();
     $this->view_dates();
     if ($saved) {
         echo $OUTPUT->notification(get_string('submissionsaved', 'assignment'), 'notifysuccess');
     }
     if (is_enrolled($this->context, $USER)) {
         if ($editmode) {
             echo $OUTPUT->box_start('generalbox', 'onlineenter');
             $mform->display();
         } else {
             echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter', 'online');
             if ($submission && has_capability('mod/assignment:exportownsubmission', $this->context)) {
                 $text = file_rewrite_pluginfile_urls($submission->data1, 'pluginfile.php', $this->context->id, 'mod_assignment', $this->filearea, $submission->id);
                 echo format_text($text, $submission->data2, array('overflowdiv' => true));
                 if ($CFG->enableportfolios) {
                     require_once $CFG->libdir . '/portfoliolib.php';
                     $button = new portfolio_add_button();
                     $button->set_callback_options('assignment_portfolio_caller', array('id' => $this->cm->id), '/mod/assignment/locallib.php');
                     $fs = get_file_storage();
                     if ($files = $fs->get_area_files($this->context->id, 'mod_assignment', $this->filearea, $submission->id, "timemodified", false)) {
                         $button->set_formats(PORTFOLIO_FORMAT_RICHHTML);
                     } else {
                         $button->set_formats(PORTFOLIO_FORMAT_PLAINHTML);
                     }
                     $button->render();
                 }
             } else {
                 if ($this->isopen()) {
                     //fix for #4206
                     echo '<div style="text-align:center">' . get_string('emptysubmission', 'assignment') . '</div>';
                 }
             }
         }
         echo $OUTPUT->box_end();
         if (!$editmode && $editable) {
             if (!empty($submission)) {
                 $submitbutton = "editmysubmission";
             } else {
                 $submitbutton = "addsubmission";
             }
             echo "<div style='text-align:center'>";
             echo $OUTPUT->single_button(new moodle_url('view.php', array('id' => $this->cm->id, 'edit' => '1')), get_string($submitbutton, 'assignment'));
             echo "</div>";
         }
     }
     $this->view_feedback();
     $this->view_footer();
 }
コード例 #27
0
ファイル: lib.php プロジェクト: nuckey/moodle
    /**
     * Factory method returning an instance of an assessment form editor class
     *
     * @param $actionurl URL of form handler, defaults to auto detect the current url
     */
    public function get_edit_strategy_form($actionurl=null) {
        global $CFG;    // needed because the included files use it
        global $PAGE;

        require_once(dirname(__FILE__) . '/edit_form.php');

        $fields             = $this->prepare_form_fields($this->dimensions, $this->mappings);
        $nodimensions       = count($this->dimensions);
        $norepeatsdefault   = max($nodimensions + self::ADDDIMS, self::MINDIMS);
        $norepeats          = optional_param('norepeats', $norepeatsdefault, PARAM_INT);    // number of dimensions
        $noadddims          = optional_param('noadddims', '', PARAM_ALPHA);                 // shall we add more?
        if ($noadddims) {
            $norepeats += self::ADDDIMS;
        }

        // prepare the embeded files
        for ($i = 0; $i < $nodimensions; $i++) {
            // prepare all editor elements
            $fields = file_prepare_standard_editor($fields, 'description__idx_'.$i, $this->descriptionopts,
                $PAGE->context, 'workshopform_numerrors', 'description', $fields->{'dimensionid__idx_'.$i});
        }

        $customdata = array();
        $customdata['workshop'] = $this->workshop;
        $customdata['strategy'] = $this;
        $customdata['norepeats'] = $norepeats;
        $customdata['nodimensions'] = $nodimensions;
        $customdata['descriptionopts'] = $this->descriptionopts;
        $customdata['current']  = $fields;
        $attributes = array('class' => 'editstrategyform');

        return new workshop_edit_numerrors_strategy_form($actionurl, $customdata, 'post', '', $attributes);
    }
コード例 #28
0
ファイル: lib.php プロジェクト: evltuma/moodle
 /**
  * Factory method returning an instance of an assessment form editor class
  *
  * @param $actionurl URL of form handler, defaults to auto detect the current url
  */
 public function get_edit_strategy_form($actionurl = null)
 {
     global $CFG;
     // needed because the included files use it
     require_once __DIR__ . '/edit_form.php';
     $fields = $this->prepare_form_fields($this->dimensions);
     $fields->config_layout = $this->config->layout;
     $nodimensions = count($this->dimensions);
     $norepeatsdefault = max($nodimensions + self::ADDDIMS, self::MINDIMS);
     $norepeats = optional_param('norepeats', $norepeatsdefault, PARAM_INT);
     // number of dimensions
     $adddims = optional_param('adddims', '', PARAM_ALPHA);
     // shall we add more dimensions?
     if ($adddims) {
         $norepeats += self::ADDDIMS;
     }
     // Append editor context to editor options, giving preference to existing context.
     $this->descriptionopts = array_merge(array('context' => $this->workshop->context), $this->descriptionopts);
     // prepare the embeded files
     for ($i = 0; $i < $nodimensions; $i++) {
         // prepare all editor elements
         $fields = file_prepare_standard_editor($fields, 'description__idx_' . $i, $this->descriptionopts, $this->workshop->context, 'workshopform_rubric', 'description', $fields->{'dimensionid__idx_' . $i});
     }
     $customdata = array();
     $customdata['workshop'] = $this->workshop;
     $customdata['strategy'] = $this;
     $customdata['norepeats'] = $norepeats;
     $customdata['descriptionopts'] = $this->descriptionopts;
     $customdata['current'] = $fields;
     $attributes = array('class' => 'editstrategyform');
     return new workshop_edit_rubric_strategy_form($actionurl, $customdata, 'post', '', $attributes);
 }
コード例 #29
0
ファイル: submission.php プロジェクト: alanaipe2015/moodle
    // ok you can go
} else {
    print_error('nopermissions', 'error', $workshop->view_url(), 'view or create submission');
}
if ($assess and $submission->id and !$isreviewer and $canallocate and $workshop->assessing_allowed($USER->id)) {
    require_sesskey();
    $assessmentid = $workshop->add_allocation($submission, $USER->id);
    redirect($workshop->assess_url($assessmentid));
}
if ($edit) {
    require_once dirname(__FILE__) . '/submission_form.php';
    $maxfiles = $workshop->nattachments;
    $maxbytes = $workshop->maxbytes;
    $contentopts = array('trusttext' => true, 'subdirs' => false, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes, 'context' => $workshop->context, 'return_types' => FILE_INTERNAL | FILE_EXTERNAL);
    $attachmentopts = array('subdirs' => true, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes, 'return_types' => FILE_INTERNAL);
    $submission = file_prepare_standard_editor($submission, 'content', $contentopts, $workshop->context, 'mod_workshop', 'submission_content', $submission->id);
    $submission = file_prepare_standard_filemanager($submission, 'attachment', $attachmentopts, $workshop->context, 'mod_workshop', 'submission_attachment', $submission->id);
    $mform = new workshop_submission_form($PAGE->url, array('current' => $submission, 'workshop' => $workshop, 'contentopts' => $contentopts, 'attachmentopts' => $attachmentopts));
    if ($mform->is_cancelled()) {
        redirect($workshop->view_url());
    } elseif ($cansubmit and $formdata = $mform->get_data()) {
        if ($formdata->example == 0) {
            // this was used just for validation, it must be set to zero when dealing with normal submissions
            unset($formdata->example);
        } else {
            throw new coding_exception('Invalid submission form data value: example');
        }
        $timenow = time();
        if (is_null($submission->id)) {
            $formdata->workshopid = $workshop->id;
            $formdata->example = 0;
コード例 #30
0
ファイル: editpage.php プロジェクト: evltuma/moodle
    $mform->set_data($data);
    $PAGE->navbar->add(get_string('edit'), new moodle_url('/mod/lesson/edit.php', array('id' => $id)));
    $PAGE->navbar->add(get_string('editingquestionpage', 'lesson', get_string($mform->qtypestring, 'lesson')));
} else {
    // Give the page type being created a chance to override the creation process
    // this is used by endofbranch, cluster, and endofcluster to skip the creation form.
    // IT SHOULD ALWAYS CALL require_sesskey();
    $mform->construction_override($pageid, $lesson);
    $data = new stdClass();
    $data->id = $cm->id;
    $data->pageid = $pageid;
    if ($qtype) {
        //TODO: the handling of form for the selection of question type is a bloody hack! (skodak)
        $data->qtype = $qtype;
    }
    $data = file_prepare_standard_editor($data, 'contents', $editoroptions, null);
    $mform->set_data($data);
    $PAGE->navbar->add(get_string('addanewpage', 'lesson'), $PAGE->url);
    if ($qtype !== 'unknown') {
        $PAGE->navbar->add(get_string($mform->qtypestring, 'lesson'));
    }
}
if ($data = $mform->get_data()) {
    require_sesskey();
    if ($edit) {
        $data->lessonid = $data->id;
        $data->id = $data->pageid;
        unset($data->pageid);
        unset($data->edit);
        $editpage->update($data, $context, $PAGE->course->maxbytes);
    } else {