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
moodle
moodle
Commits
c2200bd5
Commit
c2200bd5
authored
Sep 30, 2019
by
Tim Hunt
Browse files
MDL-66553 quiz/questions: show idnumber and tags when adding from qbank
parent
61cc1e64
Changes
4
Hide whitespace changes
Inline
Side-by-side
mod/quiz/classes/question/bank/custom_view.php
View file @
c2200bd5
...
...
@@ -207,7 +207,7 @@ class custom_view extends \core_question\bank\view {
}
protected
function
print_category_info
(
$category
)
{
$formatoptions
=
new
stdClass
();
$formatoptions
=
new
\
stdClass
();
$formatoptions
->
noclean
=
true
;
$strcategory
=
get_string
(
'category'
,
'quiz'
);
echo
'<div class="categoryinfo"><div class="categorynamefieldcontainer">'
.
...
...
mod/quiz/classes/question/bank/question_name_text_column.php
View file @
c2200bd5
...
...
@@ -44,7 +44,7 @@ class question_name_text_column extends \core_question\bank\question_name_column
if
(
$labelfor
)
{
echo
'<label for="'
.
$labelfor
.
'">'
;
}
echo
quiz_question_tostring
(
$question
);
echo
quiz_question_tostring
(
$question
,
false
,
true
,
true
,
$question
->
tags
);
if
(
$labelfor
)
{
echo
'</label>'
;
}
...
...
@@ -55,6 +55,12 @@ class question_name_text_column extends \core_question\bank\question_name_column
$fields
=
parent
::
get_required_fields
();
$fields
[]
=
'q.questiontext'
;
$fields
[]
=
'q.questiontextformat'
;
$fields
[]
=
'q.idnumber'
;
return
$fields
;
}
public
function
load_additional_data
(
array
$questions
)
{
parent
::
load_additional_data
(
$questions
);
parent
::
load_question_tags
(
$questions
);
}
}
mod/quiz/locallib.php
View file @
c2200bd5
...
...
@@ -2048,17 +2048,43 @@ class qubaids_for_quiz_user extends qubaid_join {
* @param bool $showicon If true, show the question's icon with the question. False by default.
* @param bool $showquestiontext If true (default), show question text after question name.
* If false, show only question name.
* @return string
*/
function
quiz_question_tostring
(
$question
,
$showicon
=
false
,
$showquestiontext
=
true
)
{
* @param bool $showidnumber If true, show the question's idnumber, if any. False by default.
* @param core_tag_tag[]|bool $showtags if array passed, show those tags. Else, if true, get and show tags,
* else, don't show tags (which is the default).
* @return string HTML fragment.
*/
function
quiz_question_tostring
(
$question
,
$showicon
=
false
,
$showquestiontext
=
true
,
$showidnumber
=
false
,
$showtags
=
false
)
{
global
$OUTPUT
;
$result
=
''
;
// Question name.
$name
=
shorten_text
(
format_string
(
$question
->
name
),
200
);
if
(
$showicon
)
{
$name
.
=
print_question_icon
(
$question
)
.
' '
.
$name
;
}
$result
.
=
html_writer
::
span
(
$name
,
'questionname'
);
// Question idnumber.
if
(
$showidnumber
&&
$question
->
idnumber
!==
null
&&
$question
->
idnumber
!==
''
)
{
$result
.
=
' '
.
html_writer
::
span
(
html_writer
::
span
(
get_string
(
'idnumber'
,
'question'
),
'accesshide'
)
.
' '
.
$question
->
idnumber
,
'badge badge-primary'
);
}
// Question tags.
if
(
is_array
(
$showtags
))
{
$tags
=
$showtags
;
}
else
if
(
$showtags
)
{
$tags
=
core_tag_tag
::
get_item_tags
(
'core_question'
,
'question'
,
$question
->
id
);
}
else
{
$tags
=
[];
}
if
(
$tags
)
{
$result
.
=
$OUTPUT
->
tag_list
(
$tags
,
null
,
'd-inline'
,
0
,
null
,
true
);
}
// Question text.
if
(
$showquestiontext
)
{
$questiontext
=
question_utils
::
to_plain_text
(
$question
->
questiontext
,
$question
->
questiontextformat
,
array
(
'noclean'
=>
true
,
'para'
=>
false
));
...
...
mod/quiz/tests/behat/editing_add_from_question_bank.feature
View file @
c2200bd5
...
...
@@ -21,9 +21,9 @@ Feature: Adding questions to a quiz from the question bank
|
contextlevel
|
reference
|
name
|
|
Course
|
C1
|
Test
questions
|
And the following "questions" exist
:
|
questioncategory
|
qtype
|
name
|
user
|
questiontext
|
|
Test
questions
|
essay
|
question
01
name
|
admin
|
Question
01
text
|
|
Test
questions
|
essay
|
question
02
name
|
teacher1
|
Question
02
text
|
|
questioncategory
|
qtype
|
name
|
user
|
questiontext
|
idnumber
|
|
Test
questions
|
essay
|
question
01
name
|
admin
|
Question
01
text
|
|
|
Test
questions
|
essay
|
question
02
name
|
teacher1
|
Question
02
text
|
qidnum
|
Scenario
:
The questions can be filtered by tag
Given
I log in as
"teacher1"
...
...
@@ -42,9 +42,12 @@ Feature: Adding questions to a quiz from the question bank
And
I navigate to
"Edit quiz"
in current page administration
And
I open the
"last"
add to quiz menu
And
I follow
"from question bank"
Then
I should see
"foo"
in the
"question 01 name"
"table_row"
And
I should see
"bar"
in the
"question 02 name"
"table_row"
And
I should see
"qidnum"
in the
"question 02 name"
"table_row"
And
I set the field
"Filter by tags..."
to
"foo"
And
I press key
"13"
in the field
"Filter by tags..."
Then
I should see
"question 01 name"
in the
"categoryquestions"
"table"
And
I should see
"question 01 name"
in the
"categoryquestions"
"table"
And
I should not see
"question 02 name"
in the
"categoryquestions"
"table"
Scenario
:
The question modal can be paginated
...
...
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