Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle-local_hshexport
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
moodle-local_hshexport
Commits
d475e543
Commit
d475e543
authored
7 months ago
by
Elke Kreim
Browse files
Options
Downloads
Patches
Plain Diff
Call form validation and add redirect
Rename file action_download to download
parent
6ca045de
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
classes/form/evaluserexport.php
+9
-25
9 additions, 25 deletions
classes/form/evaluserexport.php
download.php
+11
-10
11 additions, 10 deletions
download.php
index.php
+20
-5
20 additions, 5 deletions
index.php
with
40 additions
and
40 deletions
classes/form/evaluserexport.php
+
9
−
25
View file @
d475e543
...
...
@@ -38,13 +38,12 @@ class evaluserexport extends moodleform {
$mform
->
addElement
(
'html'
,
'<div id="intor">'
.
$introtext
.
'</div>'
);
$courseid
=
$this
->
_customdata
[
'courseid'
];
$mform
->
addElement
(
'hidden'
,
'courseid'
,
$courseid
);
$mform
->
setType
(
'courseid'
,
PARAM_INT
);
$coursecontext
=
$this
->
_customdata
[
'coursecontext'
];
$viewableroles
=
get_roles_used_in_context
(
$coursecontext
,
false
);
$roles
=
role_fix_names
(
$viewableroles
,
$coursecontext
,
ROLENAME_ALIAS
);
$options
=
[];
foreach
(
$roles
as
$role
)
{
$options
[
$role
->
id
]
=
$role
->
localname
;
}
$mform
->
addElement
(
'hidden'
,
'coursecontextid'
,
$coursecontext
->
id
);
$mform
->
setType
(
'coursecontextid'
,
PARAM_INT
);
$placeholder
=
get_string
(
'course_code_placeholder'
,
'local_hshexport'
);
$mform
->
addElement
(
'text'
,
'course_code'
,
get_string
(
'course_code'
,
'local_hshexport'
),
'maxlength="150" size="50" placeholder="'
.
$placeholder
.
'"'
);
...
...
@@ -52,22 +51,21 @@ class evaluserexport extends moodleform {
$mform
->
addHelpButton
(
'course_code'
,
'course_code'
,
'local_hshexport'
);
$mform
->
setDefault
(
'course_code'
,
null
);
$viewableroles
=
get_roles_used_in_context
(
$coursecontext
,
false
);
$roles
=
role_fix_names
(
$viewableroles
,
$coursecontext
,
ROLENAME_ALIAS
);
$roles_checkboxes
=
[];
foreach
(
$roles
as
$role
)
{
$roles_checkboxes
[]
=&
$mform
->
createElement
(
'advcheckbox'
,
'role_'
.
$role
->
id
,
$role
->
localname
,
null
,
[
'group'
=>
1
],
[
null
,
$role
->
id
]);
}
$mform
->
addGroup
(
$roles_checkboxes
,
'roles'
,
get_string
(
'select_roles'
,
'local_hshexport'
),
[
'<br/>'
],
true
);
$mform
->
addHelpButton
(
'roles'
,
'select_roles'
,
'local_hshexport'
);
$mform
->
addGroupRule
(
'roles'
,
get_string
(
'noselectedroles'
,
'local_hshexport'
),
'required'
,
null
,
1
,
'client'
PARAM_INT
,
1
);
$this
->
add_checkbox_controller
(
...
...
@@ -75,21 +73,7 @@ class evaluserexport extends moodleform {
get_string
(
"checkall"
,
"local_hshexport"
)
);
$mform
->
addElement
(
'hidden'
,
'courseid'
,
$courseid
);
$mform
->
setType
(
'courseid'
,
PARAM_INT
);
$mform
->
addElement
(
'hidden'
,
'coursecontextid'
,
$coursecontext
->
id
);
$mform
->
setType
(
'coursecontextid'
,
PARAM_INT
);
$submitlabel
=
get_string
(
'csvdownload'
,
'local_hshexport'
);
$this
->
add_action_buttons
(
false
,
$submitlabel
);
}
function
validation
(
$data
,
$files
)
{
$errors
=
parent
::
validation
(
$data
,
$files
);
// TODO: Change the autogenerated stub
return
$errors
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
action_
download.php
→
download.php
+
11
−
10
View file @
d475e543
...
...
@@ -27,21 +27,22 @@ use local_hshexport\local\helpers\download;
require
(
__DIR__
.
'/../../config.php'
);
require_once
(
$CFG
->
libdir
.
'/csvlib.class.php'
);
$PAGE
->
set_url
(
'/local/hshexport/
action_
download.php'
);
$PAGE
->
set_url
(
'/local/hshexport/download.php'
);
if
(
!
confirm_sesskey
())
{
throw
new
\moodle_exception
(
'confirmsesskeybad'
);
}
$course_code
=
optional_param
(
'code'
,
null
,
PARAM_ALPHANUMEXT
);
$courseid
=
required_param
(
'id'
,
PARAM_INT
);
$coursecontextid
=
required_param
(
'context'
,
PARAM_INT
);
$roles
=
required_param
(
'roles'
,
PARAM_TEXT
);
$course_code
=
optional_param
(
'course_code'
,
null
,
PARAM_ALPHANUMEXT
);
$courseid
=
required_param
(
'courseid'
,
PARAM_INT
);
$coursecontextid
=
required_param
(
'coursecontextid'
,
PARAM_INT
);
$roles
=
required_param_array
(
'roles'
,
PARAM_INT
);
$coursecontext
=
context_course
::
instance
(
$courseid
);
$PAGE
->
set_context
(
$coursecontext
);
require_capability
(
'local/hshexport:canexport'
,
$coursecontext
);
$roleids
=
array_values
(
array_filter
(
$roles
));
$roles
=
json_decode
(
urldecode
(
$roles
));
$roleids
=
array_map
(
'intval'
,
$roles
);
$filename
=
download
::
get_evaluation_filename
(
$courseid
,
$course_code
);
$users
=
local_hshexport\local\helpers\user_query
::
get_users_by_role
(
$courseid
,
$coursecontextid
,
$role
id
s
);
$users
=
local_hshexport\local\helpers\user_query
::
get_users_by_role
(
$courseid
,
$coursecontextid
,
$roles
);
if
(
!
$course_code
)
{
$course
=
get_course
(
$courseid
);
...
...
This diff is collapsed.
Click to expand it.
index.php
+
20
−
5
View file @
d475e543
...
...
@@ -24,8 +24,8 @@
use
local_hshexport
\form\evaluserexport
;
require
(
__DIR__
.
'/../../config.php'
);
require_once
(
$CFG
->
libdir
.
'/csvlib.class.php'
);
$courseid
=
required_param
(
'id'
,
PARAM_INT
);
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$courseid
),
'*'
,
MUST_EXIST
);
...
...
@@ -48,11 +48,26 @@ $customdata = [
'coursecontext'
=>
$coursecontext
];
$mform
=
new
evaluserexport
(
'action_download.php'
,
$customdata
);
$mform
=
new
evaluserexport
(
'#'
,
$customdata
);
if
(
$formdata
=
$mform
->
get_data
())
{
// removes not selected roles from array
$roleids
=
array_values
(
array_filter
(
$formdata
->
roles
));
$roles_param
=
urlencode
(
json_encode
(
$roleids
));
$params
=
[
'id'
=>
$formdata
->
courseid
,
'context'
=>
$formdata
->
coursecontextid
,
'roles'
=>
$roles_param
,
'code'
=>
$formdata
->
course_code
];
redirect
(
new
moodle_url
(
'/local/hshexport/download.php'
,
$params
));
//if ($mform->get_data())
{
//
redirect(new moodle_url('local/hshexport/action_download.php')
);
//
}
}
else
{
$mform
->
set_data
(
$formdata
);
}
$mform
->
display
();
echo
$OUTPUT
->
footer
();
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment