コード例 #1
0
ファイル: lib.php プロジェクト: rezaies/moodle-mod_customcert
 /**
  * This function renders the form elements when adding a customcert element.
  *
  * @param mod_customcert_edit_element_form $mform the edit_form instance
  */
 public function render_form_elements($mform)
 {
     $mform->addElement('textarea', 'text', get_string('text', 'customcertelement_text'));
     $mform->setType('text', PARAM_RAW);
     $mform->addHelpButton('text', 'text', 'customcertelement_text');
     parent::render_form_elements($mform);
 }
コード例 #2
0
ファイル: lib.php プロジェクト: rezaies/moodle-mod_customcert
 /**
  * This function renders the form elements when adding a customcert element.
  *
  * @param mod_customcert_edit_element_form $mform the edit_form instance
  */
 public function render_form_elements($mform)
 {
     // We want to define the width of the border.
     $mform->addElement('text', 'width', get_string('width', 'customcertelement_border'), array('size' => 10));
     $mform->setType('width', PARAM_INT);
     $mform->addHelpButton('width', 'width', 'customcertelement_border');
     // The only other thing to define is the colour we want the border to be.
     parent::render_form_element_colour($mform);
 }
コード例 #3
0
ファイル: lib.php プロジェクト: rezaies/moodle-mod_customcert
 /**
  * This function renders the form elements when adding a customcert element.
  *
  * @param mod_customcert_edit_element_form $mform the edit_form instance
  */
 public function render_form_elements($mform)
 {
     // Get the user profile fields.
     $userfields = array('firstname' => get_user_field_name('firstname'), 'lastname' => get_user_field_name('lastname'), 'email' => get_user_field_name('email'), 'city' => get_user_field_name('city'), 'country' => get_user_field_name('country'), 'url' => get_user_field_name('url'), 'icq' => get_user_field_name('icq'), 'skype' => get_user_field_name('skype'), 'aim' => get_user_field_name('aim'), 'yahoo' => get_user_field_name('yahoo'), 'msn' => get_user_field_name('msn'), 'idnumber' => get_user_field_name('idnumber'), 'institution' => get_user_field_name('institution'), 'department' => get_user_field_name('department'), 'phone1' => get_user_field_name('phone1'), 'phone2' => get_user_field_name('phone2'), 'address' => get_user_field_name('address'));
     // Get the user custom fields.
     $arrcustomfields = \availability_profile\condition::get_custom_profile_fields();
     $customfields = array();
     foreach ($arrcustomfields as $key => $customfield) {
         $customfields[$customfield->id] = $key;
     }
     // Combine the two.
     $fields = $userfields + $customfields;
     core_collator::asort($fields);
     // Create the select box where the user field is selected.
     $mform->addElement('select', 'userfield', get_string('userfield', 'customcertelement_userfield'), $fields);
     $mform->setType('userfield', PARAM_ALPHANUM);
     $mform->addHelpButton('userfield', 'userfield', 'customcertelement_userfield');
     parent::render_form_elements($mform);
 }
コード例 #4
0
ファイル: lib.php プロジェクト: rezaies/moodle-mod_customcert
 /**
  * This function renders the form elements when adding a customcert element.
  *
  * @param mod_customcert_edit_element_form $mform the edit_form instance
  */
 public function render_form_elements($mform)
 {
     // Get the grade items we can display.
     $gradeitems = array();
     $gradeitems[CUSTOMCERT_GRADE_COURSE] = get_string('coursegrade', 'customcertelement_grade');
     $gradeitems = $gradeitems + self::get_grade_items();
     // The grade items.
     $mform->addElement('select', 'gradeitem', get_string('gradeitem', 'customcertelement_grade'), $gradeitems);
     $mform->setType('gradeitem', PARAM_INT);
     $mform->addHelpButton('gradeitem', 'gradeitem', 'customcertelement_grade');
     // The grade format.
     $mform->addElement('select', 'gradeformat', get_string('gradeformat', 'customcertelement_grade'), self::get_grade_format_options());
     $mform->setType('gradeformat', PARAM_INT);
     $mform->addHelpButton('gradeformat', 'gradeformat', 'customcertelement_grade');
     parent::render_form_elements($mform);
 }
コード例 #5
0
ファイル: lib.php プロジェクト: rezaies/moodle-mod_customcert
 /**
  * This function renders the form elements when adding a customcert element.
  *
  * @param mod_customcert_edit_element_form $mform the edit_form instance
  */
 public function render_form_elements($mform)
 {
     // Get the possible date options.
     $dateoptions = array();
     $dateoptions[CUSTOMCERT_DATE_ISSUE] = get_string('issueddate', 'customcertelement_date');
     $dateoptions[CUSTOMCERT_DATE_COMPLETION] = get_string('completiondate', 'customcertelement_date');
     $dateoptions = $dateoptions + customcert_element_grade::get_grade_items();
     $mform->addElement('select', 'dateitem', get_string('dateitem', 'customcertelement_date'), $dateoptions);
     $mform->addHelpButton('dateitem', 'dateitem', 'customcertelement_date');
     $mform->addElement('select', 'dateformat', get_string('dateformat', 'customcertelement_date'), self::get_date_formats());
     $mform->addHelpButton('dateformat', 'dateformat', 'customcertelement_date');
     parent::render_form_elements($mform);
 }
コード例 #6
0
ファイル: lib.php プロジェクト: rezaies/moodle-mod_customcert
 /**
  * This function renders the form elements when adding a customcert element.
  *
  * @param mod_customcert_edit_element_form $mform the edit_form instance
  */
 public function render_form_elements($mform)
 {
     $mform->addElement('select', 'teacher', get_string('teacher', 'customcertelement_teachername'), $this->get_list_of_teachers());
     $mform->addHelpButton('teacher', 'teacher', 'customcertelement_teachername');
     parent::render_form_elements($mform);
 }
コード例 #7
0
ファイル: lib.php プロジェクト: rezaies/moodle-mod_customcert
 /**
  * Sets the data on the form when editing an element.
  *
  * @param mod_customcert_edit_element_form $mform the edit_form instance
  */
 public function definition_after_data($mform)
 {
     global $COURSE;
     // Set the image, width and height for this element.
     $imageinfo = json_decode($this->element->data);
     $this->element->image = $imageinfo->pathnamehash;
     $this->element->width = $imageinfo->width;
     $this->element->height = $imageinfo->height;
     // Editing existing instance - copy existing files into draft area.
     $draftitemid = file_get_submitted_draft_itemid('customcertimage');
     $filemanageroptions = array('maxbytes' => $COURSE->maxbytes, 'subdirs' => 1, 'accepted_types' => 'image');
     file_prepare_draft_area($draftitemid, context_course::instance($COURSE->id)->id, 'mod_customcert', 'image', 0, $filemanageroptions);
     $element = $mform->getElement('customcertimage');
     $element->setValue($draftitemid);
     parent::definition_after_data($mform);
 }
コード例 #8
0
 /**
  * Helper function to render the position elements.
  *
  * @param mod_customcert_edit_element_form $mform the edit_form instance.
  */
 public function render_form_element_position($mform)
 {
     $mform->addElement('text', 'posx', get_string('posx', 'customcert'), array('size' => 10));
     $mform->setType('posx', PARAM_INT);
     $mform->setDefault('posx', '0');
     $mform->addHelpButton('posx', 'posx', 'customcert');
     $mform->addElement('text', 'posy', get_string('posy', 'customcert'), array('size' => 10));
     $mform->setType('posy', PARAM_INT);
     $mform->setDefault('posy', '0');
     $mform->addHelpButton('posy', 'posy', 'customcert');
     $mform->addElement('text', 'width', get_string('elementwidth', 'customcert'), array('size' => 10));
     $mform->setType('width', PARAM_INT);
     $mform->setDefault('width', '');
     $mform->addHelpButton('width', 'elementwidth', 'customcert');
     $refpointoptions = array();
     $refpointoptions[CUSTOMCERT_REF_POINT_TOPLEFT] = get_string('topleft', 'customcert');
     $refpointoptions[CUSTOMCERT_REF_POINT_TOPCENTER] = get_string('topcenter', 'customcert');
     $refpointoptions[CUSTOMCERT_REF_POINT_TOPRIGHT] = get_string('topright', 'customcert');
     $mform->addElement('select', 'refpoint', get_string('refpoint', 'customcert'), $refpointoptions);
     $mform->setType('refpoint', PARAM_INT);
     $mform->setDefault('refpoint', '');
     $mform->addHelpButton('refpoint', 'refpoint', 'customcert');
     $alignoptions = array();
     $alignoptions[''] = get_string('alignnone', 'customcert');
     $alignoptions['L'] = get_string('alignleft', 'customcert');
     $alignoptions['C'] = get_string('aligncenter', 'customcert');
     $alignoptions['R'] = get_string('alignright', 'customcert');
     $mform->addElement('select', 'align', get_string('align', 'customcert'), $alignoptions);
     $mform->setType('align', PARAM_ALPHA);
     $mform->setDefault('align', '');
     $mform->addHelpButton('align', 'align', 'customcert');
 }
コード例 #9
0
ファイル: lib.php プロジェクト: rezaies/moodle-mod_customcert
 /**
  * This function renders the form elements when adding a customcert element.
  *
  * @param mod_customcert_edit_element_form $mform the edit_form instance
  */
 public function render_form_elements($mform)
 {
     $mform->addElement('select', 'gradeitem', get_string('gradeitem', 'customcertelement_gradeitemname'), customcert_element_grade::get_grade_items());
     $mform->addHelpButton('gradeitem', 'gradeitem', 'customcertelement_gradeitemname');
     parent::render_form_elements($mform);
 }
コード例 #10
0
    $element = new stdClass();
    $element->element = required_param('element', PARAM_ALPHA);
    // Set the page url.
    $params = array();
    $params['cmid'] = $cmid;
    $params['action'] = 'add';
    $params['element'] = $element->element;
    $params['pageid'] = $pageid;
    $pageurl = new moodle_url('/mod/customcert/edit_element.php', $params);
}
require_login($course, false, $cm);
require_capability('mod/customcert:manage', $context);
$PAGE->set_heading($course->fullname);
$PAGE->set_title(get_string('editcustomcert', 'customcert', format_string($customcert->name)));
$PAGE->set_url($pageurl);
$mform = new mod_customcert_edit_element_form($pageurl, array('element' => $element, 'course' => $course, 'cmid' => $cmid, 'action' => $action));
// Check if they cancelled.
if ($mform->is_cancelled()) {
    $url = new moodle_url('/mod/customcert/edit.php', array('cmid' => $cmid));
    redirect($url);
}
if ($data = $mform->get_data()) {
    // Set the id, or page id depending on if we are editing an element, or adding a new one.
    if ($action == 'edit') {
        $data->id = $id;
    } else {
        $data->pageid = $pageid;
    }
    // Set the element variable.
    $data->element = $element->element;
    // Get an instance of the element class.