コード例 #1
0
ファイル: lib.php プロジェクト: jamesmcq/elis
function get_fields()
{
    return array_merge(get_profilefields(), get_customfields());
}
コード例 #2
0
ファイル: forms.php プロジェクト: remotelearner/elis.cm
 /**
  * items in the form
  */
 public function definition()
 {
     $questions = get_questions();
     $profile_fields = get_profilefields();
     $custom_fields = get_customfields();
     $mform =& $this->_form;
     unset($questions['none']);
     foreach ($questions as $k => $q) {
         $extra = null;
         if (in_array($k, $profile_fields)) {
             if (strcmp($k, 'country') === 0) {
                 $type = 'select';
                 $extra = get_list_of_countries();
             } else {
                 $type = 'text';
             }
         } else {
             if (in_array($k, $custom_fields)) {
                 $field = get_record('user_info_field', 'shortname', $k);
                 if (strcmp($field->datatype, 'menu') === 0) {
                     $type = 'select';
                     $extra = explode("\n", $field->param1);
                     $extra = array_combine($extra, $extra);
                 } else {
                     if (strcmp($field->datatype, 'text') === 0) {
                         $type = 'text';
                     } else {
                         if (strcmp($field->datatype, 'checkbox') === 0) {
                             $type = 'checkbox';
                         } else {
                             if (strcmp($field->datatype, 'textarea') === 0) {
                                 $type = 'textarea';
                             }
                         }
                     }
                 }
             }
         }
         if (!empty($type)) {
             $mform->addElement($type, $k, $q, $extra);
         }
     }
     $group = array();
     $group[] =& $mform->createElement('submit', 'save_exit', get_string('save_exit', 'block_enrol_survey'));
     $group[] =& $mform->createElement('submit', 'update', get_string('update', 'block_enrol_survey'));
     $group[] =& $mform->createElement('cancel');
     $mform->addGroup($group, 'form_buttons', '', array(''), false);
 }
コード例 #3
0
ファイル: survey.php プロジェクト: remotelearner/elis.cm
} else {
    $context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
}
require_capability('block/enrol_survey:take', $context);
/* TBD: avoid error from $u->update() below
   if (cm_get_crlmuserid($USER->id) === false) {
       print_error(get_string('noelisuser', 'block_enrol_survey'));
   }
   */
$survey_form = new survey_form($CFG->wwwroot . '/blocks/enrol_survey/survey.php?id=' . $instanceid);
if ($survey_form->is_cancelled()) {
    redirect($CFG->wwwroot . '/course/view.php?id=' . $COURSE->id);
} else {
    if ($formdata = $survey_form->get_data()) {
        $customfields = get_customfields();
        $profilefields = get_profilefields();
        $data = get_object_vars($formdata);
        $u = new user(cm_get_crlmuserid($USER->id));
        foreach ($data as $key => $fd) {
            if (!empty($fd)) {
                if (in_array($key, $profilefields)) {
                    if (!empty($u->properties[$key])) {
                        $u->{$key}($fd);
                    }
                } else {
                    if (in_array($key, $customfields)) {
                        $id = get_field('user_info_field', 'id', 'shortname', $key);
                        if (record_exists('user_info_data', 'userid', $USER->id, 'fieldid', $id)) {
                            set_field('user_info_data', 'data', $fd, 'userid', $USER->id, 'fieldid', $id);
                        } else {
                            $dataobj = new object();
コード例 #4
0
ファイル: forms.php プロジェクト: jamesmcq/elis
 /**
  * items in the form
  */
 public function definition()
 {
     global $DB;
     $questions = get_questions();
     $profile_fields = get_profilefields();
     $custom_fields = get_customfields();
     $mform =& $this->_form;
     unset($questions['none']);
     foreach ($questions as $k => $q) {
         $extra = null;
         if (in_array($k, $profile_fields)) {
             if (strcmp($k, 'country') === 0) {
                 $type = 'select';
                 $extra = get_string_manager()->get_list_of_countries();
             } else {
                 if (strcmp($k, 'language') === 0) {
                     $type = 'select';
                     $extra = get_string_manager()->get_list_of_languages();
                 } else {
                     if (strcmp($k, 'inactive') === 0) {
                         $type = 'advcheckbox';
                     } else {
                         $type = 'text';
                     }
                 }
             }
         } else {
             if (in_array($k, $custom_fields)) {
                 $field = $DB->get_record('user_info_field', array('shortname' => $k));
                 if (strcmp($field->datatype, 'menu') === 0) {
                     $type = 'select';
                     $extra = explode("\n", $field->param1);
                     $extra = array_combine($extra, $extra);
                 } else {
                     if (strcmp($field->datatype, 'text') === 0) {
                         $type = 'text';
                     } else {
                         if (strcmp($field->datatype, 'checkbox') === 0) {
                             $type = 'advcheckbox';
                         } else {
                             if (strcmp($field->datatype, 'textarea') === 0) {
                                 $type = 'textarea';
                             }
                         }
                     }
                 }
             }
         }
         if (!empty($type)) {
             $mform->addElement($type, $k, $q, $extra);
             if ($type === 'text' || $type === 'textarea') {
                 $mform->setType($k, PARAM_RAW);
             }
         }
     }
     $group = array();
     $group[] =& $mform->createElement('submit', 'save_exit', get_string('save_exit', 'block_enrolsurvey'));
     $group[] =& $mform->createElement('submit', 'update', get_string('update', 'block_enrolsurvey'));
     $group[] =& $mform->createElement('cancel');
     $mform->addElement('hidden', 'courseid', $this->_customdata->courseid);
     $mform->setType('courseid', PARAM_INT);
     $mform->addElement('hidden', 'mymoodle', $this->_customdata->mymoodle);
     $mform->setType('mymoodle', PARAM_INT);
     $mform->addGroup($group, 'form_buttons', '', array(' '), false);
 }