Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
integration
prechecker
Commits
1d981ae4
Commit
1d981ae4
authored
Apr 13, 2016
by
Eloy Lafuente
Browse files
Merge branch 'wip-MDL-53443-master' of
https://github.com/marinaglancy/moodle
parents
f40b444e
df003a85
Changes
15
Hide whitespace changes
Inline
Side-by-side
lib/tests/behat/behat_general.php
View file @
1d981ae4
...
...
@@ -1266,7 +1266,7 @@ class behat_general extends behat_base {
* @param string $link the text of the link.
* @return string the content of the downloaded file.
*/
p
rotected
function
download_file_from_link
(
$link
)
{
p
ublic
function
download_file_from_link
(
$link
)
{
// Find the link.
$linknode
=
$this
->
find_link
(
$link
);
$this
->
ensure_node_is_visible
(
$linknode
);
...
...
mod/feedback/classes/templates_table.php
0 → 100644
View file @
1d981ae4
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Contains class mod_feedback_templates_table
*
* @package mod_feedback
* @copyright 2016 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined
(
'MOODLE_INTERNAL'
)
||
die
();
global
$CFG
;
require_once
(
$CFG
->
libdir
.
'/tablelib.php'
);
/**
* Class mod_feedback_templates_table
*
* @package mod_feedback
* @copyright 2016 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
mod_feedback_templates_table
extends
flexible_table
{
/**
* Constructor
* @param int $uniqueid all tables have to have a unique id, this is used
* as a key when storing table properties like sort order in the session.
* @param moodle_url $baseurl
*/
public
function
__construct
(
$uniqueid
,
$baseurl
)
{
parent
::
__construct
(
$uniqueid
);
$tablecolumns
=
array
(
'template'
,
'action'
);
$tableheaders
=
array
(
get_string
(
'template'
,
'feedback'
),
''
);
$this
->
set_attribute
(
'class'
,
'templateslist'
);
$this
->
define_columns
(
$tablecolumns
);
$this
->
define_headers
(
$tableheaders
);
$this
->
define_baseurl
(
$baseurl
);
$this
->
column_class
(
'template'
,
'template'
);
$this
->
column_class
(
'action'
,
'action'
);
$this
->
sortable
(
false
);
}
/**
* Displays the table with the given set of templates
* @param array $templates
*/
public
function
display
(
$templates
)
{
global
$OUTPUT
;
if
(
empty
(
$templates
))
{
echo
$OUTPUT
->
box
(
get_string
(
'no_templates_available_yet'
,
'feedback'
),
'generalbox boxaligncenter'
);
return
;
}
$this
->
setup
();
$strdeletefeedback
=
get_string
(
'delete_template'
,
'feedback'
);
foreach
(
$templates
as
$template
)
{
$data
=
array
();
$data
[]
=
format_string
(
$template
->
name
);
$url
=
new
moodle_url
(
$this
->
baseurl
,
array
(
'deletetempl'
=>
$template
->
id
));
$data
[]
=
$OUTPUT
->
single_button
(
$url
,
$strdeletefeedback
,
'post'
);
$this
->
add_data
(
$data
);
}
$this
->
finish_output
();
}
}
mod/feedback/delete_template.php
View file @
1d981ae4
...
...
@@ -24,82 +24,35 @@
require_once
(
"../../config.php"
);
require_once
(
"lib.php"
);
require_once
(
'delete_template_form.php'
);
require_once
(
$CFG
->
libdir
.
'/tablelib.php'
);
$current_tab
=
'templates'
;
$id
=
required_param
(
'id'
,
PARAM_INT
);
$canceldelete
=
optional_param
(
'canceldelete'
,
false
,
PARAM_INT
);
$shoulddelete
=
optional_param
(
'shoulddelete'
,
false
,
PARAM_INT
);
$deletetempl
=
optional_param
(
'deletetempl'
,
false
,
PARAM_INT
);
$url
=
new
moodle_url
(
'/mod/feedback/delete_template.php'
,
array
(
'id'
=>
$id
));
if
(
$canceldelete
!==
false
)
{
$url
->
param
(
'canceldelete'
,
$canceldelete
);
}
if
(
$shoulddelete
!==
false
)
{
$url
->
param
(
'shoulddelete'
,
$shoulddelete
);
}
if
(
$deletetempl
!==
false
)
{
$url
->
param
(
'deletetempl'
,
$deletetempl
);
}
$PAGE
->
set_url
(
$url
);
if
((
$formdata
=
data_submitted
())
AND
!
confirm_sesskey
())
{
print_error
(
'invalidsesskey'
);
}
if
(
$canceldelete
==
1
)
{
$editurl
=
new
moodle_url
(
'/mod/feedback/edit.php'
,
array
(
'id'
=>
$id
,
'do_show'
=>
'templates'
));
redirect
(
$editurl
->
out
(
false
));
}
if
(
!
$cm
=
get_coursemodule_from_id
(
'feedback'
,
$id
))
{
print_error
(
'invalidcoursemodule'
);
}
if
(
!
$course
=
$DB
->
get_record
(
"course"
,
array
(
"id"
=>
$cm
->
course
)))
{
print_error
(
'coursemisconf'
);
}
if
(
!
$feedback
=
$DB
->
get_record
(
"feedback"
,
array
(
"id"
=>
$cm
->
instance
)))
{
print_error
(
'invalidcoursemodule'
);
}
$baseurl
=
new
moodle_url
(
'/mod/feedback/delete_template.php'
,
array
(
'id'
=>
$id
));
$PAGE
->
set_url
(
$baseurl
);
list
(
$course
,
$cm
)
=
get_course_and_cm_from_cmid
(
$id
,
'feedback'
);
$context
=
context_module
::
instance
(
$cm
->
id
);
require_login
(
$course
,
true
,
$cm
);
require_capability
(
'mod/feedback:deletetemplate'
,
$context
);
$mform
=
new
mod_feedback_delete_template_form
();
$newformdata
=
array
(
'id'
=>
$id
,
'deletetempl'
=>
$deletetempl
,
'confirmdelete'
=>
'1'
);
$feedback
=
$PAGE
->
activityrecord
;
$systemcontext
=
context_system
::
instance
();
$mform
->
set_data
(
$newformdata
);
$formdata
=
$mform
->
get_data
();
$deleteurl
=
new
moodle_url
(
'/mod/feedback/delete_template.php'
,
array
(
'id'
=>
$id
));
if
(
$mform
->
is_cancelled
())
{
redirect
(
$deleteurl
->
out
(
false
));
}
if
(
isset
(
$formdata
->
confirmdelete
)
AND
$formdata
->
confirmdelete
==
1
)
{
if
(
!
$template
=
$DB
->
get_record
(
"feedback_template"
,
array
(
"id"
=>
$deletetempl
)))
{
print_error
(
'error'
);
}
// Process template deletion.
if
(
$deletetempl
&&
optional_param
(
'confirm'
,
0
,
PARAM_BOOL
)
&&
confirm_sesskey
())
{
$template
=
$DB
->
get_record
(
'feedback_template'
,
array
(
'id'
=>
$deletetempl
),
'*'
,
MUST_EXIST
);
if
(
$template
->
ispublic
)
{
$systemcontext
=
context_system
::
instance
();
require_capability
(
'mod/feedback:createpublictemplate'
,
$systemcontext
);
require_capability
(
'mod/feedback:deletetemplate'
,
$systemcontext
);
}
feedback_delete_template
(
$template
);
redirect
(
$
deleteurl
->
out
(
false
));
redirect
(
$
baseurl
,
get_string
(
'template_deleted'
,
'feedback'
));
}
/// Print the page header
...
...
@@ -107,6 +60,8 @@ $strfeedbacks = get_string("modulenameplural", "feedback");
$strfeedback
=
get_string
(
"modulename"
,
"feedback"
);
$strdeletefeedback
=
get_string
(
'delete_template'
,
'feedback'
);
navigation_node
::
override_active_url
(
new
moodle_url
(
'/mod/feedback/edit.php'
,
array
(
'id'
=>
$id
,
'do_show'
=>
'templates'
)));
$PAGE
->
set_heading
(
$course
->
fullname
);
$PAGE
->
set_title
(
$feedback
->
name
);
echo
$OUTPUT
->
header
();
...
...
@@ -119,100 +74,30 @@ require('tabs.php');
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
echo
$OUTPUT
->
heading
(
$strdeletefeedback
,
3
);
if
(
$shoulddelete
==
1
)
{
echo
$OUTPUT
->
box_start
(
'generalbox errorboxcontent boxaligncenter boxwidthnormal'
);
echo
html_writer
::
tag
(
'p'
,
get_string
(
'confirmdeletetemplate'
,
'feedback'
),
array
(
'class'
=>
'bold'
));
$mform
->
display
();
echo
$OUTPUT
->
box_end
();
if
(
$deletetempl
)
{
$continueurl
=
new
moodle_url
(
$baseurl
,
array
(
'deletetempl'
=>
$deletetempl
,
'confirm'
=>
1
,
'sesskey'
=>
sesskey
()));
echo
$OUTPUT
->
confirm
(
get_string
(
'confirmdeletetemplate'
,
'feedback'
),
$continueurl
,
$baseurl
);
}
else
{
//
f
irst we get the
own
templates
//
F
irst we get the
course
templates
.
$templates
=
feedback_get_template_list
(
$course
,
'own'
);
if
(
!
is_array
(
$templates
))
{
echo
$OUTPUT
->
box
(
get_string
(
'no_templates_available_yet'
,
'feedback'
),
'generalbox boxaligncenter'
);
}
else
{
echo
$OUTPUT
->
heading
(
get_string
(
'course'
),
4
);
echo
$OUTPUT
->
box_start
(
'generalbox boxaligncenter boxwidthnormal'
);
$tablecolumns
=
array
(
'template'
,
'action'
);
$tableheaders
=
array
(
get_string
(
'template'
,
'feedback'
),
''
);
$tablecourse
=
new
flexible_table
(
'feedback_template_course_table'
);
$tablecourse
->
define_columns
(
$tablecolumns
);
$tablecourse
->
define_headers
(
$tableheaders
);
$tablecourse
->
define_baseurl
(
$deleteurl
);
$tablecourse
->
column_style
(
'action'
,
'width'
,
'10%'
);
$tablecourse
->
sortable
(
false
);
$tablecourse
->
set_attribute
(
'width'
,
'100%'
);
$tablecourse
->
set_attribute
(
'class'
,
'generaltable'
);
$tablecourse
->
setup
();
foreach
(
$templates
as
$template
)
{
$data
=
array
();
$data
[]
=
$template
->
name
;
$url
=
new
moodle_url
(
$deleteurl
,
array
(
'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
=
context_system
::
instance
();
echo
$OUTPUT
->
box_start
(
'coursetemplates'
);
echo
$OUTPUT
->
heading
(
get_string
(
'course'
),
4
);
$tablecourse
=
new
mod_feedback_templates_table
(
'feedback_template_course_table'
,
$baseurl
);
$tablecourse
->
display
(
$templates
);
echo
$OUTPUT
->
box_end
();
// Now we get the public templates if it is permitted.
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'
),
4
);
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%'
);
$tablepublic
->
sortable
(
false
);
$tablepublic
->
set_attribute
(
'width'
,
'100%'
);
$tablepublic
->
set_attribute
(
'class'
,
'generaltable'
);
$tablepublic
->
setup
();
foreach
(
$templates
as
$template
)
{
$data
=
array
();
$data
[]
=
$template
->
name
;
$url
=
new
moodle_url
(
$deleteurl
,
array
(
'id'
=>
$id
,
'deletetempl'
=>
$template
->
id
,
'shoulddelete'
=>
1
,
));
$data
[]
=
$OUTPUT
->
single_button
(
$url
,
$strdeletefeedback
,
'post'
);
$tablepublic
->
add_data
(
$data
);
}
$tablepublic
->
finish_output
();
echo
$OUTPUT
->
box_end
();
}
echo
$OUTPUT
->
box_start
(
'publictemplates'
);
echo
$OUTPUT
->
heading
(
get_string
(
'public'
,
'feedback'
),
4
);
$tablepublic
=
new
mod_feedback_templates_table
(
'feedback_template_public_table'
,
$baseurl
);
$tablepublic
->
display
(
$templates
);
echo
$OUTPUT
->
box_end
();
}
echo
$OUTPUT
->
box_start
(
'boxaligncenter boxwidthnormal'
);
$url
=
new
moodle_url
(
$deleteurl
,
array
(
'id'
=>
$id
,
'canceldelete'
=>
1
,
));
$url
=
new
moodle_url
(
'/mod/feedback/edit.php'
,
array
(
'id'
=>
$id
,
'do_show'
=>
'templates'
));
echo
$OUTPUT
->
single_button
(
$url
,
get_string
(
'back'
),
'post'
);
echo
$OUTPUT
->
box_end
();
}
echo
$OUTPUT
->
footer
();
...
...
mod/feedback/delete_template_form.php
deleted
100644 → 0
View file @
f40b444e
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* prints the form to confirm delete a completed
*
* @author Andreas Grabs
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package mod_feedback
*/
//It must be included from a Moodle page
if
(
!
defined
(
'MOODLE_INTERNAL'
))
{
die
(
'Direct access to this script is forbidden.'
);
}
require_once
(
$CFG
->
libdir
.
'/formslib.php'
);
class
mod_feedback_delete_template_form
extends
moodleform
{
public
function
definition
()
{
$mform
=&
$this
->
_form
;
// hidden elements
$mform
->
addElement
(
'hidden'
,
'id'
);
$mform
->
setType
(
'id'
,
PARAM_INT
);
$mform
->
addElement
(
'hidden'
,
'deletetempl'
);
$mform
->
setType
(
'deletetempl'
,
PARAM_INT
);
$mform
->
addElement
(
'hidden'
,
'confirmdelete'
);
$mform
->
setType
(
'confirmdelete'
,
PARAM_INT
);
//-------------------------------------------------------------------------------
// buttons
$this
->
add_action_buttons
(
true
,
get_string
(
'yes'
));
}
}
mod/feedback/edit.php
View file @
1d981ae4
...
...
@@ -94,34 +94,20 @@ if ($switchitemrequired) {
exit
;
}
//The create_template-form
$create_template_form
=
new
feedback_edit_create_template_form
();
$create_template_form
->
set_feedbackdata
(
array
(
'context'
=>
$context
,
'course'
=>
$course
));
$create_template_form
->
set_form_elements
();
$create_template_form
->
set_data
(
array
(
'id'
=>
$id
,
'do_show'
=>
'templates'
));
$create_template_formdata
=
$create_template_form
->
get_data
();
if
(
isset
(
$create_template_formdata
->
savetemplate
)
&&
$create_template_formdata
->
savetemplate
==
1
)
{
//Check the capabilities to create templates.
if
(
!
has_capability
(
'mod/feedback:createprivatetemplate'
,
$context
)
AND
!
has_capability
(
'mod/feedback:createpublictemplate'
,
$context
))
{
print_error
(
'cannotsavetempl'
,
'feedback'
);
// Process the create template form.
$cancreatetemplates
=
has_capability
(
'mod/feedback:createprivatetemplate'
,
$context
)
||
has_capability
(
'mod/feedback:createpublictemplate'
,
$context
);
$create_template_form
=
new
feedback_edit_create_template_form
(
null
,
array
(
'id'
=>
$id
));
if
(
$data
=
$create_template_form
->
get_data
())
{
// Check the capabilities to create templates.
if
(
!
$cancreatetemplates
)
{
print_error
(
'cannotsavetempl'
,
'feedback'
,
$url
);
}
if
(
trim
(
$create_template_formdata
->
templatename
)
==
''
)
{
$savereturn
=
'notsaved_name'
;
$ispublic
=
!
empty
(
$data
->
ispublic
)
?
1
:
0
;
if
(
!
feedback_save_as_template
(
$feedback
,
$data
->
templatename
,
$ispublic
))
{
redirect
(
$url
,
get_string
(
'saving_failed'
,
'feedback'
),
null
,
\
core\output\notification
::
NOTIFY_ERROR
);
}
else
{
//If the feedback is located on the frontpage then templates can be public.
if
(
has_capability
(
'mod/feedback:createpublictemplate'
,
context_system
::
instance
()))
{
$create_template_formdata
->
ispublic
=
isset
(
$create_template_formdata
->
ispublic
)
?
1
:
0
;
}
else
{
$create_template_formdata
->
ispublic
=
0
;
}
if
(
!
feedback_save_as_template
(
$feedback
,
$create_template_formdata
->
templatename
,
$create_template_formdata
->
ispublic
))
{
$savereturn
=
'failed'
;
}
else
{
$savereturn
=
'saved'
;
}
redirect
(
$url
,
get_string
(
'template_saved'
,
'feedback'
),
null
,
\
core\output\notification
::
NOTIFY_SUCCESS
);
}
}
...
...
@@ -141,10 +127,7 @@ $lastposition++;
//The use_template-form
$use_template_form
=
new
feedback_edit_use_template_form
(
'use_templ.php'
);
$use_template_form
->
set_feedbackdata
(
array
(
'course'
=>
$course
));
$use_template_form
->
set_form_elements
();
$use_template_form
->
set_data
(
array
(
'id'
=>
$id
));
$use_template_form
=
new
feedback_edit_use_template_form
(
'use_templ.php'
,
array
(
'course'
=>
$course
,
'id'
=>
$id
));
//Print the page header.
$strfeedbacks
=
get_string
(
'modulenameplural'
,
'feedback'
);
...
...
@@ -178,36 +161,13 @@ require('tabs.php');
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
$savereturn
=
isset
(
$savereturn
)
?
$savereturn
:
''
;
//Print the messages.
if
(
$savereturn
==
'notsaved_name'
)
{
echo
'<p align="center"><b><font color="red">'
.
get_string
(
'name_required'
,
'feedback'
)
.
'</font></b></p>'
;
}
if
(
$savereturn
==
'saved'
)
{
echo
'<p align="center"><b><font color="green">'
.
get_string
(
'template_saved'
,
'feedback'
)
.
'</font></b></p>'
;
}
if
(
$savereturn
==
'failed'
)
{
echo
'<p align="center"><b><font color="red">'
.
get_string
(
'saving_failed'
,
'feedback'
)
.
'</font></b></p>'
;
}
///////////////////////////////////////////////////////////////////////////
///Print the template-section.
///////////////////////////////////////////////////////////////////////////
if
(
$do_show
==
'templates'
)
{
echo
$OUTPUT
->
box_start
(
'generalbox boxaligncenter boxwidthwide'
);
$use_template_form
->
display
();
if
(
has_capability
(
'mod/feedback:createprivatetemplate'
,
$context
)
OR
has_capability
(
'mod/feedback:createpublictemplate'
,
$context
))
{
if
(
$cancreatetemplates
)
{
$deleteurl
=
new
moodle_url
(
'/mod/feedback/delete_template.php'
,
array
(
'id'
=>
$id
));
$create_template_form
->
display
();
echo
'<p><a href="'
.
$deleteurl
->
out
()
.
'">'
.
...
...
@@ -226,7 +186,6 @@ if ($do_show == 'templates') {
<a href="'
.
$importurl
->
out
()
.
'">'
.
get_string
(
'import_questions'
,
'feedback'
)
.
'</a>
</p>'
;
}
echo
$OUTPUT
->
box_end
();
}
///////////////////////////////////////////////////////////////////////////
///Print the Item-Edit-section.
...
...
mod/feedback/edit_form.php
View file @
1d981ae4
...
...
@@ -30,34 +30,15 @@ if (!defined('MOODLE_INTERNAL')) {
require_once
(
$CFG
->
libdir
.
'/formslib.php'
);
class
feedback_edit_use_template_form
extends
moodleform
{
private
$feedbackdata
;
/**
* Form definition
*/
public
function
definition
()
{
$this
->
feedbackdata
=
new
stdClass
();
//this function can not be called, because not all data are available at this time
//I use set_form_elements instead
}
//this function set the data used in set_form_elements()
//in this form the only value have to set is course
//eg: array('course' => $course)
public
function
set_feedbackdata
(
$data
)
{
if
(
is_array
(
$data
))
{
if
(
!
isset
(
$this
->
feedbackdata
))
{
$this
->
feedbackdata
=
new
stdClass
();
}
foreach
(
$data
as
$key
=>
$val
)
{
$this
->
feedbackdata
->
{
$key
}
=
$val
;
}
}
}
//here the elements will be set
//this function have to be called manually
//the advantage is that the data are already set
public
function
set_form_elements
()
{
$mform
=&
$this
->
_form
;
$course
=
$this
->
_customdata
[
'course'
];
$elementgroup
=
array
();
//headline
$mform
->
addElement
(
'header'
,
'using_templates'
,
get_string
(
'using_templates'
,
'feedback'
));
...
...
@@ -67,17 +48,17 @@ class feedback_edit_use_template_form extends moodleform {
// visible elements
$templates_options
=
array
();
$owntemplates
=
feedback_get_template_list
(
$
this
->
feedbackdata
->
course
,
'own'
);
$publictemplates
=
feedback_get_template_list
(
$
this
->
feedbackdata
->
course
,
'public'
);
$owntemplates
=
feedback_get_template_list
(
$course
,
'own'
);
$publictemplates
=
feedback_get_template_list
(
$course
,
'public'
);
$options
=
array
();
if
(
$owntemplates
or
$publictemplates
)
{
$options
[
''
]
=
array
(
''
=>
get_string
(
'choose'
));
$options
[
''
]
=
array
(
''
=>
get_string
(
'choose
dots
'
));
if
(
$owntemplates
)
{
$courseoptions
=
array
();
foreach
(
$owntemplates
as
$template
)
{
$courseoptions
[
$template
->
id
]
=
$template
->
name
;
$courseoptions
[
$template
->
id
]
=
format_string
(
$template
->
name
)
;
}
$options
[
get_string
(
'course'
)]
=
$courseoptions
;
}
...
...
@@ -85,7 +66,7 @@ class feedback_edit_use_template_form extends moodleform {
if
(
$publictemplates
)
{
$publicoptions
=
array
();
foreach
(
$publictemplates
as
$template
)
{
$publicoptions
[
$template
->
id
]
=
$template
->
name
;
$publicoptions
[
$template
->
id
]
=
format_string
(
$template
->
name
)
;
}
$options
[
get_string
(
'public'
,
'feedback'
)]
=
$publicoptions
;
}
...
...
@@ -93,52 +74,38 @@ class feedback_edit_use_template_form extends moodleform {
$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'
));
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'
]));
}
}
class
feedback_edit_create_template_form
extends
moodleform
{
private
$feedbackdata
;
/**
* Form definition
*/
public
function
definition
()
{
}
public
function
data_preprocessing
(
&
$default_values
)
{
$default_values
[
'templatename'
]
=
''
;
}
public
function
set_feedbackdata
(
$data
)
{
if
(
is_array
(
$data
))
{
if
(
!
isset
(
$this
->
feedbackdata
))
{
$this
->
feedbackdata
=
new
stdClass
();
}
foreach
(
$data
as
$key
=>
$val
)
{
$this
->
feedbackdata
->
{
$key
}
=
$val
;
}
}
}
public
function
set_form_elements
()
{
$mform
=&
$this
->
_form
;
// hidden elements
$mform
->
addElement
(
'hidden'
,
'id'
);
$mform
->
setType
(
'id'
,
PARAM_INT
);
$mform
->
addElement
(
'hidden'
,
'do_show'
);
$mform
->
setType
(
'do_show'
,
PARAM_INT
);
$mform
->
addElement
(
'hidden'
,
'savetemplate'
,
1
);
$mform
->
setType
(
'savetemplate'
,
PARAM_INT
);
$mform
->
setType
(
'do_show'
,
PARAM_ALPHANUMEXT
);
$mform
->
setConstant
(
'do_show'
,
'templates'
);
//headline
$mform
->
addElement
(
'header'
,
'creating_templates'
,
get_string
(
'creating_templates'
,
'feedback'
));
...
...
@@ -146,10 +113,6 @@ class feedback_edit_create_template_form extends moodleform {
// visible elements
$elementgroup
=
array
();
$elementgroup
[]
=
$mform
->
createElement
(
'static'
,
'templatenamelabel'
,
get_string
(
'name'
,
'feedback'
));