'clid'=>$classid,
                                            'deletetempl'=>$template->id,
                                            'shoulddelete'=>1,
                                            ));

            $data[] = $OUTPUT->single_button($url, $strdeleteevaluation, '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/evaluation:createpublictemplate', $systemcontext) AND
  //      has_capability('mod/evaluation:deletetemplate', $systemcontext)) {
        $templates = evaluation_get_template_list($classid, 'public');
        if (!is_array($templates)) {
            echo $OUTPUT->box(get_string('no_templates_available_yet', 'local_evaluations'),
                              'generalbox boxaligncenter');
        } else {
            echo $OUTPUT->heading(get_string('public', 'local_evaluations'), 3);
            echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthnormal');
            $tablecolumns = array('template', 'action');
            $tableheaders = array(get_string('template', 'local_evaluations'), '');
            $tablepublic = new flexible_table('evaluation_template_public_table');

            $tablepublic->define_columns($tablecolumns);
            $tablepublic->define_headers($tableheaders);
            $tablepublic->define_baseurl($deleteurl);
            $tablepublic->column_style('action', 'width', '10%');
Esempio n. 2
0
    public function set_form_elements() {
        $mform = & $this->_form;

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

        // visible elements
        $templates_options = array();
        $owntemplates = evaluation_get_template_list($this->evaluationdata->clid, 'own');
        $publictemplates = evaluation_get_template_list($this->evaluationdata->clid, 'public');

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

            if ($owntemplates) {
                $classoptions = array();
                foreach ($owntemplates as $template) {
                    $classoptions[$template->id] = $template->name;
                }
                $options[get_string('class', 'local_clclasses')] = $classoptions;
            }

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

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

            $elementgroup[] = $mform->createElement('submit', 'use_template', get_string('use_this_template', 'local_evaluations'));

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