Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle-qtype_stack
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
moodle-qtype_stack
Commits
cb63b0b9
Commit
cb63b0b9
authored
3 years ago
by
Chris Sangwin
Browse files
Options
Downloads
Patches
Plain Diff
Resolve issue #767.
parent
0b814af3
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
lang/en/qtype_stack.php
+3
-2
3 additions, 2 deletions
lang/en/qtype_stack.php
questiontestedit.php
+34
-13
34 additions, 13 deletions
questiontestedit.php
questiontestform.php
+1
-1
1 addition, 1 deletion
questiontestform.php
questiontestrun.php
+4
-0
4 additions, 0 deletions
questiontestrun.php
with
42 additions
and
16 deletions
lang/en/qtype_stack.php
+
3
−
2
View file @
cb63b0b9
...
@@ -486,7 +486,7 @@ $string['createtestcase'] = 'Create test case';
...
@@ -486,7 +486,7 @@ $string['createtestcase'] = 'Create test case';
$string
[
'currentlyselectedvariant'
]
=
'This is the variant shown below'
;
$string
[
'currentlyselectedvariant'
]
=
'This is the variant shown below'
;
$string
[
'deletetestcase'
]
=
'Delete test case {$a->no} for question {$a->question}'
;
$string
[
'deletetestcase'
]
=
'Delete test case {$a->no} for question {$a->question}'
;
$string
[
'deletetestcaseareyousure'
]
=
'Are you sure you want to delete test case {$a->no} for question {$a->question}?'
;
$string
[
'deletetestcaseareyousure'
]
=
'Are you sure you want to delete test case {$a->no} for question {$a->question}?'
;
$string
[
'deletethistestcase'
]
=
'Delete this test case.
..
'
;
$string
[
'deletethistestcase'
]
=
'Delete this test case.'
;
$string
[
'deploy'
]
=
'Deploy'
;
$string
[
'deploy'
]
=
'Deploy'
;
$string
[
'deployedprogress'
]
=
'Deploying variants'
;
$string
[
'deployedprogress'
]
=
'Deploying variants'
;
$string
[
'deployedvariants'
]
=
'Deployed variants'
;
$string
[
'deployedvariants'
]
=
'Deployed variants'
;
...
@@ -504,7 +504,8 @@ $string['deploytestall'] = 'Run all tests on all deployed variants (slow): ';
...
@@ -504,7 +504,8 @@ $string['deploytestall'] = 'Run all tests on all deployed variants (slow): ';
$string
[
'deployfromlist'
]
=
'Remove all existing variants and deploy from a list of positive integer seeds, one on each line: '
;
$string
[
'deployfromlist'
]
=
'Remove all existing variants and deploy from a list of positive integer seeds, one on each line: '
;
$string
[
'deployfromlisterror'
]
=
'An error was detected in your list of integers, and so no changes were made to the list of deployed variants.'
;
$string
[
'deployfromlisterror'
]
=
'An error was detected in your list of integers, and so no changes were made to the list of deployed variants.'
;
$string
[
'editingtestcase'
]
=
'Editing test case {$a->no} for question {$a->question}'
;
$string
[
'editingtestcase'
]
=
'Editing test case {$a->no} for question {$a->question}'
;
$string
[
'editthistestcase'
]
=
'Edit this test case...'
;
$string
[
'editthistestcase'
]
=
'Edit this test case.'
;
$string
[
'confirmthistestcase'
]
=
'Confirm current test behaviour.'
;
$string
[
'expectedanswernote'
]
=
'Expected answer note'
;
$string
[
'expectedanswernote'
]
=
'Expected answer note'
;
$string
[
'expectedoutcomes'
]
=
'Expected PRT outcomes: [inputs used]'
;
$string
[
'expectedoutcomes'
]
=
'Expected PRT outcomes: [inputs used]'
;
$string
[
'expectedpenalty'
]
=
'Expected penalty'
;
$string
[
'expectedpenalty'
]
=
'Expected penalty'
;
...
...
This diff is collapsed.
Click to expand it.
questiontestedit.php
+
34
−
13
View file @
cb63b0b9
...
@@ -33,11 +33,12 @@ require_once(__DIR__ . '/stack/potentialresponsetreestate.class.php');
...
@@ -33,11 +33,12 @@ require_once(__DIR__ . '/stack/potentialresponsetreestate.class.php');
// Get the parameters from the URL.
// Get the parameters from the URL.
$questionid
=
required_param
(
'questionid'
,
PARAM_INT
);
$questionid
=
required_param
(
'questionid'
,
PARAM_INT
);
$testcase
=
optional_param
(
'testcase'
,
null
,
PARAM_INT
);
$testcase
=
optional_param
(
'testcase'
,
null
,
PARAM_INT
);
$confirmthistestcase
=
optional_param
(
'confirmthistestcase'
,
null
,
PARAM_INT
);
// Load the necessary data.
// Load the necessary data.
$questiondata
=
$DB
->
get_record
(
'question'
,
array
(
'id'
=>
$questionid
),
'*'
,
MUST_EXIST
);
$questiondata
=
$DB
->
get_record
(
'question'
,
array
(
'id'
=>
$questionid
),
'*'
,
MUST_EXIST
);
$question
=
question_bank
::
load_question
(
$questionid
);
$question
=
question_bank
::
load_question
(
$questionid
);
if
(
$testcase
)
{
if
(
$testcase
||
$confirmthistestcase
)
{
$qtest
=
question_bank
::
get_qtype
(
'stack'
)
->
load_question_test
(
$questionid
,
$testcase
);
$qtest
=
question_bank
::
get_qtype
(
'stack'
)
->
load_question_test
(
$questionid
,
$testcase
);
}
}
...
@@ -57,18 +58,6 @@ if (!is_null($testcase)) {
...
@@ -57,18 +58,6 @@ if (!is_null($testcase)) {
$submitlabel
=
stack_string
(
'createtestcase'
);
$submitlabel
=
stack_string
(
'createtestcase'
);
}
}
// Initialise $PAGE.
$backurl
=
new
moodle_url
(
'/question/type/stack/questiontestrun.php'
,
$urlparams
);
if
(
!
is_null
(
$testcase
))
{
$urlparams
[
'testcase'
]
=
$testcase
;
}
$PAGE
->
set_url
(
'/question/type/stack/questiontestedit.php'
,
$urlparams
);
$PAGE
->
set_title
(
$title
);
$PAGE
->
set_heading
(
$title
);
$PAGE
->
set_pagelayout
(
'popup'
);
require_login
();
// Create the question usage we will use.
// Create the question usage we will use.
$quba
=
question_engine
::
make_questions_usage_by_activity
(
'qtype_stack'
,
$context
);
$quba
=
question_engine
::
make_questions_usage_by_activity
(
'qtype_stack'
,
$context
);
$quba
->
set_preferred_behaviour
(
'adaptive'
);
$quba
->
set_preferred_behaviour
(
'adaptive'
);
...
@@ -81,6 +70,20 @@ if (!is_null($seed)) {
...
@@ -81,6 +70,20 @@ if (!is_null($seed)) {
$slot
=
$quba
->
add_question
(
$question
,
$question
->
defaultmark
);
$slot
=
$quba
->
add_question
(
$question
,
$question
->
defaultmark
);
$quba
->
start_question
(
$slot
);
$quba
->
start_question
(
$slot
);
// Initialise $PAGE.
$backurl
=
new
moodle_url
(
'/question/type/stack/questiontestrun.php'
,
$urlparams
);
if
(
!
is_null
(
$testcase
))
{
$urlparams
[
'testcase'
]
=
$testcase
;
}
$PAGE
->
set_url
(
'/question/type/stack/questiontestedit.php'
,
$urlparams
);
$PAGE
->
set_title
(
$title
);
$PAGE
->
set_heading
(
$title
);
$PAGE
->
set_pagelayout
(
'popup'
);
require_login
();
// Create the editing form.
// Create the editing form.
$mform
=
new
qtype_stack_question_test_form
(
$PAGE
->
url
,
$mform
=
new
qtype_stack_question_test_form
(
$PAGE
->
url
,
array
(
'submitlabel'
=>
$submitlabel
,
'question'
=>
$question
));
array
(
'submitlabel'
=>
$submitlabel
,
'question'
=>
$question
));
...
@@ -114,7 +117,25 @@ if ($testcase) {
...
@@ -114,7 +117,25 @@ if ($testcase) {
if
(
$mform
->
is_cancelled
())
{
if
(
$mform
->
is_cancelled
())
{
unset
(
$urlparams
[
'testcase'
]);
unset
(
$urlparams
[
'testcase'
]);
redirect
(
$backurl
);
redirect
(
$backurl
);
}
else
if
(
$confirmthistestcase
)
{
$inputs
=
array
();
foreach
(
$qtest
->
inputs
as
$name
=>
$value
)
{
$inputs
[
$name
]
=
$value
;
}
$qtest
=
new
stack_question_test
(
$inputs
);
$response
=
stack_question_test
::
compute_response
(
$question
,
$inputs
);
foreach
(
$question
->
prts
as
$prtname
=>
$prt
)
{
$result
=
$question
->
get_prt_result
(
$prtname
,
$response
,
false
);
// For testing purposes we just take the last note.
$answernotes
=
$result
->
get_answernotes
();
$answernote
=
array
(
end
(
$answernotes
));
$qtest
->
add_expected_result
(
$prtname
,
new
stack_potentialresponse_tree_state
(
1
,
true
,
$result
->
get_score
(),
$result
->
get_penalty
(),
''
,
$answernote
));
}
question_bank
::
get_qtype
(
'stack'
)
->
save_question_test
(
$questionid
,
$qtest
,
$testcase
);
redirect
(
$backurl
);
}
else
if
(
$data
=
$mform
->
get_data
())
{
}
else
if
(
$data
=
$mform
->
get_data
())
{
// Process form submission.
// Process form submission.
$inputs
=
array
();
$inputs
=
array
();
...
...
This diff is collapsed.
Click to expand it.
questiontestform.php
+
1
−
1
View file @
cb63b0b9
...
@@ -28,7 +28,7 @@ require_once($CFG->libdir . '/formslib.php');
...
@@ -28,7 +28,7 @@ require_once($CFG->libdir . '/formslib.php');
/**
/**
* The editing form for editing question tests.
* The editing form for editing
STACK
question tests.
*
*
* @copyright 2012 the Open University
* @copyright 2012 the Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
...
...
This diff is collapsed.
Click to expand it.
questiontestrun.php
+
4
−
0
View file @
cb63b0b9
...
@@ -500,6 +500,10 @@ foreach ($testresults as $key => $result) {
...
@@ -500,6 +500,10 @@ foreach ($testresults as $key => $result) {
$urlparams
+
array
(
'testcase'
=>
$key
)),
$urlparams
+
array
(
'testcase'
=>
$key
)),
stack_string
(
'editthistestcase'
,
'qtype_stack'
),
'get'
);
stack_string
(
'editthistestcase'
,
'qtype_stack'
),
'get'
);
echo
$OUTPUT
->
single_button
(
new
moodle_url
(
'/question/type/stack/questiontestedit.php'
,
$urlparams
+
array
(
'testcase'
=>
$key
,
'confirmthistestcase'
=>
true
)),
stack_string
(
'confirmthistestcase'
,
'qtype_stack'
),
'get'
);
echo
$OUTPUT
->
single_button
(
new
moodle_url
(
'/question/type/stack/questiontestdelete.php'
,
echo
$OUTPUT
->
single_button
(
new
moodle_url
(
'/question/type/stack/questiontestdelete.php'
,
$urlparams
+
array
(
'testcase'
=>
$key
)),
$urlparams
+
array
(
'testcase'
=>
$key
)),
stack_string
(
'deletethistestcase'
,
'qtype_stack'
),
'get'
);
stack_string
(
'deletethistestcase'
,
'qtype_stack'
),
'get'
);
...
...
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