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
b99ff43e
Commit
b99ff43e
authored
4 years ago
by
Chris Sangwin
Browse files
Options
Downloads
Patches
Plain Diff
WIP fix to issue #724.
parent
9534e652
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
deploy.php
+54
-0
54 additions, 0 deletions
deploy.php
lang/en/qtype_stack.php
+2
-0
2 additions, 0 deletions
lang/en/qtype_stack.php
questiontestrun.php
+44
-20
44 additions, 20 deletions
questiontestrun.php
with
100 additions
and
20 deletions
deploy.php
+
54
−
0
View file @
b99ff43e
...
...
@@ -77,6 +77,60 @@ if (!is_null($undeploy) && $question->deployedseeds) {
redirect
(
$nexturl
);
}
// Process undeployall if applicable.
$deployfromlist
=
optional_param
(
'deployfromlist'
,
null
,
PARAM_INT
);
if
(
!
is_null
(
$deployfromlist
))
{
// Check data integrity.
$dataproblem
=
false
;
$deploytxt
=
optional_param
(
'deployfromlist'
,
null
,
PARAM_TEXT
);
$newseeds
=
explode
(
"
\n
"
,
$deploytxt
);
foreach
(
$newseeds
as
$var
=>
$seed
)
{
// Clean up whitespace.
$newseeds
[
$var
]
=
trim
(
$seed
);
// Force the entry to be a positive integer.
$newseeds
[
$var
]
=
(
int
)
(
$newseeds
[
$var
]);
if
(
$newseeds
[
$var
]
<=
0
)
{
$dataproblem
=
true
;
}
$newseeds
[
$var
]
=
(
string
)
(
$newseeds
[
$var
]);
}
// No action to take?
if
(
$newseeds
===
$question
->
deployedseeds
)
{
redirect
(
$nexturl
);
}
if
(
count
(
$newseeds
)
>
100
)
{
$nexturl
->
param
(
'deployfeedbackerr'
,
stack_string
(
'deploymanyerror'
,
array
(
'err'
=>
count
(
$newseeds
))));
redirect
(
$nexturl
);
}
// Check the entries are all different.
if
(
count
(
$newseeds
)
!==
count
(
array_flip
(
$newseeds
)))
{
// TODO: specific feedback for each error.
$dataproblem
=
true
;
}
if
(
$dataproblem
)
{
$nexturl
->
param
(
'deployfeedbackerr'
,
stack_string
(
'deployfromlisterror'
));
redirect
(
$nexturl
);
}
// Undeploy all existing variants.
if
(
$question
->
deployedseeds
)
{
foreach
(
$question
->
deployedseeds
as
$seed
)
{
$question
->
undeploy_variant
(
$seed
);
}
}
// Deploy all new variants.
foreach
(
$newseeds
as
$seed
)
{
$question
->
deploy_variant
(
$seed
);
}
redirect
(
$nexturl
);
}
$deploy
=
optional_param
(
'deploymany'
,
null
,
PARAM_INT
);
$deploytxt
=
optional_param
(
'deploymany'
,
null
,
PARAM_TEXT
);
$starttime
=
time
();
...
...
This diff is collapsed.
Click to expand it.
lang/en/qtype_stack.php
+
2
−
0
View file @
b99ff43e
...
...
@@ -499,6 +499,8 @@ $string['deploymanysuccess'] = 'Number of new variants successfully created, tes
$string
[
'deployoutoftime'
]
=
'Time limit exceeded by using approx {$a->time} seconds. Please try again to deploy more.'
;
$string
[
'deployremoveall'
]
=
'Undeploy all variants: '
;
$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
[
'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
[
'editthistestcase'
]
=
'Edit this test case...'
;
$string
[
'expectedanswernote'
]
=
'Expected answer note'
;
...
...
This diff is collapsed.
Click to expand it.
questiontestrun.php
+
44
−
20
View file @
b99ff43e
...
...
@@ -263,6 +263,17 @@ if (!$variantmatched) {
array
(
'class'
=>
'undeployedvariant'
));
}
if
(
!
(
empty
(
$question
->
deployedseeds
))
&&
$canedit
)
{
// Undeploy all the variants.
echo
html_writer
::
start_tag
(
'form'
,
array
(
'method'
=>
'get'
,
'class'
=>
'deploymany'
,
'action'
=>
new
moodle_url
(
'/question/type/stack/deploy.php'
,
$urlparams
)));
echo
stack_string
(
'deployremoveall'
);
echo
html_writer
::
input_hidden_params
(
new
moodle_url
(
$PAGE
->
url
,
array
(
'sesskey'
=>
sesskey
(),
'undeployall'
=>
'true'
)));
echo
' '
.
html_writer
::
empty_tag
(
'input'
,
array
(
'type'
=>
'submit'
,
'value'
=>
get_string
(
'go'
)));
echo
html_writer
::
end_tag
(
'form'
);
}
// Add in some logic for a case where the author removes randomization after variants have been deployed.
if
(
$question
->
has_random_variants
())
{
echo
html_writer
::
start_tag
(
'p'
);
...
...
@@ -277,15 +288,6 @@ if ($question->has_random_variants()) {
echo
html_writer
::
end_tag
(
'form'
);
if
(
$canedit
)
{
// Run tests on all the variants.
echo
html_writer
::
start_tag
(
'form'
,
array
(
'method'
=>
'get'
,
'class'
=>
'deploymany'
,
'action'
=>
new
moodle_url
(
'/question/type/stack/questiontestrun.php'
,
$urlparams
)));
echo
stack_string
(
'deploytestall'
);
echo
html_writer
::
input_hidden_params
(
new
moodle_url
(
$PAGE
->
url
,
array
(
'sesskey'
=>
sesskey
(),
'testall'
=>
'1'
)));
echo
' '
.
html_writer
::
empty_tag
(
'input'
,
array
(
'type'
=>
'submit'
,
'value'
=>
get_string
(
'go'
)));
echo
html_writer
::
end_tag
(
'form'
);
// Deploy many variants.
echo
html_writer
::
start_tag
(
'form'
,
array
(
'method'
=>
'get'
,
'class'
=>
'deploymany'
,
'action'
=>
new
moodle_url
(
'/question/type/stack/deploy.php'
,
$urlparams
)));
...
...
@@ -296,20 +298,42 @@ if ($question->has_random_variants()) {
echo
' '
.
html_writer
::
empty_tag
(
'input'
,
array
(
'type'
=>
'submit'
,
'value'
=>
get_string
(
'go'
)));
echo
' '
.
stack_string
(
'deploymanynotes'
);
echo
html_writer
::
end_tag
(
'form'
);
}
echo
html_writer
::
end_tag
(
'p'
);
}
if
(
!
(
empty
(
$question
->
deployedseeds
))
&&
$canedit
)
{
// Undeploy all the variants.
echo
html_writer
::
start_tag
(
'form'
,
array
(
'method'
=>
'get'
,
'class'
=>
'deploymany'
,
// Deploy many from a CS list of integer seeds.
echo
"
\n
"
.
html_writer
::
start_tag
(
'form'
,
array
(
'method'
=>
'get'
,
'class'
=>
'deployfromlist'
,
'action'
=>
new
moodle_url
(
'/question/type/stack/deploy.php'
,
$urlparams
)));
echo
stack_string
(
'deployremoveall'
);
echo
html_writer
::
input_hidden_params
(
new
moodle_url
(
$PAGE
->
url
,
array
(
'sesskey'
=>
sesskey
())),
array
(
'seed'
));
echo
"
\n
<table>"
.
html_writer
::
start_tag
(
'table'
);
echo
html_writer
::
start_tag
(
'tr'
);
echo
html_writer
::
start_tag
(
'td'
);
echo
stack_string
(
'deployfromlist'
);
echo
html_writer
::
end_tag
(
'td'
);
echo
html_writer
::
start_tag
(
'td'
);
echo
' '
.
html_writer
::
start_tag
(
'textarea'
,
array
(
'cols'
=>
15
,
'rows'
=>
count
(
$question
->
deployedseeds
),
'id'
=>
'deployfromlist'
,
'name'
=>
'deployfromlist'
,
'value'
=>
''
));
echo
html_writer
::
end_tag
(
'textarea'
);
echo
html_writer
::
end_tag
(
'td'
);
echo
html_writer
::
start_tag
(
'td'
);
echo
' '
.
html_writer
::
tag
(
'tt'
,
implode
(
"<br />"
,
$question
->
deployedseeds
));
echo
html_writer
::
end_tag
(
'td'
);
echo
html_writer
::
start_tag
(
'td'
);
echo
' '
.
html_writer
::
empty_tag
(
'input'
,
array
(
'type'
=>
'submit'
,
'value'
=>
get_string
(
'go'
)));
echo
html_writer
::
end_tag
(
'td'
);
echo
html_writer
::
end_tag
(
'tr'
);
echo
"
\n
"
.
html_writer
::
end_tag
(
'table'
);
echo
"
\n
"
.
html_writer
::
end_tag
(
'form'
);
// Run tests on all the variants.
echo
html_writer
::
start_tag
(
'form'
,
array
(
'method'
=>
'get'
,
'class'
=>
'deploymany'
,
'action'
=>
new
moodle_url
(
'/question/type/stack/questiontestrun.php'
,
$urlparams
)));
echo
stack_string
(
'deploytestall'
);
echo
html_writer
::
input_hidden_params
(
new
moodle_url
(
$PAGE
->
url
,
array
(
'sesskey'
=>
sesskey
(),
'
undeploy
all'
=>
'
true
'
)));
'
test
all'
=>
'
1
'
)));
echo
' '
.
html_writer
::
empty_tag
(
'input'
,
array
(
'type'
=>
'submit'
,
'value'
=>
get_string
(
'go'
)));
echo
html_writer
::
end_tag
(
'form'
);
}
echo
html_writer
::
end_tag
(
'p'
);
}
echo
$OUTPUT
->
heading
(
stack_string
(
'questiontestsfor'
,
$seed
),
2
);
...
...
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