mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 02:16:41 +02:00
MDL-19488 - allow the creation of a "Public" feedback
This commit is contained in:
parent
e70dab0646
commit
7b1126fd20
5 changed files with 161 additions and 73 deletions
|
@ -79,20 +79,29 @@ class feedback_edit_use_template_form extends moodleform {
|
|||
$templates_options = array();
|
||||
$owntemplates = feedback_get_template_list($this->feedbackdata->course, 'own');
|
||||
$publictemplates = feedback_get_template_list($this->feedbackdata->course, 'public');
|
||||
if($owntemplates OR $publictemplates){//get the templates
|
||||
$templates_options[' '] = get_string('select');
|
||||
foreach($owntemplates as $template) {
|
||||
if($template->ispublic) {
|
||||
continue;
|
||||
|
||||
$options = array();
|
||||
if($owntemplates or $publictemplates) {
|
||||
$options[''] = array('' => get_string('choose'));
|
||||
|
||||
if($owntemplates) {
|
||||
$courseoptions = array();
|
||||
foreach($owntemplates as $template) {
|
||||
$courseoptions[$template->id] = $template->name;
|
||||
}
|
||||
$templates_options[$template->id] = $template->name;
|
||||
$options[get_string('course')] = $courseoptions;
|
||||
}
|
||||
foreach($publictemplates as $template) {
|
||||
$templates_options[$template->id] = '*'.$template->name;
|
||||
|
||||
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('select', 'templateid', '', $templates_options, $attributes);
|
||||
// buttons
|
||||
$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'));
|
||||
|
@ -144,11 +153,8 @@ class feedback_edit_create_template_form extends moodleform {
|
|||
$elementgroup[] =& $mform->createElement('static', 'templatenamelabel', get_string('name', 'feedback'));
|
||||
$elementgroup[] =& $mform->createElement('text', 'templatename', get_string('name', 'feedback'), array('size'=>'40', 'maxlength'=>'200'));
|
||||
|
||||
//If the feedback is located on the frontpage the we can create public templates
|
||||
if(SITEID === $this->feedbackdata->course->id) {
|
||||
if(has_capability('mod/feedback:createpublictemplate', $this->feedbackdata->context)) {
|
||||
$elementgroup[] =& $mform->createElement('checkbox', 'ispublic', get_string('public', 'feedback'), get_string('public', 'feedback'));
|
||||
}
|
||||
if(has_capability('mod/feedback:createpublictemplate', get_system_context())) {
|
||||
$elementgroup[] =& $mform->createElement('checkbox', 'ispublic', get_string('public', 'feedback'), get_string('public', 'feedback'));
|
||||
}
|
||||
|
||||
// buttons
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue