Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quiz-3346955
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
quiz-3346955
Commits
1ee7639f
Commit
1ee7639f
authored
15 years ago
by
falcon
Browse files
Options
Downloads
Patches
Plain Diff
#652186
reported by biocomp.pat: quiz_validate problems
parent
3e746ecd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
quiz.module
+19
-16
19 additions, 16 deletions
quiz.module
with
19 additions
and
16 deletions
quiz.module
+
19
−
16
View file @
1ee7639f
...
...
@@ -405,9 +405,8 @@ function quiz_form_alter(&$form, $form_state, $form_id) {
* Implementation of hook_insert().
*/
function
quiz_insert
(
$node
)
{
quiz_translate_form_date
(
$node
,
'quiz_open'
);
quiz_translate_form_date
(
$node
,
'quiz_close'
);
_quiz_common_presave_actions
(
$node
);
$tid
=
(
isset
(
$node
->
tid
)
?
$node
->
tid
:
0
);
if
(
!
isset
(
$node
->
has_userpoints
))
{
...
...
@@ -441,8 +440,7 @@ function quiz_update($node) {
// Quiz node vid (revision) was not updated.
else
{
// Update an existing row in the quiz_node_properties table.
quiz_translate_form_date
(
$node
,
'quiz_open'
);
quiz_translate_form_date
(
$node
,
'quiz_close'
);
_quiz_common_presave_actions
(
$node
);
$sql
=
"UPDATE
{
quiz_node_properties
}
SET vid = %d,
aid='%s',
...
...
@@ -476,6 +474,12 @@ function quiz_update($node) {
_quiz_update_resultoptions
(
$node
);
}
function
_quiz_common_presave_actions
(
&
$node
)
{
quiz_translate_form_date
(
$node
,
'quiz_open'
);
quiz_translate_form_date
(
$node
,
'quiz_close'
);
if
(
empty
(
$node
->
pass_rate
))
$node
->
pass_rate
=
0
;
}
/**
* Implementation of hook_delete().
*/
...
...
@@ -839,14 +843,16 @@ function quiz_validate($node) {
if
(
mktime
(
0
,
0
,
0
,
$node
->
quiz_open
[
'month'
],
$node
->
quiz_open
[
'day'
],
$node
->
quiz_open
[
'year'
])
>
mktime
(
0
,
0
,
0
,
$node
->
quiz_close
[
'month'
],
$node
->
quiz_close
[
'day'
],
$node
->
quiz_close
[
'year'
]))
{
form_set_error
(
'quiz_close'
,
t
(
'Please make sure the close date is after the open date.'
));
}
if
(
!
is_numeric
(
$node
->
pass_rate
))
{
form_set_error
(
'pass_rate'
,
t
(
'The pass rate value must be a number between 0% and 100%.'
));
}
if
(
$node
->
pass_rate
>
100
)
{
form_set_error
(
'pass_rate'
,
t
(
'The pass rate value must not be more than 100%.'
));
}
if
(
$node
->
pass_rate
<
0
)
{
form_set_error
(
'pass_rate'
,
t
(
'The pass rate value must not be less than 0%.'
));
if
(
!
empty
(
$node
->
pass_rate
))
{
if
(
!
is_numeric
(
$node
->
pass_rate
))
{
form_set_error
(
'pass_rate'
,
t
(
'The pass rate value must be a number between 0% and 100%.'
));
}
if
(
$node
->
pass_rate
>
100
)
{
form_set_error
(
'pass_rate'
,
t
(
'The pass rate value must not be more than 100%.'
));
}
if
(
$node
->
pass_rate
<
0
)
{
form_set_error
(
'pass_rate'
,
t
(
'The pass rate value must not be less than 0%.'
));
}
}
if
(
isset
(
$node
->
time_limit
))
{
...
...
@@ -897,9 +903,6 @@ function quiz_validate($node) {
form_set_error
(
'option_summary'
,
t
(
'Option has a summary, but no name.'
));
}
}
if
(
$node
->
pass_rate
==
0
&&
!
$num_options
)
{
form_set_error
(
'pass_rate'
,
t
(
'Unscored quiz, but no result options defined.'
));
}
}
/**
* Implementation of hook_nodeapi()
...
...
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