Exemplo n.º 1
1
 protected function other_preference_fields(MoodleQuickForm $mform)
 {
     $mform->addGroup(array($mform->createElement('advcheckbox', 'qtext', '', get_string('questiontext', 'quiz_responses')), $mform->createElement('advcheckbox', 'resp', '', get_string('response', 'quiz_responses')), $mform->createElement('advcheckbox', 'right', '', get_string('rightanswer', 'quiz_responses'))), 'coloptions', get_string('showthe', 'quiz_responses'), array(' '), false);
     $mform->disabledIf('qtext', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
     $mform->disabledIf('resp', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
     $mform->disabledIf('right', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
 }
 protected function standard_attempt_fields(MoodleQuickForm $mform)
 {
     $mform->addElement('select', 'attempts', get_string('reportattemptsfrom', 'quiz'), array(quiz_attempts_report::ENROLLED_WITH => get_string('reportuserswith', 'quiz'), quiz_attempts_report::ENROLLED_WITHOUT => get_string('reportuserswithout', 'quiz'), quiz_attempts_report::ENROLLED_ALL => get_string('reportuserswithorwithout', 'quiz'), quiz_attempts_report::ALL_WITH => get_string('reportusersall', 'quiz')));
     $stategroup = array($mform->createElement('advcheckbox', 'stateinprogress', '', get_string('stateinprogress', 'quiz')), $mform->createElement('advcheckbox', 'stateoverdue', '', get_string('stateoverdue', 'quiz')), $mform->createElement('advcheckbox', 'statefinished', '', get_string('statefinished', 'quiz')), $mform->createElement('advcheckbox', 'stateabandoned', '', get_string('stateabandoned', 'quiz')));
     $mform->addGroup($stategroup, 'stateoptions', get_string('reportattemptsthatare', 'quiz'), array(' '), false);
     $mform->setDefault('stateinprogress', 1);
     $mform->setDefault('stateoverdue', 1);
     $mform->setDefault('statefinished', 1);
     $mform->setDefault('stateabandoned', 1);
     $mform->disabledIf('stateinprogress', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
     $mform->disabledIf('stateoverdue', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
     $mform->disabledIf('statefinished', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
     $mform->disabledIf('stateabandoned', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
     if (quiz_report_can_filter_only_graded($this->_customdata['quiz'])) {
         $gm = html_writer::tag('span', quiz_get_grading_option_name($this->_customdata['quiz']->grademethod), array('class' => 'highlight'));
         $mform->addElement('advcheckbox', 'onlygraded', get_string('reportshowonly', 'quiz'), get_string('optonlygradedattempts', 'quiz_overview', $gm));
         $mform->disabledIf('onlygraded', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
         $mform->disabledIf('onlygraded', 'statefinished', 'notchecked');
     }
 }
Exemplo n.º 3
0
 /**
  * Add the disabledIf values.
  *
  * @param   MoodleQuickForm $mform      The form to add configuration to.
  */
 public static function add_disabled_constraints_to_form(\MoodleQuickForm $mform)
 {
     $myvalue = \tool_usertours\target::get_target_constant_for_class(get_class());
     foreach (array_keys(self::$forcedsettings) as $settingname) {
         $mform->disabledIf($settingname, 'targettype', 'eq', $myvalue);
     }
 }
Exemplo n.º 4
0
 protected function other_attempt_fields(MoodleQuickForm $mform) {
     if (has_capability('mod/quiz:regrade', $this->_customdata['context'])) {
         $mform->addElement('advcheckbox', 'onlyregraded', '',
                 get_string('optonlyregradedattempts', 'quiz_overview'));
         $mform->disabledIf('onlyregraded', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
     }
 }
Exemplo n.º 5
0
 /**
  * Get the default setting for file submission plugin
  *
  * @param MoodleQuickForm $mform The form to add elements to
  * @return void
  */
 public function get_settings(MoodleQuickForm $mform)
 {
     global $CFG, $COURSE;
     $defaultmaxfilesubmissions = $this->get_config('maxfilesubmissions');
     $defaultmaxsubmissionsizebytes = $this->get_config('maxsubmissionsizebytes');
     $settings = array();
     $options = array();
     for ($i = 1; $i <= ASSIGNSUBMISSION_FILE_MAXFILES; $i++) {
         $options[$i] = $i;
     }
     $mform->addElement('select', 'assignsubmission_file_maxfiles', get_string('maxfilessubmission', 'assignsubmission_file'), $options);
     $mform->addHelpButton('assignsubmission_file_maxfiles', 'maxfilessubmission', 'assignsubmission_file');
     $mform->setDefault('assignsubmission_file_maxfiles', $defaultmaxfilesubmissions);
     $mform->disabledIf('assignsubmission_file_maxfiles', 'assignsubmission_file_enabled', 'eq', 0);
     $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes, get_config('assignsubmission_file', 'maxbytes'));
     // Remove the option for 0 bytes.
     unset($choices[0]);
     if ($COURSE->maxbytes == 0) {
         $choices = array(0 => get_string('siteuploadlimit', 'assignsubmission_file')) + $choices;
     } else {
         $choices = array(0 => get_string('courseuploadlimit') . ' (' . display_size($COURSE->maxbytes) . ')') + $choices;
     }
     $settings[] = array('type' => 'select', 'name' => 'maxsubmissionsizebytes', 'description' => get_string('maximumsubmissionsize', 'assignsubmission_file'), 'options' => $choices, 'default' => $defaultmaxsubmissionsizebytes);
     $mform->addElement('select', 'assignsubmission_file_maxsizebytes', get_string('maximumsubmissionsize', 'assignsubmission_file'), $choices);
     $mform->addHelpButton('assignsubmission_file_maxsizebytes', 'maximumsubmissionsize', 'assignsubmission_file');
     $mform->setDefault('assignsubmission_file_maxsizebytes', $defaultmaxsubmissionsizebytes);
     $mform->disabledIf('assignsubmission_file_maxsizebytes', 'assignsubmission_file_enabled', 'eq', 0);
 }
 public static function add_settings_form_fields(mod_quiz_mod_form $quizform, MoodleQuickForm $mform)
 {
     $config = get_config('quizaccess_offlinemode');
     $mform->addElement('selectyesno', 'offlinemode_enabled', get_string('offlinemodeenabled', 'quizaccess_offlinemode'));
     $mform->addHelpButton('offlinemode_enabled', 'offlinemodeenabled', 'quizaccess_offlinemode');
     $mform->setDefault('offlinemode_enabled', !empty($config->defaultenabled));
     $mform->setAdvanced('offlinemode_enabled', !empty($config->defaultenabled_adv));
     foreach (question_engine::get_behaviour_options(null) as $behaviour => $notused) {
         if (!self::is_compatible_behaviour($behaviour)) {
             $mform->disabledIf('offlinemode_enabled', 'preferredbehaviour', 'eq', $behaviour);
         }
     }
 }
Exemplo n.º 7
0
 /**
  * Get the default setting for OneNote submission plugin
  *
  * @param MoodleQuickForm $mform The form to add elements to
  * @return void
  */
 public function get_settings(MoodleQuickForm $mform)
 {
     global $CFG, $COURSE;
     $defaultmaxfilesubmissions = $this->get_config('maxfilesubmissions');
     $defaultmaxsubmissionsizebytes = $this->get_config('maxsubmissionsizebytes');
     $settings = array();
     $options = array();
     for ($i = 1; $i <= \local_onenote\api\base::ASSIGNSUBMISSION_ONENOTE_MAXFILES; $i++) {
         $options[$i] = $i;
     }
     $name = get_string('maxfilessubmission', 'assignsubmission_onenote');
     $mform->addElement('select', 'assignsubmission_onenote_maxfiles', $name, $options);
     $mform->addHelpButton('assignsubmission_onenote_maxfiles', 'maxfilessubmission', 'assignsubmission_onenote');
     $mform->setDefault('assignsubmission_onenote_maxfiles', $defaultmaxfilesubmissions);
     $mform->disabledIf('assignsubmission_onenote_maxfiles', 'assignsubmission_onenote_enabled', 'notchecked');
     $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes, get_config('assignsubmission_onenote', 'maxbytes'));
     $settings[] = array('type' => 'select', 'name' => 'maxsubmissionsizebytes', 'description' => get_string('maximumsubmissionsize', 'assignsubmission_onenote'), 'options' => $choices, 'default' => $defaultmaxsubmissionsizebytes);
     $name = get_string('maximumsubmissionsize', 'assignsubmission_onenote');
     $mform->addElement('select', 'assignsubmission_onenote_maxsizebytes', $name, $choices);
     $mform->addHelpButton('assignsubmission_onenote_maxsizebytes', 'maximumsubmissionsize', 'assignsubmission_onenote');
     $mform->setDefault('assignsubmission_onenote_maxsizebytes', $defaultmaxsubmissionsizebytes);
     $mform->disabledIf('assignsubmission_onenote_maxsizebytes', 'assignsubmission_onenote_enabled', 'notchecked');
 }
Exemplo n.º 8
0
 /**
  * Adds controls specific to this filter in the form.
  *
  * @param moodleform $mform a MoodleQuickForm object in which element will be added
  */
 public function setupForm(MoodleQuickForm &$mform)
 {
     $objs = array();
     $objs[] = $mform->createElement('checkbox', $this->_name, null, '');
     $grp = $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name . '_grp');
     }
     //Check if disable if options are set. if yes then set rules
     if (!empty($this->disableelements) && is_array($this->disableelements)) {
         foreach ($this->disableelements as $disableelement) {
             $mform->disabledIf($disableelement, $this->_name, 'checked');
         }
     }
 }
Exemplo n.º 9
0
 /**
  * Get the settings for onlinetext submission plugin
  *
  * @param MoodleQuickForm $mform The form to add elements to
  * @return void
  */
 public function get_settings(MoodleQuickForm $mform)
 {
     global $CFG, $COURSE;
     $defaultwordlimit = $this->get_config('wordlimit') == 0 ? '' : $this->get_config('wordlimit');
     $defaultwordlimitenabled = $this->get_config('wordlimitenabled');
     $options = array('size' => '6', 'maxlength' => '6');
     $name = get_string('wordlimit', 'assignsubmission_onlinetext');
     // Create a text box that can be enabled/disabled for onlinetext word limit.
     $wordlimitgrp = array();
     $wordlimitgrp[] = $mform->createElement('text', 'assignsubmission_onlinetext_wordlimit', '', $options);
     $wordlimitgrp[] = $mform->createElement('checkbox', 'assignsubmission_onlinetext_wordlimit_enabled', '', get_string('enable'));
     $mform->addGroup($wordlimitgrp, 'assignsubmission_onlinetext_wordlimit_group', $name, ' ', false);
     $mform->addHelpButton('assignsubmission_onlinetext_wordlimit_group', 'wordlimit', 'assignsubmission_onlinetext');
     $mform->disabledIf('assignsubmission_onlinetext_wordlimit', 'assignsubmission_onlinetext_wordlimit_enabled', 'notchecked');
     // Add numeric rule to text field.
     $wordlimitgrprules = array();
     $wordlimitgrprules['assignsubmission_onlinetext_wordlimit'][] = array(null, 'numeric', null, 'client');
     $mform->addGroupRule('assignsubmission_onlinetext_wordlimit_group', $wordlimitgrprules);
     // Rest of group setup.
     $mform->setDefault('assignsubmission_onlinetext_wordlimit', $defaultwordlimit);
     $mform->setDefault('assignsubmission_onlinetext_wordlimit_enabled', $defaultwordlimitenabled);
     $mform->setType('assignsubmission_onlinetext_wordlimit', PARAM_INT);
     $mform->disabledIf('assignsubmission_onlinetext_wordlimit_group', 'assignsubmission_onlinetext_enabled', 'notchecked');
 }
Exemplo n.º 10
0
 /**
  * Add elements to the edit instance form.
  *
  * @param stdClass $instance
  * @param MoodleQuickForm $mform
  * @param context $context
  * @return bool
  */
 public function edit_instance_form($instance, MoodleQuickForm $mform, $context)
 {
     global $DB;
     $nameattribs = array('size' => '20', 'maxlength' => '255');
     $mform->addElement('text', 'name', get_string('custominstancename', 'enrol'), $nameattribs);
     $mform->setType('name', PARAM_TEXT);
     $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'server');
     $tools = array();
     $tools[$context->id] = get_string('course');
     $modinfo = get_fast_modinfo($instance->courseid);
     $mods = $modinfo->get_cms();
     foreach ($mods as $mod) {
         $tools[$mod->context->id] = format_string($mod->name);
     }
     $mform->addElement('select', 'contextid', get_string('tooltobeprovided', 'enrol_lti'), $tools);
     $mform->setDefault('contextid', $context->id);
     $mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'enrol_lti'), array('optional' => true, 'defaultunit' => DAYSECS));
     $mform->setDefault('enrolperiod', 0);
     $mform->addHelpButton('enrolperiod', 'enrolperiod', 'enrol_lti');
     $mform->addElement('date_time_selector', 'enrolstartdate', get_string('enrolstartdate', 'enrol_lti'), array('optional' => true));
     $mform->setDefault('enrolstartdate', 0);
     $mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'enrol_lti');
     $mform->addElement('date_time_selector', 'enrolenddate', get_string('enrolenddate', 'enrol_lti'), array('optional' => true));
     $mform->setDefault('enrolenddate', 0);
     $mform->addHelpButton('enrolenddate', 'enrolenddate', 'enrol_lti');
     $mform->addElement('text', 'maxenrolled', get_string('maxenrolled', 'enrol_lti'));
     $mform->setDefault('maxenrolled', 0);
     $mform->addHelpButton('maxenrolled', 'maxenrolled', 'enrol_lti');
     $mform->setType('maxenrolled', PARAM_INT);
     $assignableroles = get_assignable_roles($context);
     $mform->addElement('select', 'roleinstructor', get_string('roleinstructor', 'enrol_lti'), $assignableroles);
     $mform->setDefault('roleinstructor', '3');
     $mform->addHelpButton('roleinstructor', 'roleinstructor', 'enrol_lti');
     $mform->addElement('select', 'rolelearner', get_string('rolelearner', 'enrol_lti'), $assignableroles);
     $mform->setDefault('rolelearner', '5');
     $mform->addHelpButton('rolelearner', 'rolelearner', 'enrol_lti');
     $mform->addElement('header', 'remotesystem', get_string('remotesystem', 'enrol_lti'));
     $mform->addElement('text', 'secret', get_string('secret', 'enrol_lti'), 'maxlength="64" size="25"');
     $mform->setType('secret', PARAM_ALPHANUM);
     $mform->setDefault('secret', random_string(32));
     $mform->addHelpButton('secret', 'secret', 'enrol_lti');
     $mform->addRule('secret', get_string('required'), 'required');
     $mform->addElement('selectyesno', 'gradesync', get_string('gradesync', 'enrol_lti'));
     $mform->setDefault('gradesync', 1);
     $mform->addHelpButton('gradesync', 'gradesync', 'enrol_lti');
     $mform->addElement('selectyesno', 'gradesynccompletion', get_string('requirecompletion', 'enrol_lti'));
     $mform->setDefault('gradesynccompletion', 0);
     $mform->disabledIf('gradesynccompletion', 'gradesync', 0);
     $mform->addElement('selectyesno', 'membersync', get_string('membersync', 'enrol_lti'));
     $mform->setDefault('membersync', 1);
     $mform->addHelpButton('membersync', 'membersync', 'enrol_lti');
     $options = array();
     $options[\enrol_lti\helper::MEMBER_SYNC_ENROL_AND_UNENROL] = get_string('membersyncmodeenrolandunenrol', 'enrol_lti');
     $options[\enrol_lti\helper::MEMBER_SYNC_ENROL_NEW] = get_string('membersyncmodeenrolnew', 'enrol_lti');
     $options[\enrol_lti\helper::MEMBER_SYNC_UNENROL_MISSING] = get_string('membersyncmodeunenrolmissing', 'enrol_lti');
     $mform->addElement('select', 'membersyncmode', get_string('membersyncmode', 'enrol_lti'), $options);
     $mform->setDefault('membersyncmode', \enrol_lti\helper::MEMBER_SYNC_ENROL_AND_UNENROL);
     $mform->addHelpButton('membersyncmode', 'membersyncmode', 'enrol_lti');
     $mform->disabledIf('membersyncmode', 'membersync', 0);
     $mform->addElement('header', 'defaultheader', get_string('userdefaultvalues', 'enrol_lti'));
     $emaildisplay = get_config('enrol_lti', 'emaildisplay');
     $choices = array(0 => get_string('emaildisplayno'), 1 => get_string('emaildisplayyes'), 2 => get_string('emaildisplaycourse'));
     $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
     $mform->setDefault('maildisplay', $emaildisplay);
     $city = get_config('enrol_lti', 'city');
     $mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"');
     $mform->setType('city', PARAM_TEXT);
     $mform->setDefault('city', $city);
     $country = get_config('enrol_lti', 'country');
     $countries = array('' => get_string('selectacountry') . '...') + get_string_manager()->get_list_of_countries();
     $mform->addElement('select', 'country', get_string('selectacountry'), $countries);
     $mform->setDefault('country', $country);
     $mform->setAdvanced('country');
     $timezone = get_config('enrol_lti', 'timezone');
     $choices = core_date::get_list_of_timezones(null, true);
     $mform->addElement('select', 'timezone', get_string('timezone'), $choices);
     $mform->setDefault('timezone', $timezone);
     $mform->setAdvanced('timezone');
     $lang = get_config('enrol_lti', 'lang');
     $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
     $mform->setDefault('lang', $lang);
     $mform->setAdvanced('lang');
     $institution = get_config('enrol_lti', 'institution');
     $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="40" size="25"');
     $mform->setType('institution', core_user::get_property_type('institution'));
     $mform->setDefault('institution', $institution);
     $mform->setAdvanced('institution');
     // Check if we are editing an instance.
     if (!empty($instance->id)) {
         // Get the details from the enrol_lti_tools table.
         $ltitool = $DB->get_record('enrol_lti_tools', array('enrolid' => $instance->id), '*', MUST_EXIST);
         $mform->addElement('hidden', 'toolid');
         $mform->setType('toolid', PARAM_INT);
         $mform->setConstant('toolid', $ltitool->id);
         $mform->setDefaults((array) $ltitool);
     }
 }
Exemplo n.º 11
0
/**
 * Extends the course reset form with workshop specific settings.
 *
 * @param MoodleQuickForm $mform
 */
function workshop_reset_course_form_definition($mform) {

    $mform->addElement('header', 'workshopheader', get_string('modulenameplural', 'mod_workshop'));

    $mform->addElement('advcheckbox', 'reset_workshop_submissions', get_string('resetsubmissions', 'mod_workshop'));
    $mform->addHelpButton('reset_workshop_submissions', 'resetsubmissions', 'mod_workshop');

    $mform->addElement('advcheckbox', 'reset_workshop_assessments', get_string('resetassessments', 'mod_workshop'));
    $mform->addHelpButton('reset_workshop_assessments', 'resetassessments', 'mod_workshop');
    $mform->disabledIf('reset_workshop_assessments', 'reset_workshop_submissions', 'checked');

    $mform->addElement('advcheckbox', 'reset_workshop_phase', get_string('resetphase', 'mod_workshop'));
    $mform->addHelpButton('reset_workshop_phase', 'resetphase', 'mod_workshop');
}
Exemplo n.º 12
0
  /**
   * Get the default setting for feedback comments plugin
   *
   * @param MoodleQuickForm $mform The form to add elements to
   * @return void
   */
  public function get_settings(MoodleQuickForm $mform) {
      $default = $this->get_config('commentinline');
      $mform->addElement('selectyesno',
                         'assignfeedback_comments_commentinline',
                         get_string('commentinline', 'assignfeedback_comments'));
      $mform->addHelpButton('assignfeedback_comments_commentinline', 'commentinline', 'assignfeedback_comments');
      $mform->setDefault('assignfeedback_comments_commentinline', $default);
      // Disable comment online if comment feedback plugin is disabled.
      $mform->disabledIf('assignfeedback_comments_commentinline', 'assignfeedback_comments_enabled', 'notchecked');
 }
Exemplo n.º 13
0
 /**
  * Adds enrol instance UI to course edit form
  *
  * @param object $instance enrol instance or null if does not exist yet
  * @param MoodleQuickForm $mform
  * @param object $data
  * @param object $context context of existing course or parent category if course does not exist
  * @return void
  */
 public function course_edit_form($instance, MoodleQuickForm $mform, $data, $context)
 {
     $i = isset($instance->id) ? $instance->id : 0;
     if (!$i and !$this->get_config('defaultenrol')) {
         return;
     }
     $header = $this->get_instance_name($instance);
     $config = has_capability('enrol/guest:config', $context);
     $mform->addElement('header', 'enrol_guest_header_' . $i, $header);
     $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), ENROL_INSTANCE_DISABLED => get_string('no'));
     $mform->addElement('select', 'enrol_guest_status_' . $i, get_string('status', 'enrol_guest'), $options);
     $mform->addHelpButton('enrol_guest_status_' . $i, 'status', 'enrol_guest');
     $mform->setDefault('enrol_guest_status_' . $i, $this->get_config('status'));
     $mform->setAdvanced('enrol_guest_status_' . $i, $this->get_config('status_adv'));
     if (!$config) {
         $mform->hardFreeze('enrol_guest_status_' . $i);
     }
     $mform->addElement('passwordunmask', 'enrol_guest_password_' . $i, get_string('password', 'enrol_guest'));
     $mform->addHelpButton('enrol_guest_password_' . $i, 'password', 'enrol_guest');
     if (!$config) {
         $mform->hardFreeze('enrol_guest_password_' . $i);
     } else {
         $mform->disabledIf('enrol_guest_password_' . $i, 'enrol_guest_status_' . $i, 'noteq', ENROL_INSTANCE_ENABLED);
     }
     // now add all values from enrol table
     if ($instance) {
         foreach ($instance as $key => $val) {
             $data->{'enrol_guest_' . $key . '_' . $i} = $val;
         }
     }
 }
Exemplo n.º 14
0
 public static function add_settings_form_fields(mod_quiz_mod_form $quizform, MoodleQuickForm $mform)
 {
     global $CFG;
     // Allow to enable the access rule only if the Mobile services are enabled.
     if ($CFG->enablemobilewebservice) {
         $mform->addElement('selectyesno', 'allowofflineattempts', get_string('allowofflineattempts', 'quizaccess_offlineattempts'));
         $mform->addHelpButton('allowofflineattempts', 'allowofflineattempts', 'quizaccess_offlineattempts');
         $mform->setDefault('allowofflineattempts', 0);
         $mform->setAdvanced('allowofflineattempts');
         $mform->disabledIf('allowofflineattempts', 'timelimit[number]', 'neq', 0);
         $mform->disabledIf('allowofflineattempts', 'subnet', 'neq', '');
     }
 }
Exemplo n.º 15
0
 /**
  * Get the default setting for feedback comments plugin
  *
  * @param MoodleQuickForm $mform The form to add elements to
  * @return void
  */
 public function get_settings(MoodleQuickForm $mform)
 {
     $default = $this->get_config('commentinline');
     if ($default === false) {
         // Apply the admin default if we don't have a value yet.
         $default = get_config('assignfeedback_comments', 'inline');
     }
     $mform->addElement('selectyesno', 'assignfeedback_comments_commentinline', get_string('commentinline', 'assignfeedback_comments'));
     $mform->addHelpButton('assignfeedback_comments_commentinline', 'commentinline', 'assignfeedback_comments');
     $mform->setDefault('assignfeedback_comments_commentinline', $default);
     // Disable comment online if comment feedback plugin is disabled.
     $mform->disabledIf('assignfeedback_comments_commentinline', 'assignfeedback_comments_enabled', 'notchecked');
 }
Exemplo n.º 16
0
 /**
  * Add the disabledIf values.
  *
  * @param   MoodleQuickForm $mform      The form to add configuration to.
  */
 public static function add_disabled_constraints_to_form(\MoodleQuickForm $mform)
 {
     $mform->disabledIf('targetvalue_selector', 'targettype', 'noteq', \tool_usertours\target::get_target_constant_for_class(get_class()));
 }
Exemplo n.º 17
0
 /**
  * Get the settings for Youtube submission plugin form
  *
  * @global stdClass $CFG
  * @global stdClass $COURSE
  * @param MoodleQuickForm $mform The form to add elements to
  * @return void
  */
 public function get_settings(MoodleQuickForm $mform)
 {
     global $CFG, $COURSE;
     //get default display size for single player screens
     $displaysizesingle_default = $this->get_config('displaysizesingle');
     if ($displaysizesingle_default == null) {
         $displaysizesingle_default = get_config('assignsubmission_youtube', 'displaysize_single');
     }
     //get default display size for screens with lists of players
     $displaysizelist_default = $this->get_config('displaysizelist');
     if ($displaysizelist_default == null) {
         $displaysizelist_default = get_config('assignsubmission_youtube', 'displaysize_list');
     }
     /*
     //get default authentication type
     $authtype_default = $this->get_config('authtype');
     if(!$authtype_default){
     	$authtype_default = get_config('assignsubmission_youtube', 'authtype');
     }
     */
     //The size of the youtube player on the various screens
     $displaysizes = array('0' => new lang_string('linkonly', 'assignsubmission_youtube'), '1' => new lang_string('moodledefault', 'assignsubmission_youtube'), '160' => '160x120', '320' => '320x240', '480' => '480x360', '640' => '640x480', '800' => '800x600', '1024' => '1024x768');
     //add the screen size selectors
     //single
     $mform->addElement('select', 'assignsubmission_youtube_displaysizesingle', get_string('displaysizesingle', 'assignsubmission_youtube'), $displaysizes);
     $mform->setDefault('assignsubmission_youtube_displaysizesingle', $displaysizesingle_default);
     $mform->disabledIf('assignsubmission_youtube_displaysizesingle', 'assignsubmission_youtube_enabled', 'eq', 0);
     //list
     $mform->addElement('select', 'assignsubmission_youtube_displaysizelist', get_string('displaysizelist', 'assignsubmission_youtube'), $displaysizes);
     $mform->setDefault('assignsubmission_youtube_displaysizelist', $displaysizelist_default);
     $mform->disabledIf('assignsubmission_youtube_displaysizelist', 'assignsubmission_youtube_enabled', 'eq', 0);
     //The authentication type, master user or student by student
     /*
     $authoptions = array('byuser' => new lang_string('byuser', 'assignsubmission_youtube'),
     	'bymaster' => new lang_string('bymaster', 'assignsubmission_youtube'));
     $mform->addElement('select', 'assignsubmission_youtube_authtype',
     	get_string('authtype', 'assignsubmission_youtube'), $authoptions);
     $mform->setDefault('assignsubmission_youtube_authtype', $authtype_default);
     $mform->disabledIf('assignsubmission_youtube_authtype', 'assignsubmission_youtube_enabled', 'eq', 0);	
     */
 }
Exemplo n.º 18
0
 /**
  * Get the settings for PoodLL Feedback plugin form
  *
  * @global stdClass $CFG
  * @global stdClass $COURSE
  * @param MoodleQuickForm $mform The form to add elements to
  * @return void
  */
 public function get_settings(MoodleQuickForm $mform)
 {
     global $CFG, $COURSE;
     //get saved values and return them as defaults
     $recordertype = $this->get_config('recordertype');
     $boardsize = $this->get_config('boardsize');
     $downloadsok = $this->get_config('downloadsok');
     //get allowed recorders from admin settings
     $allowed_recorders = get_config('assignfeedback_poodll', 'allowedrecorders');
     $allowed_recorders = explode(',', $allowed_recorders);
     $recorderoptions = array();
     if (array_search(FP_REPLYMP3VOICE, $allowed_recorders) !== false) {
         $recorderoptions[FP_REPLYMP3VOICE] = get_string("replymp3voice", "assignfeedback_poodll");
     }
     if (array_search(FP_REPLYVOICE, $allowed_recorders) !== false) {
         $recorderoptions[FP_REPLYVOICE] = get_string("replyvoice", "assignfeedback_poodll");
     }
     if (array_search(FP_REPLYVIDEO, $allowed_recorders) !== false) {
         $recorderoptions[FP_REPLYVIDEO] = get_string("replyvideo", "assignfeedback_poodll");
     }
     if (array_search(FP_REPLYWHITEBOARD, $allowed_recorders) !== false) {
         $recorderoptions[FP_REPLYWHITEBOARD] = get_string("replywhiteboard", "assignfeedback_poodll");
     }
     if (array_search(FP_REPLYSNAPSHOT, $allowed_recorders) !== false) {
         $recorderoptions[FP_REPLYSNAPSHOT] = get_string("replysnapshot", "assignfeedback_poodll");
     }
     //Show a list of recorders
     /*
             $recorderoptions = array( FP_REPLYMP3VOICE => get_string("replymp3voice", "assignfeedback_poodll"), 
     		FP_REPLYVOICE => get_string("replyvoice", "assignfeedback_poodll"), 
     		FP_REPLYVIDEO => get_string("replyvideo", "assignfeedback_poodll"),
     		FP_REPLYWHITEBOARD => get_string("replywhiteboard", "assignfeedback_poodll"),
     		FP_REPLYSNAPSHOT => get_string("replysnapshot", "assignfeedback_poodll"));
     */
     $mform->addElement('select', 'assignfeedback_poodll_recordertype', get_string("recordertype", "assignfeedback_poodll"), $recorderoptions);
     //$mform->addHelpButton('assignfeedback_poodll_recordertype', get_string('onlinepoodll', ASSIGNSUBMISSION_ONLINEPOODLL_COMPONENT), ASSIGNSUBMISSION_ONLINEPOODLL_COMPONENT);
     $mform->setDefault('assignfeedback_poodll_recordertype', $recordertype);
     $mform->disabledIf('assignfeedback_poodll_recordertype', 'assignfeedback_poodll_enabled', 'eq', 0);
     //Are students and teachers shown the download link for the feedback recording
     $yesno_options = array(1 => get_string("yes", "assignfeedback_poodll"), 0 => get_string("no", "assignfeedback_poodll"));
     $mform->addElement('select', 'assignfeedback_poodll_downloadsok', get_string('downloadsok', 'assignfeedback_poodll'), $yesno_options);
     $mform->setDefault('assignfeedback_poodll_downloadsok', $downloadsok);
     //If whiteboard not allowed, not much point showing boardsizes
     if (array_search(FP_REPLYWHITEBOARD, $allowed_recorders) !== false) {
         //board sizes for the whiteboard feedback
         $boardsizes = array('320x320' => '320x320', '400x600' => '400x600', '500x500' => '500x500', '600x400' => '600x400', '600x800' => '600x800', '800x600' => '800x600');
         $mform->addElement('select', 'assignfeedback_poodll_boardsize', get_string('boardsize', 'assignfeedback_poodll'), $boardsizes);
         $mform->setDefault('assignfeedback_poodll_boardsize', $boardsize);
         $mform->disabledIf('assignfeedback_poodll_boardsize', 'assignfeedback_poodll_enabled', 'eq', 0);
         $mform->disabledIf('assignfeedback_poodll_boardsize', 'assignfeedback_poodll_recordertype', 'ne', FP_REPLYWHITEBOARD);
     }
     //end of if whiteboard
 }
 /**
  * Add question-type specific form fields.
  *
  * @param MoodleQuickForm $mform the form being built.
  */
 function definition_inner(&$mform)
 {
     // Add the select control which will select the comparison type to use
     $mform->addElement('select', 'compareby', get_string('compareby', 'qtype_algebra'), array("sage" => get_string('comparesage', 'qtype_algebra'), "eval" => get_string('compareeval', 'qtype_algebra'), "equiv" => get_string('compareequiv', 'qtype_algebra')));
     $mform->setDefault('compareby', 'eval');
     $mform->setHelpButton('compareby', array('comp_algorithm', get_string('compalgorithm', 'qtype_algebra'), 'qtype_algebra'));
     // Add the control to select the number of checks to perform
     // First create an array with all the allowed values. We will then use this array
     // with the array_combine function to create a single array where the keys are the
     // same as the array values
     $chk_array = array('1', '2', '3', '5', '7', '10', '20', '30', '50', '70', '100', '200', '300', '500', '700', '1000');
     // Add the select element using the array_combine method discussed above
     $mform->addElement('select', 'nchecks', get_string('nchecks', 'qtype_algebra'), array_combine($chk_array, $chk_array));
     // Set the default number of checks to perform
     $mform->setDefault('nchecks', '10');
     $mform->setHelpButton('nchecks', array('eval_checks', get_string('evalchecks', 'qtype_algebra'), 'qtype_algebra'));
     // Add the box to set the tolerance to use when performing evaluation checks
     $mform->addElement('text', 'tolerance', get_string('tolerance', 'qtype_algebra'));
     $mform->setType('tolerance', PARAM_NUMBER);
     $mform->setDefault('tolerance', '0.001');
     $mform->setHelpButton('tolerance', array('check_tolerance', get_string('checktolerance', 'qtype_algebra'), 'qtype_algebra'));
     // Add an entry for the answer box prefix
     $mform->addElement('text', 'answerprefix', get_string('answerprefix', 'qtype_algebra'), array('size' => 55));
     $mform->setType('answerprefix', PARAM_RAW);
     $mform->setHelpButton('answerprefix', array('answer_prefix', get_string('answerboxprefix', 'qtype_algebra'), 'qtype_algebra'));
     // Add an entry for a disallowed expression
     $mform->addElement('text', 'disallow', get_string('disallow', 'qtype_algebra'), array('size' => 55));
     $mform->setType('disallow', PARAM_RAW);
     $mform->setHelpButton('disallow', array('disallowed_ans', get_string('disallowanswer', 'qtype_algebra'), 'qtype_algebra'));
     // Create an array which will store the function checkboxes
     $func_group = array();
     // Create an array to add spacers between the boxes
     $spacers = array('<br>');
     // Add the initial all functions box to the list of check boxes
     $func_group[] =& $mform->createElement('checkbox', 'all', '', get_string('allfunctions', 'qtype_algebra'));
     // Create a checkbox element for each function understood by the parser
     for ($i = 0; $i < count(qtype_algebra_parser::$functions); $i++) {
         $func = qtype_algebra_parser::$functions[$i];
         $func_group[] =& $mform->createElement('checkbox', $func, '', $func);
         if ($i % 6 == 5) {
             $spacers[] = '<br>';
         } else {
             $spacers[] = str_repeat('&nbsp;', 8 - strlen($func));
         }
     }
     // Create and add the group of function controls to the form
     $mform->addGroup($func_group, 'allowedfuncs', get_string('allowedfuncs', 'qtype_algebra'), $spacers, true);
     $mform->disabledIf('allowedfuncs', 'allowedfuncs[all]', 'checked');
     $mform->setDefault('allowedfuncs[all]', 'checked');
     $mform->setHelpButton('allowedfuncs', array('allowed_funcs', get_string('allowedfunctions', 'qtype_algebra'), 'qtype_algebra'));
     // Create the array for the list of variables used in the question
     $repeated = array();
     // Create the array for the list of repeated options used by the variable subforms
     $repeatedoptions = array();
     // Add the form elements to enter the variables
     $repeated[] =& $mform->createElement('header', 'variablehdr', get_string('variableno', 'qtype_algebra', '{no}'));
     $repeatedoptions['variablehdr']['helpbutton'] = array('variable', get_string('variable', 'qtype_algebra'), 'qtype_algebra');
     $repeated[] =& $mform->createElement('text', 'variable', get_string('variablename', 'qtype_algebra'), array('size' => 20));
     $mform->setType('variable', PARAM_RAW);
     $repeated[] =& $mform->createElement('text', 'varmin', get_string('varmin', 'qtype_algebra'), array('size' => 20));
     $mform->setType('varmin', PARAM_RAW);
     $repeatedoptions['varmin']['default'] = '';
     $repeated[] =& $mform->createElement('text', 'varmax', get_string('varmax', 'qtype_algebra'), array('size' => 20));
     $mform->setType('varmax', PARAM_RAW);
     $repeatedoptions['varmax']['default'] = '';
     // Get the current number of variables defined, if any
     if (isset($this->question->options)) {
         $countvars = count($this->question->options->variables);
     } else {
         $countvars = 0;
     }
     // Come up with the number of variable entries to add to the form at the start
     if ($this->question->formoptions->repeatelements) {
         $repeatsatstart = SYMB_QUESTION_NUMVAR_START > $countvars + SYMB_QUESTION_NUMVAR_ADD ? SYMB_QUESTION_NUMVAR_START : $countvars + SYMB_QUESTION_NUMVAR_ADD;
     } else {
         $repeatsatstart = $countvars;
     }
     $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'novariables', 'addvariables', SYMB_QUESTION_NUMVAR_ADD, get_string('addmorevariableblanks', 'qtype_algebra'));
     // Add the instructions for entering answers to the question
     $mform->addElement('static', 'answersinstruct', get_string('correctanswers', 'quiz'), get_string('filloutoneanswer', 'quiz'));
     $mform->closeHeaderBefore('answersinstruct');
     $creategrades = get_grade_options();
     $gradeoptions = $creategrades->gradeoptions;
     $repeated = array();
     $repeated[] =& $mform->createElement('header', 'answerhdr', get_string('answerno', 'qtype_algebra', '{no}'));
     $repeated[] =& $mform->createElement('text', 'answer', get_string('answer', 'quiz'), array('size' => 54));
     $repeated[] =& $mform->createElement('select', 'fraction', get_string('grade'), $gradeoptions);
     $repeated[] =& $mform->createElement('htmleditor', 'feedback', get_string('feedback', 'quiz'), array('course' => $this->coursefilesid));
     if (isset($this->question->options)) {
         $countanswers = count($this->question->options->answers);
     } else {
         $countanswers = 0;
     }
     if ($this->question->formoptions->repeatelements) {
         $repeatsatstart = SYMB_QUESTION_NUMANS_START > $countanswers + SYMB_QUESTION_NUMANS_ADD ? SYMB_QUESTION_NUMANS_START : $countanswers + SYMB_QUESTION_NUMANS_ADD;
     } else {
         $repeatsatstart = $countanswers;
     }
     $repeatedoptions = array();
     $mform->setType('answer', PARAM_RAW);
     $repeatedoptions['fraction']['default'] = 0;
     $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', SYMB_QUESTION_NUMANS_ADD, get_string('addmoreanswerblanks', 'qtype_algebra'));
 }
Exemplo n.º 20
0
 /**
  * Add elements to grade form.
  *
  * @param MoodleQuickForm $mform
  * @param stdClass $data
  * @param array $params
  * @return void
  */
 public function add_grade_form_elements(MoodleQuickForm $mform, stdClass $data, $params)
 {
     global $USER, $CFG;
     $settings = $this->get_instance();
     $rownum = $params['rownum'];
     $last = $params['last'];
     $useridlistid = $params['useridlistid'];
     $userid = $params['userid'];
     $attemptnumber = $params['attemptnumber'];
     if (!$userid) {
         $cache = cache::make_from_params(cache_store::MODE_SESSION, 'mod_assign', 'useridlist');
         if (!($useridlist = $cache->get($this->get_course_module()->id . '_' . $useridlistid))) {
             $useridlist = $this->get_grading_userid_list();
             $cache->set($this->get_course_module()->id . '_' . $useridlistid, $useridlist);
         }
     } else {
         $useridlist = array($userid);
         $rownum = 0;
         $useridlistid = '';
     }
     $userid = $useridlist[$rownum];
     $grade = $this->get_user_grade($userid, false, $attemptnumber);
     $submission = null;
     if ($this->get_instance()->teamsubmission) {
         $submission = $this->get_group_submission($userid, 0, false, $attemptnumber);
     } else {
         $submission = $this->get_user_submission($userid, false, $attemptnumber);
     }
     // Add advanced grading.
     $gradingdisabled = $this->grading_disabled($userid);
     $gradinginstance = $this->get_grading_instance($userid, $grade, $gradingdisabled);
     $mform->addElement('header', 'gradeheader', get_string('grade'));
     if ($gradinginstance) {
         $gradingelement = $mform->addElement('grading', 'advancedgrading', get_string('grade') . ':', array('gradinginstance' => $gradinginstance));
         if ($gradingdisabled) {
             $gradingelement->freeze();
         } else {
             $mform->addElement('hidden', 'advancedgradinginstanceid', $gradinginstance->get_id());
             $mform->setType('advancedgradinginstanceid', PARAM_INT);
         }
     } else {
         // Use simple direct grading.
         if ($this->get_instance()->grade > 0) {
             $name = get_string('gradeoutof', 'assign', $this->get_instance()->grade);
             if (!$gradingdisabled) {
                 $gradingelement = $mform->addElement('text', 'grade', $name);
                 $mform->addHelpButton('grade', 'gradeoutofhelp', 'assign');
                 $mform->setType('grade', PARAM_RAW);
             } else {
                 $mform->addElement('hidden', 'grade', $name);
                 $mform->hardFreeze('grade');
                 $mform->setType('grade', PARAM_RAW);
                 $strgradelocked = get_string('gradelocked', 'assign');
                 $mform->addElement('static', 'gradedisabled', $name, $strgradelocked);
                 $mform->addHelpButton('gradedisabled', 'gradeoutofhelp', 'assign');
             }
         } else {
             $grademenu = array(-1 => get_string("nograde")) + make_grades_menu($this->get_instance()->grade);
             if (count($grademenu) > 1) {
                 $gradingelement = $mform->addElement('select', 'grade', get_string('grade') . ':', $grademenu);
                 // The grade is already formatted with format_float so it needs to be converted back to an integer.
                 if (!empty($data->grade)) {
                     $data->grade = (int) unformat_float($data->grade);
                 }
                 $mform->setType('grade', PARAM_INT);
                 if ($gradingdisabled) {
                     $gradingelement->freeze();
                 }
             }
         }
     }
     $gradinginfo = grade_get_grades($this->get_course()->id, 'mod', 'assign', $this->get_instance()->id, $userid);
     if (!empty($CFG->enableoutcomes)) {
         foreach ($gradinginfo->outcomes as $index => $outcome) {
             $options = make_grades_menu(-$outcome->scaleid);
             if ($outcome->grades[$userid]->locked) {
                 $options[0] = get_string('nooutcome', 'grades');
                 $mform->addElement('static', 'outcome_' . $index . '[' . $userid . ']', $outcome->name . ':', $options[$outcome->grades[$userid]->grade]);
             } else {
                 $options[''] = get_string('nooutcome', 'grades');
                 $attributes = array('id' => 'menuoutcome_' . $index);
                 $mform->addElement('select', 'outcome_' . $index . '[' . $userid . ']', $outcome->name . ':', $options, $attributes);
                 $mform->setType('outcome_' . $index . '[' . $userid . ']', PARAM_INT);
                 $mform->setDefault('outcome_' . $index . '[' . $userid . ']', $outcome->grades[$userid]->grade);
             }
         }
     }
     $capabilitylist = array('gradereport/grader:view', 'moodle/grade:viewall');
     if (has_all_capabilities($capabilitylist, $this->get_course_context())) {
         $urlparams = array('id' => $this->get_course()->id);
         $url = new moodle_url('/grade/report/grader/index.php', $urlparams);
         $usergrade = '-';
         if (isset($gradinginfo->items[0]->grades[$userid]->str_grade)) {
             $usergrade = $gradinginfo->items[0]->grades[$userid]->str_grade;
         }
         $gradestring = $this->get_renderer()->action_link($url, $usergrade);
     } else {
         $usergrade = '-';
         if (isset($gradinginfo->items[0]->grades[$userid]) && !$gradinginfo->items[0]->grades[$userid]->hidden) {
             $usergrade = $gradinginfo->items[0]->grades[$userid]->str_grade;
         }
         $gradestring = $usergrade;
     }
     if ($this->get_instance()->markingworkflow) {
         $states = $this->get_marking_workflow_states_for_current_user();
         $options = array('' => get_string('markingworkflowstatenotmarked', 'assign')) + $states;
         $mform->addElement('select', 'workflowstate', get_string('markingworkflowstate', 'assign'), $options);
         $mform->addHelpButton('workflowstate', 'markingworkflowstate', 'assign');
     }
     if ($this->get_instance()->markingallocation && has_capability('mod/assign:manageallocations', $this->context)) {
         $markers = get_users_by_capability($this->context, 'mod/assign:grade');
         $markerlist = array('' => get_string('choosemarker', 'assign'));
         foreach ($markers as $marker) {
             $markerlist[$marker->id] = fullname($marker);
         }
         $mform->addElement('select', 'allocatedmarker', get_string('allocatedmarker', 'assign'), $markerlist);
         $mform->addHelpButton('allocatedmarker', 'allocatedmarker', 'assign');
         $mform->disabledIf('allocatedmarker', 'workflowstate', 'eq', ASSIGN_MARKING_WORKFLOW_STATE_READYFORREVIEW);
         $mform->disabledIf('allocatedmarker', 'workflowstate', 'eq', ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW);
         $mform->disabledIf('allocatedmarker', 'workflowstate', 'eq', ASSIGN_MARKING_WORKFLOW_STATE_READYFORRELEASE);
         $mform->disabledIf('allocatedmarker', 'workflowstate', 'eq', ASSIGN_MARKING_WORKFLOW_STATE_RELEASED);
     }
     $mform->addElement('static', 'currentgrade', get_string('currentgrade', 'assign'), $gradestring);
     if (count($useridlist) > 1) {
         $strparams = array('current' => $rownum + 1, 'total' => count($useridlist));
         $name = get_string('outof', 'assign', $strparams);
         $mform->addElement('static', 'gradingstudent', get_string('gradingstudent', 'assign'), $name);
     }
     // Let feedback plugins add elements to the grading form.
     $this->add_plugin_grade_elements($grade, $mform, $data, $userid);
     // Hidden params.
     $mform->addElement('hidden', 'id', $this->get_course_module()->id);
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'rownum', $rownum);
     $mform->setType('rownum', PARAM_INT);
     $mform->setConstant('rownum', $rownum);
     $mform->addElement('hidden', 'useridlistid', $useridlistid);
     $mform->setType('useridlistid', PARAM_INT);
     $mform->addElement('hidden', 'attemptnumber', $attemptnumber);
     $mform->setType('attemptnumber', PARAM_INT);
     $mform->addElement('hidden', 'ajax', optional_param('ajax', 0, PARAM_INT));
     $mform->setType('ajax', PARAM_INT);
     if ($this->get_instance()->teamsubmission) {
         $mform->addElement('header', 'groupsubmissionsettings', get_string('groupsubmissionsettings', 'assign'));
         $mform->addElement('selectyesno', 'applytoall', get_string('applytoteam', 'assign'));
         $mform->setDefault('applytoall', 1);
     }
     // Do not show if we are editing a previous attempt.
     if ($attemptnumber == -1 && $this->get_instance()->attemptreopenmethod != ASSIGN_ATTEMPT_REOPEN_METHOD_NONE) {
         $mform->addElement('header', 'attemptsettings', get_string('attemptsettings', 'assign'));
         $attemptreopenmethod = get_string('attemptreopenmethod_' . $this->get_instance()->attemptreopenmethod, 'assign');
         $mform->addElement('static', 'attemptreopenmethod', get_string('attemptreopenmethod', 'assign'), $attemptreopenmethod);
         $attemptnumber = 0;
         if ($submission) {
             $attemptnumber = $submission->attemptnumber;
         }
         $maxattempts = $this->get_instance()->maxattempts;
         if ($maxattempts == ASSIGN_UNLIMITED_ATTEMPTS) {
             $maxattempts = get_string('unlimitedattempts', 'assign');
         }
         $mform->addelement('static', 'maxattemptslabel', get_string('maxattempts', 'assign'), $maxattempts);
         $mform->addelement('static', 'attemptnumberlabel', get_string('attemptnumber', 'assign'), $attemptnumber + 1);
         $ismanual = $this->get_instance()->attemptreopenmethod == ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL;
         $issubmission = !empty($submission);
         $isunlimited = $this->get_instance()->maxattempts == ASSIGN_UNLIMITED_ATTEMPTS;
         $islessthanmaxattempts = $issubmission && $submission->attemptnumber < $this->get_instance()->maxattempts - 1;
         if ($ismanual && (!$issubmission || $isunlimited || $islessthanmaxattempts)) {
             $mform->addElement('selectyesno', 'addattempt', get_string('addattempt', 'assign'));
             $mform->setDefault('addattempt', 0);
         }
     }
     $mform->addElement('hidden', 'action', 'submitgrade');
     $mform->setType('action', PARAM_ALPHA);
     $buttonarray = array();
     $name = get_string('savechanges', 'assign');
     $buttonarray[] = $mform->createElement('submit', 'savegrade', $name);
     if (!$last) {
         $name = get_string('savenext', 'assign');
         $buttonarray[] = $mform->createElement('submit', 'saveandshownext', $name);
     }
     $buttonarray[] = $mform->createElement('cancel', 'cancelbutton', get_string('cancel'));
     $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
     $mform->closeHeaderBefore('buttonar');
     $buttonarray = array();
     if ($rownum > 0) {
         $name = get_string('previous', 'assign');
         $buttonarray[] = $mform->createElement('submit', 'nosaveandprevious', $name);
     }
     if (!$last) {
         $name = get_string('nosavebutnext', 'assign');
         $buttonarray[] = $mform->createElement('submit', 'nosaveandnext', $name);
     }
     if (!empty($buttonarray)) {
         $mform->addGroup($buttonarray, 'navar', '', array(' '), false);
     }
     // The grading form does not work well with shortforms.
     $mform->setDisableShortforms();
 }
Exemplo n.º 21
0
 /**
  * Get the default setting for file submission plugin
  * @global stdClass $CFG
  * @global stdClass $COURSE
  * @param MoodleQuickForm $mform The form to add elements to
  * @return void
  */
 public function get_settings(MoodleQuickForm $mform)
 {
     global $CFG, $COURSE, $DB;
     $defaultmaxfilesubmissions = $this->get_config('maxfilesubmissions');
     if ($defaultmaxfilesubmissions === false) {
         $defaultmaxfilesubmissions = get_config('assignsubmission_pdf', 'maxfilesubmissions');
     }
     $defaultmaxsubmissionsizebytes = $this->get_config('maxsubmissionsizebytes');
     if ($defaultmaxsubmissionsizebytes === false) {
         $defaultmaxsubmissionsizebytes = get_config('assignsubmission_pdf', 'maxbytes');
     }
     $defaulttemplateid = $this->get_config('templateid');
     if ($defaulttemplateid === false) {
         $defaulttemplateid = 0;
     }
     $settings = array();
     $options = array();
     for ($i = 1; $i <= ASSIGNSUBMISSION_PDF_MAXFILES; $i++) {
         $options[$i] = $i;
     }
     $mform->addElement('select', 'assignsubmission_pdf_maxfiles', get_string('maxfilessubmission', 'assignsubmission_pdf'), $options);
     $mform->setDefault('assignsubmission_pdf_maxfiles', $defaultmaxfilesubmissions);
     $mform->disabledIf('assignsubmission_pdf_maxfiles', 'assignsubmission_pdf_enabled', 'eq', 0);
     $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes);
     $choices[0] = get_string('courseuploadlimit', 'assignsubmission_pdf') . ' (' . display_size($COURSE->maxbytes) . ')';
     $settings[] = array('type' => 'select', 'name' => 'maxsubmissionsizebytes', 'description' => get_string('maximumsubmissionsize', 'assignsubmission_file'), 'options' => $choices, 'default' => $defaultmaxsubmissionsizebytes);
     $mform->addElement('select', 'assignsubmission_pdf_maxsizebytes', get_string('maximumsubmissionsize', 'assignsubmission_file'), $choices);
     $mform->setDefault('assignsubmission_pdf_maxsizebytes', $defaultmaxsubmissionsizebytes);
     $mform->disabledIf('assignsubmission_pdf_maxsizebytes', 'assignsubmission_pdf_enabled', 'eq', 0);
     // Coversheet.
     $mform->addElement('filemanager', 'assignsubmission_pdf_coversheet', get_string('coversheet', 'assignsubmission_pdf'), null, array('subdirs' => 0, 'maxbytes' => $COURSE->maxbytes, 'maxfiles' => 1, 'accepted_types' => array('.pdf')));
     // Templates.
     $templates = array();
     $templates[0] = get_string('notemplate', 'assignsubmission_pdf');
     $templates_data = $DB->get_records_select_menu('assignsubmission_pdf_tmpl', 'courseid = 0 OR courseid = ?', array($COURSE->id), 'name', 'id, name');
     foreach ($templates_data as $templateid => $templatename) {
         $templates[$templateid] = $templatename;
     }
     $mform->addElement('select', 'assignsubmission_pdf_templateid', get_string('coversheettemplate', 'assignsubmission_pdf'), $templates);
     $mform->setDefault('assignsubmission_pdf_templateid', $defaulttemplateid);
     $edittemplateurl = new moodle_url('/mod/assign/submission/pdf/edittemplates.php', array('courseid' => $COURSE->id));
     $edittemplatelink = html_writer::link($edittemplateurl, get_string('edittemplates', 'assignsubmission_pdf'), array('target' => '_blank'));
     $mform->addElement('static', 'assignsubmission_pdf_template_edit', '', $edittemplatelink);
 }
 /**
  * Add an settings element to the form. It is enabled only if the strategy it belongs to is selected.
  * @param string $stratfieldid id of the element to be added
  * @param array $value array with the element type and its caption 
  *        (usually returned by the strategys get settingsfields methods).
  * @param string $curr_strategyid id of the strategy it belongs to
  * @param string $default default value for the element
  */
 private function add_settings_field($stratfieldid, array $value, $strategyid, MoodleQuickForm $mform, $default = null)
 {
     $attributes = array('size' => '20');
     if (isset($value[3])) {
         $attributes['placeholder'] = $value[3];
     }
     if ($value[0] == "text") {
         $mform->addElement('text', $stratfieldid, $value[1], $attributes);
         $mform->setType($stratfieldid, PARAM_TEXT);
     } else {
         if ($value[0] == "int") {
             $mform->addElement('text', $stratfieldid, $value[1], $attributes);
             $mform->setType($stratfieldid, PARAM_TEXT);
             $mform->addRule($stratfieldid, null, 'numeric');
             // TODO: Only validate if not disabled.
         }
     }
     if (isset($value[2])) {
         $mform->setDefault($stratfieldid, $value[2]);
     }
     $mform->disabledIf($stratfieldid, 'strategy', 'neq', $strategyid);
 }
Exemplo n.º 23
0
 /**
  * Add elements to the edit instance form.
  *
  * @param stdClass $instance
  * @param MoodleQuickForm $mform
  * @param context $context
  * @return bool
  */
 public function edit_instance_form($instance, MoodleQuickForm $mform, $context)
 {
     $options = $this->get_status_options();
     $mform->addElement('select', 'status', get_string('status', 'enrol_manual'), $options);
     $mform->addHelpButton('status', 'status', 'enrol_manual');
     $mform->setDefault('status', $this->get_config('status'));
     $roles = $this->get_roleid_options($instance, $context);
     $mform->addElement('select', 'roleid', get_string('defaultrole', 'role'), $roles);
     $mform->setDefault('roleid', $this->get_config('roleid'));
     $options = array('optional' => true, 'defaultunit' => 86400);
     $mform->addElement('duration', 'enrolperiod', get_string('defaultperiod', 'enrol_manual'), $options);
     $mform->setDefault('enrolperiod', $this->get_config('enrolperiod'));
     $mform->addHelpButton('enrolperiod', 'defaultperiod', 'enrol_manual');
     $options = $this->get_expirynotify_options();
     $mform->addElement('select', 'expirynotify', get_string('expirynotify', 'core_enrol'), $options);
     $mform->addHelpButton('expirynotify', 'expirynotify', 'core_enrol');
     $options = array('optional' => false, 'defaultunit' => 86400);
     $mform->addElement('duration', 'expirythreshold', get_string('expirythreshold', 'core_enrol'), $options);
     $mform->addHelpButton('expirythreshold', 'expirythreshold', 'core_enrol');
     $mform->disabledIf('expirythreshold', 'expirynotify', 'eq', 0);
     if (enrol_accessing_via_instance($instance)) {
         $warntext = get_string('instanceeditselfwarningtext', 'core_enrol');
         $mform->addElement('static', 'selfwarn', get_string('instanceeditselfwarning', 'core_enrol'), $warntext);
     }
 }
Exemplo n.º 24
0
 /**
  * Get the settings for Onbline PoodLLsubmission plugin form
  *
  * @global stdClass $CFG
  * @global stdClass $COURSE
  * @param MoodleQuickForm $mform The form to add elements to
  * @return void
  */
 public function get_settings(MoodleQuickForm $mform)
 {
     global $CFG, $COURSE;
     $recordertype = $this->get_config('recordertype');
     $boardsize = $this->get_config('boardsize');
     $backimage = $this->get_config('backimage');
     $timelimit = $this->get_config('timelimit');
     //get allowed recorders from admin settings
     $allowed_recorders = get_config('assignsubmission_onlinepoodll', 'allowedrecorders');
     $allowed_recorders = explode(',', $allowed_recorders);
     $recorderoptions = array();
     if (array_search(OP_REPLYMP3VOICE, $allowed_recorders) !== false) {
         $recorderoptions[OP_REPLYMP3VOICE] = get_string("replymp3voice", "assignsubmission_onlinepoodll");
     }
     if (array_search(OP_REPLYVOICE, $allowed_recorders) !== false) {
         $recorderoptions[OP_REPLYVOICE] = get_string("replyvoice", "assignsubmission_onlinepoodll");
     }
     if (array_search(OP_REPLYVIDEO, $allowed_recorders) !== false) {
         $recorderoptions[OP_REPLYVIDEO] = get_string("replyvideo", "assignsubmission_onlinepoodll");
     }
     if (array_search(OP_REPLYWHITEBOARD, $allowed_recorders) !== false) {
         $recorderoptions[OP_REPLYWHITEBOARD] = get_string("replywhiteboard", "assignsubmission_onlinepoodll");
     }
     if (array_search(OP_REPLYSNAPSHOT, $allowed_recorders) !== false) {
         $recorderoptions[OP_REPLYSNAPSHOT] = get_string("replysnapshot", "assignsubmission_onlinepoodll");
     }
     /*
             $recorderoptions = array( OP_REPLYMP3VOICE => get_string("replymp3voice", "assignsubmission_onlinepoodll"), 
     			OP_REPLYVOICE => get_string("replyvoice", "assignsubmission_onlinepoodll"), 
     			OP_REPLYVIDEO => get_string("replyvideo", "assignsubmission_onlinepoodll"),
     			OP_REPLYWHITEBOARD => get_string("replywhiteboard", "assignsubmission_onlinepoodll"),
     			OP_REPLYSNAPSHOT => get_string("replysnapshot", "assignsubmission_onlinepoodll"));
     */
     //we don't support talkback yet
     //OP_REPLYTALKBACK => get_string("replytalkback", "assignsubmission_onlinepoodll"));
     $mform->addElement('select', 'assignsubmission_onlinepoodll_recordertype', get_string("recordertype", "assignsubmission_onlinepoodll"), $recorderoptions);
     //$mform->addHelpButton('assignsubmission_onlinepoodll_recordertype', get_string('onlinepoodll', ASSIGNSUBMISSION_ONLINEPOODLL_COMPONENT), ASSIGNSUBMISSION_ONLINEPOODLL_COMPONENT);
     $mform->setDefault('assignsubmission_onlinepoodll_recordertype', $recordertype);
     $mform->disabledIf('assignsubmission_onlinepoodll_recordertype', 'assignsubmission_onlinepoodll_enabled', 'eq', 0);
     //Add a place to set a maximum recording time.
     $mform->addElement('duration', 'assignsubmission_onlinepoodll_timelimit', get_string('timelimit', 'assignsubmission_onlinepoodll'));
     $mform->setDefault('assignsubmission_onlinepoodll_timelimit', $timelimit);
     $mform->disabledIf('assignsubmission_onlinepoodll_timelimit', 'assignsubmission_onlinepoodll_enabled', 'eq', 0);
     $mform->disabledIf('assignsubmission_onlinepoodll_timelimit', 'assignsubmission_onlinepoodll_recordertype', 'eq', OP_REPLYWHITEBOARD);
     $mform->disabledIf('assignsubmission_onlinepoodll_timelimit', 'assignsubmission_onlinepoodll_recordertype', 'eq', OP_REPLYSNAPSHOT);
     //these are for the whiteboard submission
     // added Justin 20121216 back image, and boardsizes, part of whiteboard response
     //For the back image, we
     //(i) first have to load existing back image files into a draft area
     // (ii) add a file manager element
     //(iii) set the draft area info as the "default" value for the file manager
     if (array_search(OP_REPLYWHITEBOARD, $allowed_recorders) !== false) {
         $itemid = 0;
         $draftitemid = file_get_submitted_draft_itemid(ASSIGNSUBMISSION_ONLINEPOODLL_WB_FILEAREA);
         $context = $this->assignment->get_context();
         if ($context) {
             $contextid = $context->id;
         } else {
             $contextid = 0;
         }
         file_prepare_draft_area($draftitemid, $contextid, ASSIGNSUBMISSION_ONLINEPOODLL_CONFIG_COMPONENT, ASSIGNSUBMISSION_ONLINEPOODLL_WB_FILEAREA, $itemid, array('subdirs' => 0, 'maxbytes' => 0, 'maxfiles' => 1));
         $mform->addElement('filemanager', 'backimage', get_string('backimage', 'assignsubmission_onlinepoodll'), null, array('subdirs' => 0, 'maxbytes' => 0, 'maxfiles' => 1));
         $mform->setDefault('backimage', $backimage);
         //commented 20130120 bcause was broken with moodle 2.6. Errors saying "must attach no more than one file" when tried to save, empty, disabled
         //$mform->disabledIf('backimage', 'assignsubmission_onlinepoodll_enabled', 'eq', 0);
         //$mform->disabledIf('backimage', 'assignsubmission_onlinepoodll_recordertype', 'ne', OP_REPLYWHITEBOARD );
     } else {
         $mform->addElement('hidden', 'backimage', $backimage);
     }
     //board sizes
     if (array_search(OP_REPLYWHITEBOARD, $allowed_recorders) !== false) {
         $boardsizes = array('320x320' => '320x320', '400x600' => '400x600', '500x500' => '500x500', '600x400' => '600x400', '600x800' => '600x800', '800x600' => '800x600');
         $mform->addElement('select', 'assignsubmission_onlinepoodll_boardsize', get_string('boardsize', 'assignsubmission_onlinepoodll'), $boardsizes);
         $mform->setDefault('assignsubmission_onlinepoodll_boardsize', $boardsize);
         $mform->disabledIf('assignsubmission_onlinepoodll_boardsize', 'assignsubmission_onlinepoodll_enabled', 'eq', 0);
         $mform->disabledIf('assignsubmission_onlinepoodll_boardsize', 'assignsubmission_onlinepoodll_recordertype', 'ne', OP_REPLYWHITEBOARD);
     } else {
         $mform->addElement('hidden', 'assignsubmission_onlinepoodll_boardsize', $boardsize);
     }
 }
Exemplo n.º 25
0
 /**
  * Add elements to the edit instance form.
  *
  * @param stdClass $instance
  * @param MoodleQuickForm $mform
  * @param context $context
  * @return bool
  */
 public function edit_instance_form($instance, MoodleQuickForm $mform, $context)
 {
     global $CFG;
     // Merge these two settings to one value for the single selection element.
     if ($instance->notifyall and $instance->expirynotify) {
         $instance->expirynotify = 2;
     }
     unset($instance->notifyall);
     $nameattribs = array('size' => '20', 'maxlength' => '255');
     $mform->addElement('text', 'name', get_string('custominstancename', 'enrol'), $nameattribs);
     $mform->setType('name', PARAM_TEXT);
     $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'server');
     $options = $this->get_status_options();
     $mform->addElement('select', 'status', get_string('status', 'enrol_self'), $options);
     $mform->addHelpButton('status', 'status', 'enrol_self');
     $options = $this->get_newenrols_options();
     $mform->addElement('select', 'customint6', get_string('newenrols', 'enrol_self'), $options);
     $mform->addHelpButton('customint6', 'newenrols', 'enrol_self');
     $mform->disabledIf('customint6', 'status', 'eq', ENROL_INSTANCE_DISABLED);
     $passattribs = array('size' => '20', 'maxlength' => '50');
     $mform->addElement('passwordunmask', 'password', get_string('password', 'enrol_self'), $passattribs);
     $mform->addHelpButton('password', 'password', 'enrol_self');
     if (empty($instance->id) and $this->get_config('requirepassword')) {
         $mform->addRule('password', get_string('required'), 'required', null, 'client');
     }
     $mform->addRule('password', get_string('maximumchars', '', 50), 'maxlength', 50, 'server');
     $options = $this->get_groupkey_options();
     $mform->addElement('select', 'customint1', get_string('groupkey', 'enrol_self'), $options);
     $mform->addHelpButton('customint1', 'groupkey', 'enrol_self');
     $roles = $this->extend_assignable_roles($context, $instance->roleid);
     $mform->addElement('select', 'roleid', get_string('role', 'enrol_self'), $roles);
     $options = array('optional' => true, 'defaultunit' => 86400);
     $mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'enrol_self'), $options);
     $mform->addHelpButton('enrolperiod', 'enrolperiod', 'enrol_self');
     $options = $this->get_expirynotify_options();
     $mform->addElement('select', 'expirynotify', get_string('expirynotify', 'core_enrol'), $options);
     $mform->addHelpButton('expirynotify', 'expirynotify', 'core_enrol');
     $options = array('optional' => false, 'defaultunit' => 86400);
     $mform->addElement('duration', 'expirythreshold', get_string('expirythreshold', 'core_enrol'), $options);
     $mform->addHelpButton('expirythreshold', 'expirythreshold', 'core_enrol');
     $mform->disabledIf('expirythreshold', 'expirynotify', 'eq', 0);
     $options = array('optional' => true);
     $mform->addElement('date_time_selector', 'enrolstartdate', get_string('enrolstartdate', 'enrol_self'), $options);
     $mform->setDefault('enrolstartdate', 0);
     $mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'enrol_self');
     $options = array('optional' => true);
     $mform->addElement('date_time_selector', 'enrolenddate', get_string('enrolenddate', 'enrol_self'), $options);
     $mform->setDefault('enrolenddate', 0);
     $mform->addHelpButton('enrolenddate', 'enrolenddate', 'enrol_self');
     $options = $this->get_longtimenosee_options();
     $mform->addElement('select', 'customint2', get_string('longtimenosee', 'enrol_self'), $options);
     $mform->addHelpButton('customint2', 'longtimenosee', 'enrol_self');
     $mform->addElement('text', 'customint3', get_string('maxenrolled', 'enrol_self'));
     $mform->addHelpButton('customint3', 'maxenrolled', 'enrol_self');
     $mform->setType('customint3', PARAM_INT);
     require_once $CFG->dirroot . '/cohort/lib.php';
     $cohorts = array(0 => get_string('no'));
     $allcohorts = cohort_get_available_cohorts($context, 0, 0, 0);
     if ($instance->customint5 && !isset($allcohorts[$instance->customint5])) {
         $c = $DB->get_record('cohort', array('id' => $instance->customint5), 'id, name, idnumber, contextid, visible', IGNORE_MISSING);
         if ($c) {
             // Current cohort was not found because current user can not see it. Still keep it.
             $allcohorts[$instance->customint5] = $c;
         }
     }
     foreach ($allcohorts as $c) {
         $cohorts[$c->id] = format_string($c->name, true, array('context' => context::instance_by_id($c->contextid)));
         if ($c->idnumber) {
             $cohorts[$c->id] .= ' [' . s($c->idnumber) . ']';
         }
     }
     if ($instance->customint5 && !isset($allcohorts[$instance->customint5])) {
         // Somebody deleted a cohort, better keep the wrong value so that random ppl can not enrol.
         $cohorts[$instance->customint5] = get_string('unknowncohort', 'cohort', $instance->customint5);
     }
     if (count($cohorts) > 1) {
         $mform->addElement('select', 'customint5', get_string('cohortonly', 'enrol_self'), $cohorts);
         $mform->addHelpButton('customint5', 'cohortonly', 'enrol_self');
     } else {
         $mform->addElement('hidden', 'customint5');
         $mform->setType('customint5', PARAM_INT);
         $mform->setConstant('customint5', 0);
     }
     $mform->addElement('advcheckbox', 'customint4', get_string('sendcoursewelcomemessage', 'enrol_self'));
     $mform->addHelpButton('customint4', 'sendcoursewelcomemessage', 'enrol_self');
     $options = array('cols' => '60', 'rows' => '8');
     $mform->addElement('textarea', 'customtext1', get_string('customwelcomemessage', 'enrol_self'), $options);
     $mform->addHelpButton('customtext1', 'customwelcomemessage', 'enrol_self');
     if (enrol_accessing_via_instance($instance)) {
         $warntext = get_string('instanceeditselfwarningtext', 'core_enrol');
         $mform->addElement('static', 'selfwarn', get_string('instanceeditselfwarning', 'core_enrol'), $warntext);
     }
 }
 /**
  * Get the settings form for Mahara submission plugin
  *
  * @global stdClass $CFG
  * @global stdClass $DB
  * @param MoodleQuickForm $mform The form to add elements to
  * @return void
  */
 public function get_settings(MoodleQuickForm $mform)
 {
     global $CFG;
     require_once $CFG->dirroot . '/mod/assign/submission/mahara/lib.php';
     if ($hosts = assignsubmission_mahara_sitelist()) {
         $hostid = $this->get_config('mnethostid');
         if ($hostid === false) {
             // No setting for this instance, so use the sitewide default
             $hostid = get_config('assignsubmission_mahara', 'host');
         }
         $locked = $this->get_config('lock');
         if ($locked === false) {
             // No setting for this instance, so use the sitewide default
             $locked = get_config('assignsubmission_mahara', 'lock');
         }
         // Menu to select which MNet host
         $mform->addElement('select', 'assignsubmission_mahara_mnethostid', get_string('site', 'assignsubmission_mahara'), $hosts);
         $mform->setDefault('assignsubmission_mahara_mnethostid', $hostid);
         $mform->disabledIf('assignsubmission_mahara_mnethostid', 'assignsubmission_mahara_enabled', 'notchecked');
         // Menu to select whether to lock Mahara pages or not
         $locksettings = array(ASSIGNSUBMISSION_MAHARA_SETTING_DONTLOCK => new lang_string('no'), ASSIGNSUBMISSION_MAHARA_SETTING_KEEPLOCKED => new lang_string('yeskeeplocked', 'assignsubmission_mahara'), ASSIGNSUBMISSION_MAHARA_SETTING_UNLOCK => new lang_string('yesunlock', 'assignsubmission_mahara'));
         $mform->addElement('select', 'assignsubmission_mahara_lockpages', get_string('lockpages', 'assignsubmission_mahara'), $locksettings);
         $mform->setDefault('assignsubmission_mahara_lockpages', $locked);
         $mform->addHelpButton('assignsubmission_mahara_lockpages', 'lockpages', 'assignsubmission_mahara');
         $mform->disabledIf('assignsubmission_mahara_lockpages', 'assignsubmission_mahara_enabled', 'notchecked');
     } else {
         // No hosts found.
         $mform->addElement('static', 'assignsubmission_mahara_mnethostid', get_string('site', 'assignsubmission_mahara'), get_string('nomaharahostsfound', 'assignsubmission_mahara'));
         $mform->updateElementAttr('assignsubmission_mahara_enabled', array('disabled' => true));
     }
     $mform->addHelpButton('assignsubmission_mahara_mnethostid', 'site', 'assignsubmission_mahara');
 }