Example #1
0
 function set_form_elements()
 {
     $mform =& $this->_form;
     $elementgroup = array();
     //headline
     $mform->addElement('header', '', get_string('using_templates', 'feedback'));
     // hidden elements
     $mform->addElement('hidden', 'id');
     // visible elements
     $templates_options = array();
     if ($templates = feedback_get_template_list($this->feedbackdata->course)) {
         //get the templates
         $templates_options[' '] = get_string('select');
         foreach ($templates as $template) {
             $templates_options[$template->id] = $template->name;
         }
         $attributes = 'onChange="this.form.submit()"';
         $elementgroup[] =& $mform->createElement('select', 'templateid', '', $templates_options, $attributes);
         // buttons
         $elementgroup[] =& $mform->createElement('submit', 'use_template', get_string('use_this_template', 'feedback'));
     } else {
         $mform->addElement('static', 'info', get_string('no_templates_available_yet', 'feedback'));
     }
     $mform->addGroup($elementgroup, 'elementgroup', '', array(' '), false);
     //-------------------------------------------------------------------------------
 }
Example #2
0
    /**
     * Form definition
     */
    public function definition() {
        $mform =& $this->_form;

        $course = $this->_customdata['course'];

        $elementgroup = array();
        //headline
        $mform->addElement('header', 'using_templates', get_string('using_templates', 'feedback'));
        // hidden elements
        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);

        // visible elements
        $templates_options = array();
        $owntemplates = feedback_get_template_list($course, 'own');
        $publictemplates = feedback_get_template_list($course, 'public');

        $options = array();
        if ($owntemplates or $publictemplates) {
            $options[''] = array('' => get_string('choosedots'));

            if ($owntemplates) {
                $courseoptions = array();
                foreach ($owntemplates as $template) {
                    $courseoptions[$template->id] = format_string($template->name);
                }
                $options[get_string('course')] = $courseoptions;
            }

            if ($publictemplates) {
                $publicoptions = array();
                foreach ($publictemplates as $template) {
                    $publicoptions[$template->id] = format_string($template->name);
                }
                $options[get_string('public', 'feedback')] = $publicoptions;
            }

            $attributes = 'onChange="M.core_formchangechecker.set_form_submitted(); this.form.submit()"';
            $elementgroup[] = $mform->createElement('selectgroups',
                                                     'templateid',
                                                     get_string('using_templates', 'feedback'),
                                                     $options,
                                                     $attributes);

            $elementgroup[] = $mform->createElement('submit',
                                                     'use_template',
                                                     get_string('use_this_template', 'feedback'),
                                                     array('class' => 'hiddenifjs'));

            $mform->addGroup($elementgroup, 'elementgroup', '', array(' '), false);
        } else {
            $mform->addElement('static', 'info', get_string('no_templates_available_yet', 'feedback'));
        }

        $this->set_data(array('id' => $this->_customdata['id']));
    }
Example #3
0
                                            'id'=>$id,
                                            'deletetempl'=>$template->id,
                                            'shoulddelete'=>1,
                                            ));

            $data[] = $OUTPUT->single_button($url, $strdeletefeedback, 'post');
            $tablecourse->add_data($data);
        }
        $tablecourse->finish_output();
        echo $OUTPUT->box_end();
    }
    //now we get the public templates if it is permitted
    $systemcontext = get_system_context();
    if (has_capability('mod/feedback:createpublictemplate', $systemcontext) AND
        has_capability('mod/feedback:deletetemplate', $systemcontext)) {
        $templates = feedback_get_template_list($course, 'public');
        if (!is_array($templates)) {
            echo $OUTPUT->box(get_string('no_templates_available_yet', 'feedback'),
                              'generalbox boxaligncenter');
        } else {
            echo $OUTPUT->heading(get_string('public', 'feedback'), 3);
            echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthnormal');
            $tablecolumns = array('template', 'action');
            $tableheaders = array(get_string('template', 'feedback'), '');
            $tablepublic = new flexible_table('feedback_template_public_table');

            $tablepublic->define_columns($tablecolumns);
            $tablepublic->define_headers($tableheaders);
            $tablepublic->define_baseurl($deleteurl);
            $tablepublic->column_style('action', 'width', '10%');
Example #4
0
/// print the tabs
include 'tabs.php';
/// Print the main part of the page
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
print_heading(get_string('delete_template', 'feedback'));
if ($shoulddelete == 1) {
    // print_simple_box_start("center", "60%", "#FFAAAA", 20, "noticebox");
    print_box_start('generalbox errorboxcontent boxaligncenter boxwidthnormal');
    print_heading(get_string('confirmdeletetemplate', 'feedback'));
    $mform->display();
    // print_simple_box_end();
    print_box_end();
} else {
    $templates = feedback_get_template_list($course, true);
    echo '<div align="center">';
    if (!is_array($templates)) {
        // print_simple_box(get_string('no_templates_available_yet', 'feedback'), "center");
        print_box(get_string('no_templates_available_yet', 'feedback'), 'generalbox boxaligncenter');
    } else {
        echo '<table width="30%">';
        echo '<tr><th>' . get_string('templates', 'feedback') . '</th><th>&nbsp;</th></tr>';
        foreach ($templates as $template) {
            echo '<tr><td align="center">' . $template->name . '</td>';
            echo '<td align="center">';
            echo '<form action="' . $ME . '" method="post">';
            echo '<input title="' . get_string('delete_template', 'feedback') . '" type="image" src="' . $CFG->pixpath . '/t/delete.gif" hspace="1" height="11" width="11" border="0" />';
            echo '<input type="hidden" name="deletetempl" value="' . $template->id . '" />';
            echo '<input type="hidden" name="shoulddelete" value="1" />';
            echo '<input type="hidden" name="id" value="' . $id . '" />';
Example #5
0
    public function set_form_elements() {
        $mform =& $this->_form;

        $elementgroup = array();
        //headline
        $mform->addElement('header', '', get_string('using_templates', 'feedback'));
        // hidden elements
        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);

        // visible elements
        $templates_options = array();
        $owntemplates = feedback_get_template_list($this->feedbackdata->course, 'own');
        $publictemplates = feedback_get_template_list($this->feedbackdata->course, 'public');

        $options = array();
        if ($owntemplates or $publictemplates) {
            $options[''] = array('' => get_string('choose'));

            if ($owntemplates) {
                $courseoptions = array();
                foreach ($owntemplates as $template) {
                    $courseoptions[$template->id] = $template->name;
                }
                $options[get_string('course')] = $courseoptions;
            }

            if ($publictemplates) {
                $publicoptions = array();
                foreach ($publictemplates as $template) {
                    $publicoptions[$template->id] = $template->name;
                }
                $options[get_string('public', 'feedback')] = $publicoptions;
            }

            $attributes = 'onChange="this.form.submit()"';
            $elementgroup[] =& $mform->createElement('selectgroups',
                                                     'templateid',
                                                     '',
                                                     $options,
                                                     $attributes);

            $elementgroup[] =& $mform->createElement('submit',
                                                     'use_template',
                                                     get_string('use_this_template', 'feedback'));
        } else {
            $mform->addElement('static', 'info', get_string('no_templates_available_yet', 'feedback'));
        }
        $mform->addGroup($elementgroup, 'elementgroup', '', array(' '), false);

    }