Example #1
0
 function definition()
 {
     global $COURSE;
     $mform =& $this->_form;
     $defaultcategory = $this->_customdata['defaultcategory'];
     $contexts = $this->_customdata['contexts'];
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'fileformat', get_string('fileformat', 'quiz'));
     $fileformatnames = get_import_export_formats('import');
     $i = 0;
     foreach ($fileformatnames as $shortname => $fileformatname) {
         $currentgrp1 = array();
         $currentgrp1[] =& $mform->createElement('radio', 'format', '', $fileformatname, $shortname);
         $mform->addGroup($currentgrp1, "formathelp[{$i}]", '', array('<br />'), false);
         $mform->addHelpButton("formathelp[{$i}]", $shortname, 'qformat_' . $shortname);
         $i++;
     }
     $mform->addRule("formathelp[0]", null, 'required', null, 'client');
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('questioncategory', 'category', get_string('importcategory', 'question'), compact('contexts'));
     $mform->setDefault('category', $defaultcategory);
     $mform->addHelpButton('category', 'importcategory', 'question');
     $categorygroup = array();
     $categorygroup[] =& $mform->createElement('checkbox', 'catfromfile', '', get_string('getcategoryfromfile', 'question'));
     $categorygroup[] =& $mform->createElement('checkbox', 'contextfromfile', '', get_string('getcontextfromfile', 'question'));
     $mform->addGroup($categorygroup, 'categorygroup', '', '', false);
     $mform->disabledIf('categorygroup', 'catfromfile', 'notchecked');
     $mform->setDefault('catfromfile', 1);
     $mform->setDefault('contextfromfile', 1);
     $matchgrades = array();
     $matchgrades['error'] = get_string('matchgradeserror', 'quiz');
     $matchgrades['nearest'] = get_string('matchgradesnearest', 'quiz');
     $mform->addElement('select', 'matchgrades', get_string('matchgrades', 'question'), $matchgrades);
     $mform->addHelpButton('matchgrades', 'matchgrades', 'question');
     $mform->setDefault('matchgrades', 'error');
     $mform->addElement('selectyesno', 'stoponerror', get_string('stoponerror', 'question'));
     $mform->setDefault('stoponerror', 1);
     $mform->addHelpButton('stoponerror', 'stoponerror', 'question');
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'importfileupload', get_string('importfromthisfile', 'quiz'));
     $mform->addElement('filepicker', 'newfile', get_string('import', 'quiz'));
     //--------------------------------------------------------------------------------
     $mform->addElement('submit', 'submitbutton', get_string('import', 'quiz'));
     //--------------------------------------------------------------------------------
     //if (has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $COURSE->id))){
     //$mform->addElement('header', 'importfilearea', get_string('importfilearea','quiz'));
     //TODO: MDL-16094
     //$mform->addElement('choosecoursefile', 'choosefile', get_string('choosefile','quiz'));
     //--------------------------------------------------------------------------------
     //$mform->addElement('submit', 'submitbutton', get_string('importfromthisfile','quiz'));
     //}
     //--------------------------------------------------------------------------------
     $mform->addElement('static', 'dummy', '');
     $mform->closeHeaderBefore('dummy');
     // set a template for the format select elements
     $renderer =& $mform->defaultRenderer();
     $template = "{help} {element}\n";
     $renderer->setGroupElementTemplate($template, 'format');
 }
Example #2
0
 protected function definition()
 {
     global $OUTPUT;
     $mform = $this->_form;
     $defaultcategory = $this->_customdata['defaultcategory'];
     $contexts = $this->_customdata['contexts'];
     // Choice of import format, with help icons.
     $mform->addElement('header', 'fileformat', get_string('fileformat', 'question'));
     $fileformatnames = get_import_export_formats('import');
     $radioarray = array();
     $separators = array();
     foreach ($fileformatnames as $shortname => $fileformatname) {
         $radioarray[] = $mform->createElement('radio', 'format', '', $fileformatname, $shortname);
         $separator = '';
         if (get_string_manager()->string_exists('pluginname_help', 'qformat_' . $shortname)) {
             $separator .= $OUTPUT->help_icon('pluginname', 'qformat_' . $shortname);
         }
         $separator .= '<br>';
         $separators[] = $separator;
     }
     $radioarray[] = $mform->createElement('static', 'makelasthelpiconshowup', '');
     $mform->addGroup($radioarray, "formatchoices", '', $separators, false);
     $mform->addRule("formatchoices", null, 'required', null, 'client');
     // Import options.
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('questioncategory', 'category', get_string('importcategory', 'question'), compact('contexts'));
     $mform->setDefault('category', $defaultcategory);
     $mform->addHelpButton('category', 'importcategory', 'question');
     $categorygroup = array();
     $categorygroup[] = $mform->createElement('checkbox', 'catfromfile', '', get_string('getcategoryfromfile', 'question'));
     $categorygroup[] = $mform->createElement('checkbox', 'contextfromfile', '', get_string('getcontextfromfile', 'question'));
     $mform->addGroup($categorygroup, 'categorygroup', '', '', false);
     $mform->disabledIf('categorygroup', 'catfromfile', 'notchecked');
     $mform->setDefault('catfromfile', 1);
     $mform->setDefault('contextfromfile', 1);
     $matchgrades = array();
     $matchgrades['error'] = get_string('matchgradeserror', 'question');
     $matchgrades['nearest'] = get_string('matchgradesnearest', 'question');
     $mform->addElement('select', 'matchgrades', get_string('matchgrades', 'question'), $matchgrades);
     $mform->addHelpButton('matchgrades', 'matchgrades', 'question');
     $mform->setDefault('matchgrades', 'error');
     $mform->addElement('selectyesno', 'stoponerror', get_string('stoponerror', 'question'));
     $mform->setDefault('stoponerror', 1);
     $mform->addHelpButton('stoponerror', 'stoponerror', 'question');
     // The file to import
     $mform->addElement('header', 'importfileupload', get_string('importquestions', 'question'));
     $mform->addElement('filepicker', 'newfile', get_string('import'));
     $mform->addRule('newfile', null, 'required', null, 'client');
     // Submit button.
     $mform->addElement('submit', 'submitbutton', get_string('import'));
     // Set a template for the format select elements
     $renderer = $mform->defaultRenderer();
     $template = "{help} {element}\n";
     $renderer->setGroupElementTemplate($template, 'format');
 }
Example #3
0
 function definition()
 {
     global $COURSE;
     $mform =& $this->_form;
     $defaultcategory = $this->_customdata['defaultcategory'];
     $contexts = $this->_customdata['contexts'];
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'fileformat', get_string('fileformat', 'quiz'));
     $fileformatnames = get_import_export_formats('import');
     $radioarray = array();
     foreach ($fileformatnames as $id => $fileformatname) {
         $radioarray[] =& MoodleQuickForm::createElement('radio', 'format', '', $fileformatname, $id);
     }
     $mform->addGroup($radioarray, 'format', '', array('<br />'), false);
     $mform->addRule('format', null, 'required', null, 'client');
     $mform->setHelpButton('format', array('import', get_string('importquestions', 'quiz'), 'quiz'));
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('questioncategory', 'category', get_string('category', 'quiz'), compact('contexts'));
     $mform->setDefault('category', $defaultcategory);
     $mform->setHelpButton('category', array('importcategory', get_string('importcategory', 'quiz'), 'quiz'));
     $categorygroup = array();
     $categorygroup[] =& $mform->createElement('checkbox', 'catfromfile', '', get_string('getcategoryfromfile', 'question'));
     $categorygroup[] =& $mform->createElement('checkbox', 'contextfromfile', '', get_string('getcontextfromfile', 'question'));
     $mform->addGroup($categorygroup, 'categorygroup', '', '', false);
     $mform->disabledIf('categorygroup', 'catfromfile', 'notchecked');
     $mform->setDefault('catfromfile', 1);
     $mform->setDefault('contextfromfile', 1);
     $matchgrades = array();
     $matchgrades['error'] = get_string('matchgradeserror', 'quiz');
     $matchgrades['nearest'] = get_string('matchgradesnearest', 'quiz');
     $mform->addElement('select', 'matchgrades', get_string('matchgrades', 'quiz'), $matchgrades);
     $mform->setHelpButton('matchgrades', array('matchgrades', get_string('matchgrades', 'quiz'), 'quiz'));
     $mform->setDefault('matchgrades', 'error');
     $mform->addElement('selectyesno', 'stoponerror', get_string('stoponerror', 'quiz'));
     $mform->setDefault('stoponerror', 1);
     $mform->setHelpButton('stoponerror', array('stoponerror', get_string('stoponerror', 'quiz'), 'quiz'));
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'importfileupload', get_string('importfileupload', 'quiz'));
     $this->set_upload_manager(new upload_manager('newfile', true, false, $COURSE, false, 0, false, true, false));
     $mform->addElement('file', 'newfile', get_string('upload'));
     //--------------------------------------------------------------------------------
     $mform->addElement('submit', 'submitbutton', get_string('uploadthisfile'));
     //--------------------------------------------------------------------------------
     if (has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $COURSE->id))) {
         $mform->addElement('header', 'importfilearea', get_string('importfilearea', 'quiz'));
         $mform->addElement('choosecoursefile', 'choosefile', get_string('choosefile', 'quiz'));
         //--------------------------------------------------------------------------------
         $mform->addElement('submit', 'submitbutton', get_string('importfromthisfile', 'quiz'));
     }
     //--------------------------------------------------------------------------------
     $mform->addElement('static', 'dummy', '');
     $mform->closeHeaderBefore('dummy');
 }
 protected function definition()
 {
     global $COURSE;
     $mform = $this->_form;
     $defaultcategory = $this->_customdata['defaultcategory'];
     $contexts = $this->_customdata['contexts'];
     // Choice of import format, with help icons.
     $mform->addElement('header', 'fileformat', get_string('fileformat', 'question'));
     $fileformatnames = get_import_export_formats('import');
     $radioarray = array();
     $i = 0;
     foreach ($fileformatnames as $shortname => $fileformatname) {
         $currentgrp1 = array();
         $currentgrp1[] = $mform->createElement('radio', 'format', '', $fileformatname, $shortname);
         $mform->addGroup($currentgrp1, "formathelp[{$i}]", '', array('<br />'), false);
         $mform->addHelpButton("formathelp[{$i}]", $shortname, 'qformat_' . $shortname);
         $i++;
     }
     $mform->addRule("formathelp[0]", null, 'required', null, 'client');
     // Import options.
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('questioncategory', 'category', get_string('importcategory', 'question'), compact('contexts'));
     $mform->setDefault('category', $defaultcategory);
     $mform->addHelpButton('category', 'importcategory', 'question');
     $categorygroup = array();
     $categorygroup[] = $mform->createElement('checkbox', 'catfromfile', '', get_string('getcategoryfromfile', 'question'));
     $categorygroup[] = $mform->createElement('checkbox', 'contextfromfile', '', get_string('getcontextfromfile', 'question'));
     $mform->addGroup($categorygroup, 'categorygroup', '', '', false);
     $mform->disabledIf('categorygroup', 'catfromfile', 'notchecked');
     $mform->setDefault('catfromfile', 1);
     $mform->setDefault('contextfromfile', 1);
     $matchgrades = array();
     $matchgrades['error'] = get_string('matchgradeserror', 'question');
     $matchgrades['nearest'] = get_string('matchgradesnearest', 'question');
     $mform->addElement('select', 'matchgrades', get_string('matchgrades', 'question'), $matchgrades);
     $mform->addHelpButton('matchgrades', 'matchgrades', 'question');
     $mform->setDefault('matchgrades', 'error');
     $mform->addElement('selectyesno', 'stoponerror', get_string('stoponerror', 'question'));
     $mform->setDefault('stoponerror', 1);
     $mform->addHelpButton('stoponerror', 'stoponerror', 'question');
     // The file to import
     $mform->addElement('header', 'importfileupload', get_string('importquestions', 'question'));
     $mform->addElement('filepicker', 'newfile', get_string('import'));
     $mform->addRule('newfile', null, 'required', null, 'client');
     // Submit button.
     $mform->addElement('submit', 'submitbutton', get_string('import'));
     // Set a template for the format select elements
     $renderer = $mform->defaultRenderer();
     $template = "{help} {element}\n";
     $renderer->setGroupElementTemplate($template, 'format');
 }
Example #5
0
    protected function definition() {
        $mform = $this->_form;

        $defaultcategory = $this->_customdata['defaultcategory'];
        $contexts = $this->_customdata['contexts'];

        // Choice of format, with help.
        $mform->addElement('header', 'fileformat', get_string('fileformat', 'question'));
        $fileformatnames = get_import_export_formats('export');
        $radioarray = array();
        $i = 0 ;
        foreach ($fileformatnames as $shortname => $fileformatname) {
            $currentgrp1 = array();
            $currentgrp1[] = $mform->createElement('radio', 'format', '', $fileformatname, $shortname);
            $mform->addGroup($currentgrp1, "formathelp[$i]", '&#160;', array('<br />'), false);

            if (get_string_manager()->string_exists('pluginname_help', 'qformat_' . $shortname)) {
                $mform->addHelpButton("formathelp[$i]", 'pluginname', 'qformat_' . $shortname);
            }

            $i++ ;
        }
        $mform->addRule("formathelp[0]", null, 'required', null, 'client');

        // Export options.
        $mform->addElement('header', 'general', get_string('general', 'form'));

        $mform->addElement('questioncategory', 'category', get_string('exportcategory', 'question'), compact('contexts'));
        $mform->setDefault('category', $defaultcategory);
        $mform->addHelpButton('category', 'exportcategory', 'question');

        $categorygroup = array();
        $categorygroup[] = $mform->createElement('checkbox', 'cattofile', '', get_string('tofilecategory', 'question'));
        $categorygroup[] = $mform->createElement('checkbox', 'contexttofile', '', get_string('tofilecontext', 'question'));
        $mform->addGroup($categorygroup, 'categorygroup', '', '', false);
        $mform->disabledIf('categorygroup', 'cattofile', 'notchecked');
        $mform->setDefault('cattofile', 1);
        $mform->setDefault('contexttofile', 1);

        // Set a template for the format select elements
        $renderer = $mform->defaultRenderer();
        $template = "{help} {element}\n";
        $renderer->setGroupElementTemplate($template, 'format');

        // Submit buttons.
        $this->add_action_buttons(false, get_string('exportquestions', 'question'));
    }
Example #6
0
 function definition()
 {
     $mform =& $this->_form;
     $defaultcategory = $this->_customdata['defaultcategory'];
     $contexts = $this->_customdata['contexts'];
     $defaultfilename = $this->_customdata['defaultfilename'];
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'fileformat', get_string('fileformat', 'quiz'));
     $fileformatnames = get_import_export_formats('export');
     $radioarray = array();
     foreach ($fileformatnames as $shortname => $fileformatname) {
         $radioelement =& MoodleQuickForm::createElement('radio', 'format', '', $fileformatname, $shortname);
         $radioelement->setHelpButton(array("{$shortname}", $fileformatname, "qformat_{$shortname}"));
         $radioarray[] = $radioelement;
     }
     $mform->addGroup($radioarray, 'format', '', array('<br />'), false);
     $mform->addRule('format', null, 'required', null, 'client');
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('questioncategory', 'category', get_string('category', 'quiz'), compact('contexts'));
     $mform->setDefault('category', $defaultcategory);
     $mform->setHelpButton('category', array('exportcategory', get_string('exportcategory', 'question'), 'quiz'));
     $categorygroup = array();
     $categorygroup[] =& $mform->createElement('checkbox', 'cattofile', '', get_string('tofilecategory', 'question'));
     $categorygroup[] =& $mform->createElement('checkbox', 'contexttofile', '', get_string('tofilecontext', 'question'));
     $mform->addGroup($categorygroup, 'categorygroup', '', '', false);
     $mform->disabledIf('categorygroup', 'cattofile', 'notchecked');
     $mform->setDefault('cattofile', 1);
     $mform->setDefault('contexttofile', 1);
     //        $fileformatnames = get_import_export_formats('export');
     //        $mform->addElement('select', 'format', get_string('fileformat','quiz'), $fileformatnames);
     //        $mform->setDefault('format', 'gift');
     //        $mform->setHelpButton('format', array('export', get_string('exportquestions', 'quiz'), 'quiz'));
     $mform->addElement('text', 'exportfilename', get_string('exportname', 'quiz'), array('size' => 40));
     $mform->setDefault('exportfilename', $defaultfilename);
     $mform->setType('exportfilename', PARAM_FILE);
     // set a template for the format select elements
     $renderer =& $mform->defaultRenderer();
     $template = "{help} {element}\n";
     $renderer->setGroupElementTemplate($template, 'format');
     //--------------------------------------------------------------------------------
     $this->add_action_buttons(false, get_string('exportquestions', 'quiz'));
     //--------------------------------------------------------------------------------
 }
Example #7
0
 function definition()
 {
     $mform =& $this->_form;
     $defaultcategory = $this->_customdata['defaultcategory'];
     $contexts = $this->_customdata['contexts'];
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'fileformat', get_string('fileformat', 'quiz'));
     $fileformatnames = get_import_export_formats('export');
     $radioarray = array();
     $i = 0;
     foreach ($fileformatnames as $shortname => $fileformatname) {
         $currentgrp1 = array();
         $currentgrp1[] =& $mform->createElement('radio', 'format', '', $fileformatname, $shortname);
         $mform->addGroup($currentgrp1, "formathelp[{$i}]", '', array('<br />'), false);
         $mform->addHelpButton("formathelp[{$i}]", $shortname, 'qformat_' . $shortname);
         $i++;
     }
     $mform->addRule("formathelp[0]", null, 'required', null, 'client');
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('questioncategory', 'category', get_string('exportcategory', 'question'), compact('contexts'));
     $mform->setDefault('category', $defaultcategory);
     $mform->addHelpButton('category', 'exportcategory', 'question');
     $categorygroup = array();
     $categorygroup[] =& $mform->createElement('checkbox', 'cattofile', '', get_string('tofilecategory', 'question'));
     $categorygroup[] =& $mform->createElement('checkbox', 'contexttofile', '', get_string('tofilecontext', 'question'));
     $mform->addGroup($categorygroup, 'categorygroup', '', '', false);
     $mform->disabledIf('categorygroup', 'cattofile', 'notchecked');
     $mform->setDefault('cattofile', 1);
     $mform->setDefault('contexttofile', 1);
     //        $fileformatnames = get_import_export_formats('export');
     //        $mform->addElement('select', 'format', get_string('fileformat','quiz'), $fileformatnames);
     //        $mform->setDefault('format', 'gift');
     // set a template for the format select elements
     $renderer =& $mform->defaultRenderer();
     $template = "{help} {element}\n";
     $renderer->setGroupElementTemplate($template, 'format');
     //--------------------------------------------------------------------------------
     $this->add_action_buttons(false, get_string('exportquestions', 'quiz'));
     //--------------------------------------------------------------------------------
 }
Example #8
0
    // link to download the finished file
    $file_ext = $qformat->export_file_extension();
    if ($CFG->slasharguments) {
        $efile = "{$CFG->wwwroot}/file.php/" . $qformat->question_get_export_dir() . "/{$exportfilename}" . $file_ext . "?forcedownload=1";
    } else {
        $efile = "{$CFG->wwwroot}/file.php?file=/" . $qformat->question_get_export_dir() . "/{$exportfilename}" . $file_ext . "&forcedownload=1";
    }
    echo "<p><div class=\"boxaligncenter\"><a href=\"{$efile}\">{$txt->download}</a></div></p>";
    echo "<p><div class=\"boxaligncenter\"><font size=\"-1\">{$txt->downloadextra}</font></div></p>";
    print_continue("edit.php?courseid={$course->id}");
    print_footer($course);
    exit;
}
/// Display upload form
// get valid formats to generate dropdown list
$fileformatnames = get_import_export_formats('export');
// get filename
if (empty($exportfilename)) {
    $exportfilename = default_export_filename($course, $category);
}
print_heading_with_help($txt->exportquestions, 'export', 'quiz');
print_box_start('generalbox boxwidthnormal boxaligncenter');
?>

    <form enctype="multipart/form-data" method="post" action="export.php">
        <fieldset class="invisiblefieldset" style="display: block;">
            <input type="hidden" name="sesskey" value="<?php 
echo sesskey();
?>
" />
            <input type="hidden" name="courseid" value="<?php