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);
 }
Exemplo n.º 2
0
 /**
  * Add question-type specific form fields.
  *
  * @param MoodleQuickForm $mform the form being built.
  */
 function definition_inner(&$mform)
 {
     //don't need these default elements :
     $mform->removeElement('defaultgrade');
     $mform->removeElement('penalty');
     $mform->addElement('hidden', 'defaultgrade', 0);
 }
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
 /**
  * Add autocomplete to a form text field
  *
  * @param MoodleQuickForm $mform Moodle form
  * @param array|moodle_url $options Array of autocomplete options, if $hiddenfieldname is
  *                       passed, array indexes are considered record IDs
  * @param string $textfieldname The text field's name
  * @param string $hiddenfieldname The hidden field's name.  If passed,
  *                                the option index will be set to this hidden
  *                                value when its option value is selected in
  *                                the text field
  * @param string $width The pixel width of the text field (Due to YUI, must
  *                      use width instead of size)
  * @return void
  * @link http://developer.yahoo.com/yui/examples/autocomplete/ac_basic_array.html What you get with no $hiddenfieldname
  * @link http://developer.yahoo.com/yui/examples/autocomplete/ac_itemselect.html What you get with $hiddenfieldname
  */
 public function mform_autocomplete($mform, $options, $textfieldname, $hiddenfieldname = '', $width = '300')
 {
     global $PAGE;
     $url = NULL;
     $data = NULL;
     // Generate data source
     if ($options instanceof moodle_url) {
         $url = $options->out(false);
     } else {
         $data = array();
         foreach ($options as $optionid => $option) {
             if (empty($hiddenfieldname)) {
                 $data[] = $option;
             } else {
                 $data[] = (object) array('text' => $option, 'id' => $optionid);
             }
         }
     }
     $fields = array('text');
     if (!empty($hiddenfieldname)) {
         $fields[] = 'id';
     }
     $module = array('name' => 'local_mr_framework', 'fullpath' => '/local/mr/framework/assets/javascript.js', 'requires' => array('yui2-yahoo', 'yui2-dom', 'yui2-event', 'yui2-datasource', 'yui2-json', 'yui2-connection', 'yui2-get', 'yui2-animation', 'yui2-autocomplete'));
     $arguments = array((object) array('fieldname' => $textfieldname, 'hiddenfieldname' => $hiddenfieldname, 'width' => $width, 'url' => $url, 'data' => $data, 'fields' => $fields));
     $PAGE->requires->js_init_call('M.local_mr.init_mr_html_autocomplete', $arguments, true, $module);
     // $PAGE->requires->css('/lib/yui/2.8.1/build/autocomplete/assets/autocomplete-core.css');
     // $PAGE->requires->css('/lib/yui/2.8.1/build/autocomplete/assets/skins/sam/autocomplete.css');
     // Update form - need to force some attributes and add the javascript
     $mform->updateElementAttr($textfieldname, array('autocomplete' => 'off', 'style' => "width: {$width}px;"));
     // Add ID to hidden field so javascript can find it
     if (!empty($hiddenfieldname)) {
         $mform->updateElementAttr($hiddenfieldname, array('id' => "id_{$hiddenfieldname}"));
     }
 }
 /**
  * @param MoodleQuickForm $mform
  */
 protected function specific_definition(MoodleQuickForm $mform)
 {
     $mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
     $options = ['tree' => get_string('config_type_tree', 'block_activity_tree'), 'prev_next' => get_string('config_type_prev_next', 'block_activity_tree')];
     $mform->addElement('select', 'config_type', get_string('config_type', 'block_activity_tree'), $options);
     $mform->setDefault('config_type', 'tree');
 }
Exemplo n.º 6
0
 /**
  * Add question-type specific form fields.
  *
  * @param MoodleQuickForm $mform the form being built.
  */
 protected function definition_inner($mform)
 {
     // We don't need this default element.
     $mform->removeElement('defaultmark');
     $mform->addElement('hidden', 'defaultmark', 0);
     $mform->setType('defaultmark', PARAM_RAW);
 }
Exemplo n.º 7
0
 /**
  * Get form elements for grading form
  *
  * @param stdClass $grade
  * @param MoodleQuickForm $mform
  * @param stdClass $data
  * @return bool true if elements were added to the form
  */
 public function get_form_elements($grade, MoodleQuickForm $mform, stdClass $data)
 {
     $fileoptions = $this->get_file_options();
     $gradeid = $grade ? $grade->id : 0;
     $data = file_prepare_standard_filemanager($data, 'files', $fileoptions, $this->assignment->get_context(), 'assignfeedback_file', ASSIGNFEEDBACK_FILE_FILEAREA, $gradeid);
     $mform->addElement('filemanager', 'files_filemanager', '', null, $fileoptions);
     return true;
 }
Exemplo n.º 8
0
 protected function other_preference_fields(MoodleQuickForm $mform) {
     if (quiz_has_grades($this->_customdata['quiz'])) {
         $mform->addElement('selectyesno', 'slotmarks',
                 get_string('showdetailedmarks', 'quiz_overview'));
     } else {
         $mform->addElement('hidden', 'slotmarks', 0);
     }
 }
Exemplo n.º 9
0
 public function add_preflight_check_form_fields(mod_quiz_preflight_check_form $quizform, MoodleQuickForm $mform, $attemptid)
 {
     $mform->addElement('header', 'passwordheader', get_string('password'));
     $mform->addElement('static', 'passwordmessage', '', get_string('requirepasswordmessage', 'quizaccess_password'));
     // Don't use the 'proper' field name of 'password' since that get's
     // Firefox's password auto-complete over-excited.
     $mform->addElement('password', 'quizpassword', get_string('quizpassword', 'quizaccess_password'), array('autofocus' => 'true'));
 }
Exemplo n.º 10
0
 /**
  * @param MoodleQuickForm $mform
  */
 function add_submit_buttons($mform)
 {
     $buttons = array();
     $buttons[] =& $mform->createElement('submit', 'submitbutton', get_string('filter', 'local_mr'));
     $buttons[] =& $mform->createElement('submit', 'resetbutton', get_string('reset', 'local_mr'));
     $mform->addGroup($buttons, 'buttons', '', array(' '), false);
     $mform->registerNoSubmitButton('reset');
 }
Exemplo n.º 11
0
 /**
  * Extends the standard instance config form with custom
  * fields for moodletxt specifically
  * @param MoodleQuickForm $form Form to extend
  * @version 2011072201
  * @since 2011072201
  */
 protected function specific_definition($form)
 {
     // Section header title according to language file.
     $form->addElement('header', 'configheader', get_string('headerinstanceconfig', 'block_moodletxt'));
     // The title of the block
     $form->addElement('text', 'config_title', get_string('labelblocktitle', 'block_moodletxt'));
     $form->setDefault('config_title', get_string('blocktitle', 'block_moodletxt'));
     $form->setType('config_title', PARAM_MULTILANG);
 }
 /**
  * Create the form element used to define the weight of the cell
  * 
  * @param MoodleQuickForm   $form
  * @param int $row          row number
  * @param int $col          column number
  * @return object
  */
 public function create_cell_element($form, $row, $col, $multiple)
 {
     $cell_name = $this->cell_name($row, $col, $multiple);
     if ($multiple) {
         return $form->createElement('checkbox', $cell_name, 'label');
     } else {
         return $form->createElement('radio', $cell_name, '', '', $col);
     }
 }
Exemplo n.º 13
0
 /**
  * @param MoodleQuickForm $mform
  */
 protected function specific_definition($mform)
 {
     // Section header title according to language file.
     $mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
     // A sample string variable with a default value.
     $mform->addElement('text', 'config_text', get_string('blockstring', 'block_simplehtml'));
     $mform->setDefault('config_text', 'default value');
     $mform->setType('config_text', PARAM_RAW);
 }
 /**
  * Add question-type specific form fields.
  *
  * @param MoodleQuickForm $mform the form being built.
  */
 function definition_inner(&$mform)
 {
     $menu = array(get_string('caseno', 'quiz'), get_string('caseyes', 'quiz'));
     $mform->addElement('select', 'usecase', get_string('casesensitive', 'quiz'), $menu);
     $mform->addElement('static', 'answersinstruct', get_string('correctanswers', 'quiz'), get_string('filloutoneanswer', 'quiz'));
     $mform->closeHeaderBefore('answersinstruct');
     $creategrades = get_grade_options();
     $this->add_per_answer_fields($mform, get_string('answerno', 'qtype_shortanswer', '{no}'), $creategrades->gradeoptions);
 }
Exemplo n.º 15
0
 public function add_to_moodleform_testinput(MoodleQuickForm $mform)
 {
     $values = $this->get_choices();
     if (empty($values)) {
         $mform->addElement('static', $this->name, stack_string('ddl_empty'));
     } else {
         $mform->addElement('select', $this->name, $this->name, $values);
     }
 }
 /**
  * Builds the form to edit instance settings
  *
  * @param MoodleQuickForm $mform
  */
 protected function specific_definition($mform)
 {
     // Section header title according to language file.
     $mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
     // Set the title for the block.
     $mform->addElement('text', 'config_title', get_string('configtitle', 'block_filtered_course_list'));
     $mform->setDefault('config_title', get_string('blockname', 'block_filtered_course_list'));
     $mform->setType('config_title', PARAM_TEXT);
 }
Exemplo n.º 17
0
 /**
  * Get form elements for the grading page
  *
  * @param stdClass|null $grade
  * @param MoodleQuickForm $mform
  * @param stdClass $data
  * @return bool true if elements were added to the form
  */
 public function get_form_elements($grade, MoodleQuickForm $mform, stdClass $data)
 {
     $choices = get_string_manager()->get_list_of_countries();
     $choices = array('' => get_string('selectacountry') . '...') + $choices;
     $mform->addElement('select', 'country', 'Country for E-signature', $choices);
     $mform->addElement('static', 'description', '', get_string('savechanges', 'assignfeedback_esign'));
     $mform->setDefault('country', 'SE');
     $mform->addRule('country', get_string('selectacountry'), 'required', '', 'client', false, false);
     return true;
 }
Exemplo n.º 18
0
 /**
  * Add the form elements for the filter to the supplied form.
  *
  * @param   MoodleQuickForm $mform      The form to add filter settings to.
  */
 public static function add_filter_to_form(\MoodleQuickForm &$mform)
 {
     $options = [static::ANYVALUE => get_string('all')];
     $options += static::get_filter_options();
     $filtername = static::get_filter_name();
     $key = "filter_{$filtername}";
     $mform->addElement('select', $key, get_string($key, 'tool_usertours'), $options, ['multiple' => true]);
     $mform->setDefault($key, static::ANYVALUE);
     $mform->addHelpButton($key, $key, 'tool_usertours');
 }
 /**
  * Add question-type specific form fields.
  *
  * @param MoodleQuickForm $mform the form being built.
  */
 function definition_inner(&$mform)
 {
     $menu = array(get_string('caseno', 'quiz'), get_string('caseyes', 'quiz'));
     $mform->addElement('select', 'usecase', get_string('casesensitive', 'quiz'), $menu);
     $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_shortanswer', '{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 = QUESTION_NUMANS_START > $countanswers + QUESTION_NUMANS_ADD ? QUESTION_NUMANS_START : $countanswers + 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', QUESTION_NUMANS_ADD, get_string('addmoreanswerblanks', 'qtype_shortanswer'));
 }
Exemplo n.º 20
0
 /**
  * Add question-type specific form fields.
  *
  * @param MoodleQuickForm $mform the form being built.
  */
 function definition_inner(&$mform)
 {
     $mform->removeElement('image');
     $questionstoselect = array();
     for ($i = 2; $i <= QUESTION_NUMANS; $i++) {
         $questionstoselect[$i] = $i;
     }
     $mform->addElement('select', 'choose', get_string("randomsamatchnumber", "quiz"), $questionstoselect);
     $mform->setType('feedback', PARAM_RAW);
     $mform->addElement('hidden', 'fraction', 0);
 }
Exemplo n.º 21
0
    /**
     * Get form elements for the grading page
     *
     * @param stdClass|null $grade
     * @param MoodleQuickForm $mform
     * @param stdClass $data
     * @return bool true if elements were added to the form
     */
    public function get_form_elements($grade, MoodleQuickForm $mform, stdClass $data) {
        if ($grade) {
            $feedbackcomments = $this->get_feedback_comments($grade->id);
            if ($feedbackcomments) {
                $data->assignfeedbackcomments_editor['text'] = $feedbackcomments->commenttext;
                $data->assignfeedbackcomments_editor['format'] = $feedbackcomments->commentformat;
            }
        }

        $mform->addElement('editor', 'assignfeedbackcomments_editor', '', null, null);
        return true;
    }
 /**
  * Adds the fields for showing the Venn diagram where teacher can define the areas of correct answer.
  * 
  * @param MoodleQuickForm $mform 
  */
 protected function add_vd_fields($mform)
 {
     $vd = new qtype_vdmarker_vd3("correct_answer_vd");
     $vd->readonly = false;
     if (isset($this->question->options)) {
         $state = $this->question->options->vd_correctanswer;
     } else {
         $state = 0;
     }
     $vd->set_state($state);
     $vd->fieldtoupdate = 'vd_correctanswer';
     $mform->addElement('hidden', $vd->fieldtoupdate, $vd->get_state(), 'id="' . str_replace(':', '_', $vd->fieldtoupdate) . '"');
     $mform->addElement('static', 'diagram', get_string('correct_answer', 'qtype_vdmarker'), $vd->render());
     unset($vd);
 }
Exemplo n.º 23
0
    protected function definition_inner(MoodleQuickForm $mform) {
        if ($this->_customdata['qmsubselect']) {
            $mform->addElement($this->create_qmfilter_checkbox($mform));
        }

        $colsgroup = array();
        $colsgroup[] = $mform->createElement('advcheckbox', 'qtext', '',
                get_string('summaryofquestiontext', 'quiz_responses'));
        $colsgroup[] = $mform->createElement('advcheckbox', 'resp', '',
                get_string('summaryofresponse', 'quiz_responses'));
        $colsgroup[] = $mform->createElement('advcheckbox', 'right', '',
                get_string('summaryofrightanswer', 'quiz_responses'));
        $mform->addGroup($colsgroup, null,
                get_string('include', 'quiz_responses'), '<br />', false);
    }
Exemplo n.º 24
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.º 25
0
 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $course = $this->_customdata['course'];
     $cm = $this->_customdata['cm'];
     $modcontext = $this->_customdata['modcontext'];
     $ids = $this->_customdata['ids'];
     $mform->addElement('header', 'general', get_string('changeduration', 'attforblock'));
     $mform->addElement('static', 'count', get_string('countofselected', 'attforblock'), count(explode('_', $ids)));
     for ($i = 0; $i <= 23; $i++) {
         $hours[$i] = sprintf("%02d", $i);
     }
     for ($i = 0; $i < 60; $i += 5) {
         $minutes[$i] = sprintf("%02d", $i);
     }
     $durselect[] =& MoodleQuickForm::createElement('select', 'hours', '', $hours);
     $durselect[] =& MoodleQuickForm::createElement('select', 'minutes', '', $minutes, false, true);
     $mform->addGroup($durselect, 'durtime', get_string('newduration', 'attforblock'), array(' '), true);
     $mform->addElement('hidden', 'ids', $ids);
     $mform->addElement('hidden', 'id', $cm->id);
     $mform->addElement('hidden', 'action', att_sessions_page_params::ACTION_CHANGE_DURATION);
     $mform->setDefaults(array('durtime' => array('hours' => 0, 'minutes' => 0)));
     //-------------------------------------------------------------------------------
     // buttons
     $submit_string = get_string('update', 'attforblock');
     $this->add_action_buttons(true, $submit_string);
     //        $mform->addElement('hidden', 'id', $cm->id);
     //        $mform->addElement('hidden', 'sessionid', $sessionid);
     //        $mform->addElement('hidden', 'action', 'changeduration');
 }
Exemplo n.º 26
0
 function _createElements()
 {
     global $COURSE;
     $this->_elements = array();
     if (!is_array($this->getAttributes()) || !array_key_exists('size', $this->getAttributes())) {
         $this->updateAttributes(array('size' => 48));
     }
     $this->_elements[0] =& MoodleQuickForm::createElement('text', 'value', '', $this->getAttributes());
     $this->_elements[1] =& MoodleQuickForm::createElement('button', 'popup', get_string('chooseafile', 'resource') . ' ...');
     $button =& $this->_elements[1];
     if ($this->_options['courseid'] !== null) {
         $courseid = $this->_options['courseid'];
     } else {
         $courseid = $COURSE->id;
     }
     // first find out the text field id - this is a bit hacky, is there a better way?
     $choose = 'id_' . str_replace(array('[', ']'), array('_', ''), $this->getElementName(0));
     $url = "/files/index.php?id={$courseid}&choose=" . $choose;
     if ($this->_options['options'] == 'none') {
         $options = 'menubar=0,location=0,scrollbars,resizable,width=' . $this->_options['width'] . ',height=' . $this->_options['height'];
     } else {
         $options = $this->_options['options'];
     }
     $fullscreen = 0;
     $buttonattributes = array('title' => get_string("chooseafile", "resource"), 'onclick' => "return openpopup('{$url}', '" . $button->getName() . "', '{$options}', {$fullscreen});");
     $button->updateAttributes($buttonattributes);
 }
Exemplo n.º 27
0
    /**
     * 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', html_writer::tag('span', $this->get_name(),
            array('class' => 'accesshide')), null, $editoroptions);

        return true;
    }
Exemplo n.º 28
0
 function definition()
 {
     global $CFG, $CHOICE_SHOWRESULTS, $CHOICE_PUBLISH, $CHOICE_DISPLAY, $DB;
     $mform =& $this->_form;
     //-------------------------------------------------------------------------------
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('text', 'name', get_string('choicename', 'choice'), array('size' => '64'));
     if (!empty($CFG->formatstringstriptags)) {
         $mform->setType('name', PARAM_TEXT);
     } else {
         $mform->setType('name', PARAM_CLEANHTML);
     }
     $mform->addRule('name', null, 'required', null, 'client');
     $this->add_intro_editor(true, get_string('chatintro', 'chat'));
     //-------------------------------------------------------------------------------
     $repeatarray = array();
     $repeatarray[] =& MoodleQuickForm::createElement('header', '', get_string('option', 'choice') . ' {no}');
     $repeatarray[] =& MoodleQuickForm::createElement('text', 'option', get_string('option', 'choice'));
     $repeatarray[] =& MoodleQuickForm::createElement('text', 'limit', get_string('limit', 'choice'));
     $repeatarray[] =& MoodleQuickForm::createElement('hidden', 'optionid', 0);
     $menuoptions = array();
     $menuoptions[0] = get_string('disable');
     $menuoptions[1] = get_string('enable');
     $mform->addElement('header', 'timerestricthdr', get_string('limit', 'choice'));
     $mform->addElement('select', 'limitanswers', get_string('limitanswers', 'choice'), $menuoptions);
     $mform->addHelpButton('limitanswers', 'limitanswers', 'choice');
     if ($this->_instance) {
         $repeatno = $DB->count_records('choice_options', array('choiceid' => $this->_instance));
         $repeatno += 2;
     } else {
         $repeatno = 5;
     }
     $repeateloptions = array();
     $repeateloptions['limit']['default'] = 0;
     $repeateloptions['limit']['disabledif'] = array('limitanswers', 'eq', 0);
     $mform->setType('limit', PARAM_INT);
     $repeateloptions['option']['helpbutton'] = array('choiceoptions', 'choice');
     $mform->setType('option', PARAM_CLEAN);
     $mform->setType('optionid', PARAM_INT);
     $this->repeat_elements($repeatarray, $repeatno, $repeateloptions, 'option_repeats', 'option_add_fields', 3);
     //-------------------------------------------------------------------------------
     $mform->addElement('header', 'timerestricthdr', get_string('timerestrict', 'choice'));
     $mform->addElement('checkbox', 'timerestrict', get_string('timerestrict', 'choice'));
     $mform->addElement('date_time_selector', 'timeopen', get_string("choiceopen", "choice"));
     $mform->disabledIf('timeopen', 'timerestrict');
     $mform->addElement('date_time_selector', 'timeclose', get_string("choiceclose", "choice"));
     $mform->disabledIf('timeclose', 'timerestrict');
     //-------------------------------------------------------------------------------
     $mform->addElement('header', 'miscellaneoussettingshdr', get_string('miscellaneoussettings', 'form'));
     $mform->addElement('select', 'display', get_string("displaymode", "choice"), $CHOICE_DISPLAY);
     $mform->addElement('select', 'showresults', get_string("publish", "choice"), $CHOICE_SHOWRESULTS);
     $mform->addElement('select', 'publish', get_string("privacy", "choice"), $CHOICE_PUBLISH);
     $mform->disabledIf('publish', 'showresults', 'eq', 0);
     $mform->addElement('selectyesno', 'allowupdate', get_string("allowupdate", "choice"));
     $mform->addElement('selectyesno', 'showunanswered', get_string("showunanswered", "choice"));
     //-------------------------------------------------------------------------------
     $this->standard_coursemodule_elements();
     //-------------------------------------------------------------------------------
     $this->add_action_buttons();
 }
 function definition()
 {
     global $CFG, $USER;
     $mform =& $this->_form;
     $course = $this->_customdata['course'];
     $cm = $this->_customdata['cm'];
     $modcontext = $this->_customdata['modcontext'];
     $mform->addElement('header', 'general', get_string('export', 'quiz'));
     $mform->setHelpButton('general', array('export', get_string('export', 'quiz'), 'attforblock'));
     $groupmode = groups_get_activity_groupmode($cm);
     $groups = groups_get_activity_allowed_groups($cm, $USER->id);
     if ($groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $modcontext)) {
         $grouplist[0] = get_string('allparticipants');
     }
     if ($groups) {
         foreach ($groups as $group) {
             $grouplist[$group->id] = $group->name;
         }
     }
     $mform->addElement('select', 'group', get_string('group'), $grouplist);
     $ident = array();
     $ident[] =& MoodleQuickForm::createElement('checkbox', 'id', '', get_string('studentid', 'attforblock'));
     $ident[] =& MoodleQuickForm::createElement('checkbox', 'uname', '', get_string('username'));
     $mform->addGroup($ident, 'ident', get_string('identifyby', 'attforblock'), array('<br />'), true);
     $mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true));
     $mform->addElement('checkbox', 'includenottaken', get_string('includenottaken', 'attforblock'), get_string('yes'));
     $mform->addElement('date_selector', 'sessionenddate', get_string('endofperiod', 'attforblock'));
     $mform->disabledIf('sessionenddate', 'includenottaken', 'notchecked');
     $mform->addElement('select', 'format', get_string('format'), array('excel' => get_string('downloadexcel', 'attforblock'), 'ooo' => get_string('downloadooo', 'attforblock'), 'text' => get_string('downloadtext', 'attforblock')));
     // buttons
     $submit_string = get_string('ok');
     $this->add_action_buttons(false, $submit_string);
     $mform->addElement('hidden', 'id', $cm->id);
     //        $mform->addElement('hidden', 'action', 'add');
 }
 function _createElements()
 {
     global $CFG, $COURSE;
     $this->_elements = array();
     $this->_elements[0] =& MoodleQuickForm::createElement('text', 'value', '', array('size' => '48'));
     $this->_elements[1] =& MoodleQuickForm::createElement('button', 'popup', get_string('chooseafile', 'resource') . ' ...');
     $button =& $this->_elements[1];
     if ($this->_options['courseid'] !== null) {
         $courseid = $this->_options['courseid'];
     } else {
         $courseid = $COURSE->id;
     }
     // first find out the text field id - this is a bit hacky, is there a better way?
     $choose = 'id_' . str_replace(array('[', ']'), array('_', ''), $this->getElementName(0));
     $url = "/files/index.php?id={$courseid}&choose=" . $choose;
     if ($this->_options['options'] == 'none') {
         $options = 'menubar=0,location=0,scrollbars,resizable,width=' . $this->_options['width'] . ',height=' . $this->_options['height'];
     } else {
         $options = $this->_options['options'];
     }
     $fullscreen = 0;
     $buttonattributes = array('title' => get_string("chooseafile", "resource"), 'onclick' => "return openpopup('{$url}', '" . $button->getName() . "', '{$options}', {$fullscreen});");
     $button->updateAttributes($buttonattributes);
     /// With repository active, show the button to browse it
     if (isset($CFG->repositoryactivate) && $CFG->repositoryactivate) {
         $this->_elements[2] =& MoodleQuickForm::createElement('button', 'imsrepo', get_string('browserepository', 'resource'));
         $imsbutton =& $this->_elements[2];
         $url = "/mod/resource/type/ims/finder.php?directory=&choose=" . $choose;
         $buttonattributes = array('title' => get_string("browserepository", "resource"), 'onclick' => "return openpopup('{$url}', '" . $button->getName() . "', '{$options}', {$fullscreen});");
         $imsbutton->updateAttributes($buttonattributes);
     }
 }