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
891750bc
Commit
891750bc
authored
Sep 01, 2016
by
Frederic Massart
Committed by
Dan Poltawski
Sep 23, 2016
Browse files
MDL-55797 core_question: Make static getter for chooser
Part of MDL-55071
parent
7f8b7b2b
Changes
5
Hide whitespace changes
Inline
Side-by-side
question/classes/output/qbank_chooser.php
View file @
891750bc
...
...
@@ -25,9 +25,11 @@
namespace
core_question\output
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
use
context_course
;
use
core\output\chooser_section
;
use
lang_string
;
use
moodle_url
;
use
question_bank
;
/**
...
...
@@ -41,6 +43,12 @@ class qbank_chooser extends \core\output\chooser {
/**
* Constructor.
*
* @param array $real The real question types.
* @param array $fake The fake question types.
* @param stdClass $course The course.
* @param array $hiddenparams Hidden parameters.
* @param context $context The relevant context.
*/
public
function
__construct
(
$real
,
$fake
,
$course
,
$hiddenparams
,
$context
)
{
$sections
=
[];
...
...
@@ -66,4 +74,30 @@ class qbank_chooser extends \core\output\chooser {
}
}
/**
* Get an instance of the question bank chooser.
*
* @param stdClass $course The course.
* @param array $hiddenparams Hidden parameters.
* @param array|null $allowedqtypes Allowed question types.
* @return qbank_chooser
*/
public
static
function
get
(
$course
,
$hiddenparams
,
array
$allowedqtypes
=
null
)
{
$realqtypes
=
array
();
$fakeqtypes
=
array
();
foreach
(
question_bank
::
get_creatable_qtypes
()
as
$qtypename
=>
$qtype
)
{
if
(
$allowedqtypes
&&
!
in_array
(
$qtypename
,
$allowedqtypes
))
{
continue
;
}
if
(
$qtype
->
is_real_question_type
())
{
$realqtypes
[]
=
$qtype
;
}
else
{
$fakeqtypes
[]
=
$qtype
;
}
}
return
new
static
(
$realqtypes
,
$fakeqtypes
,
$course
,
$hiddenparams
,
context_course
::
instance
(
$course
->
id
));
}
}
question/editlib.php
View file @
891750bc
...
...
@@ -450,21 +450,10 @@ function require_login_in_context($contextorid = null){
function
print_choose_qtype_to_add_form
(
$hiddenparams
,
array
$allowedqtypes
=
null
,
$enablejs
=
true
)
{
global
$CFG
,
$PAGE
,
$OUTPUT
;
$realqtypes
=
array
();
$fakeqtypes
=
array
();
foreach
(
question_bank
::
get_creatable_qtypes
()
as
$qtypename
=>
$qtype
)
{
if
(
$allowedqtypes
&&
!
in_array
(
$qtypename
,
$allowedqtypes
))
{
continue
;
}
if
(
$qtype
->
is_real_question_type
())
{
$realqtypes
[]
=
$qtype
;
}
else
{
$fakeqtypes
[]
=
$qtype
;
}
}
$chooser
=
core_question\output\qbank_chooser
::
get
(
$PAGE
->
course
,
$hiddenparams
,
$allowedqtypes
);
$renderer
=
$PAGE
->
get_renderer
(
'question'
,
'bank'
);
return
$renderer
->
qbank_chooser
(
$realqtypes
,
$fakeqtypes
,
$PAGE
->
course
,
$hiddenparams
);
return
$renderer
->
render
(
$chooser
);
}
/**
...
...
question/renderer.php
View file @
891750bc
...
...
@@ -68,9 +68,9 @@ class core_question_bank_renderer extends plugin_renderer_base {
* @return string The composed HTML for the questionbank chooser
*/
public
function
qbank_chooser
(
$real
,
$fake
,
$course
,
$hiddenparams
)
{
$chooser
=
new
\
core_question\output\qbank_chooser
(
$real
,
$fake
,
$course
,
$hiddenparams
,
context_course
::
instance
(
$course
->
id
)
);
return
$this
->
render
(
$chooser
)
;
debugging
(
'Method core_question_bank_renderer::qbank_chooser() is deprecated, '
.
'see core_question_bank_renderer::render_qbank_chooser().'
,
DEBUG_DEVELOPER
);
return
''
;
}
/**
...
...
question/upgrade.txt
View file @
891750bc
This files describes API changes for code that uses the question API.
=== 3.2 ===
1) The following renderers have been deprecated in favour of the renderable
core_question\output\qbank_chooser and associated render_* method.
* qbank_chooser
* qbank_chooser_types
* qbank_chooser_qtype
* qbank_chooser_title
=== 3.1 ===
1) The argument $requirecourseid was removed from question_edit_setup() and
...
...
theme/upgrade.txt
View file @
891750bc
...
...
@@ -35,6 +35,12 @@ Removed themes:
- course_modchooser_module_types
- course_modchooser_module
- course_modchooser_title
* The question chooser now uses a renderable and a template, the following methods
have been deprecated in favour of core_question_bank_renderer::render_qbank_chooser().
- qbank_chooser
- qbank_chooser_types
- qbank_chooser_qtype
- qbank_chooser_title
=== 3.1 ===
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment