Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quiz-3218427
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-3218427
Commits
e6435508
Commit
e6435508
authored
17 years ago
by
Joshua Ellinger
Browse files
Options
Downloads
Patches
Plain Diff
Backwards navigation is now supported
Issue
#84863
by awong
parent
f55ef856
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.txt
+1
-0
1 addition, 0 deletions
CHANGELOG.txt
multichoice.module
+20
-3
20 additions, 3 deletions
multichoice.module
quiz.module
+33
-8
33 additions, 8 deletions
quiz.module
with
54 additions
and
11 deletions
CHANGELOG.txt
+
1
−
0
View file @
e6435508
...
...
@@ -6,6 +6,7 @@ Changes since quiz version 1.1
- Added additional permission options.
- Added feedback ranges
- Added support for feedback options by category
- Added support for backwards navigation
- Questions on quiz now in groupings based on how they are placed within a quiz
- Added support for revisions
- Schema overhaul
...
...
This diff is collapsed.
Click to expand it.
multichoice.module
+
20
−
3
View file @
e6435508
...
...
@@ -557,6 +557,14 @@ function multichoice_render_question_form($node) {
'#options'
=>
$options
,
'#default_value'
=>
-
1
,
);
$quiz
=
node_load
(
arg
(
1
));
if
(
$quiz
->
backwards_navigation
==
1
&&
$node
->
question_number
)
{
$form
[
'back'
]
=
array
(
'#type'
=>
'submit'
,
'#value'
=>
t
(
'Back'
),
);
}
$form
[
'submit'
]
=
array
(
'#type'
=>
'submit'
,
...
...
@@ -612,9 +620,18 @@ function multichoice_evaluate_question($question, $rid = null) {
* The answer id.
*/
function
multichoice_store_answer
(
$nid
,
$vid
,
$rid
,
$answer_id
)
{
db_query
(
"INSERT INTO
{
quiz_multichoice_user_answers
}
"
.
"(question_nid, question_vid, result_id, answer_id) "
.
"VALUES (%d, %d, %d, %d)"
,
$nid
,
$vid
,
$rid
,
$answer_id
);
$result
=
db_query
(
"SELECT result_id FROM
{
quiz_multichoice_user_answers
}
WHERE question_nid = %d AND question_vid = %d AND result_id = %d"
,
$nid
,
$vid
,
$rid
);
if
(
db_num_rows
(
$result
))
{
db_query
(
"UPDATE
{
quiz_multichoice_user_answers
}
"
.
"SET answer_id = %d "
.
"WHERE question_nid = %d AND question_vid = %d AND result_id = %d"
,
$answer_id
,
$nid
,
$vid
,
$rid
);
}
else
{
db_query
(
"INSERT INTO
{
quiz_multichoice_user_answers
}
"
.
"(question_nid, question_vid, result_id, answer_id) "
.
"VALUES (%d, %d, %d, %d)"
,
$nid
,
$vid
,
$rid
,
$answer_id
);
}
}
/**
...
...
This diff is collapsed.
Click to expand it.
quiz.module
+
33
−
8
View file @
e6435508
...
...
@@ -231,6 +231,13 @@ function quiz_form(&$node) {
'#default_value'
=>
(
isset
(
$node
->
shuffle
)
?
$node
->
shuffle
:
1
),
'#description'
=>
t
(
'Whether to shuffle/randomize the questions on the @quiz'
,
array
(
'@quiz'
=>
QUIZ_NAME
)),
);
$form
[
'backwards_navigation'
]
=
array
(
'#type'
=>
'checkbox'
,
'#title'
=>
t
(
'Backwards navigation'
),
'#default_value'
=>
$node
->
backwards_navigation
,
'#description'
=>
t
(
'Whether to allow user to go back and revisit their answers'
),
);
$form
[
'feedback_time'
]
=
array
(
'#title'
=>
t
(
'Feedback Time'
),
...
...
@@ -533,9 +540,10 @@ function quiz_insert($node) {
quiz_translate_form_date
(
$node
,
'quiz_open'
);
quiz_translate_form_date
(
$node
,
'quiz_close'
);
$sql
=
"INSERT INTO
{
quiz_node_properties
}
"
.
"(vid, nid, number_of_random_questions, shuffle, quiz_open, quiz_close, takes, pass_rate, summary_pass, summary_default, quiz_always, feedback_time, tid) "
.
"(vid, nid, number_of_random_questions, shuffle,
backwards_navigation,
quiz_open, quiz_close, takes, pass_rate, summary_pass, summary_default, quiz_always, feedback_time, tid) "
.
"VALUES(%d, %d, %d, %d, %d, %d, %d, %d, '%s', '%s', %d, %d, %d)"
;
db_query
(
$sql
,
$node
->
vid
,
$node
->
nid
,
$node
->
number_of_random_questions
,
$node
->
shuffle
,
$node
->
quiz_open
,
$node
->
quiz_close
,
$node
->
takes
,
$node
->
pass_rate
,
$node
->
summary_pass
,
$node
->
summary_default
,
$node
->
quiz_always
,
$node
->
feedback_time
,
$node
->
tid
);
db_query
(
$sql
,
$node
->
vid
,
$node
->
nid
,
$node
->
number_of_random_questions
,
$node
->
shuffle
,
$node
->
backwards_navigation
,
$node
->
quiz_open
,
$node
->
quiz_close
,
$node
->
takes
,
$node
->
pass_rate
,
$node
->
summary_pass
,
$node
->
summary_default
,
$node
->
quiz_always
,
$node
->
feedback_time
,
$node
->
tid
);
_quiz_insert_resultoptions
(
$node
);
}
...
...
@@ -600,6 +608,7 @@ function quiz_update($node) {
UPDATE
{
quiz_node_properties
}
SET
vid = %d,
shuffle = %d,
backwards_navigation = %d,
quiz_open = %d,
quiz_close = %d,
takes = %d,
...
...
@@ -612,7 +621,7 @@ function quiz_update($node) {
vid = %d AND
nid = %d
"
;
db_query
(
$sql
,
$node
->
vid
,
$node
->
shuffle
,
$node
->
quiz_open
,
$node
->
quiz_close
,
$node
->
takes
,
$node
->
pass_rate
,
$node
->
summary_pass
,
$node
->
summary_default
,
$node
->
quiz_always
,
$node
->
feedback_time
,
$node
->
vid
,
$node
->
nid
);
db_query
(
$sql
,
$node
->
vid
,
$node
->
shuffle
,
$node
->
backwards_navigation
,
$node
->
quiz_open
,
$node
->
quiz_close
,
$node
->
takes
,
$node
->
pass_rate
,
$node
->
summary_pass
,
$node
->
summary_default
,
$node
->
quiz_always
,
$node
->
feedback_time
,
$node
->
vid
,
$node
->
nid
);
}
_quiz_update_resultoptions
(
$node
);
}
...
...
@@ -910,12 +919,19 @@ function quiz_take_quiz() {
}
}
if
(
$_POST
[
'op'
]
==
t
(
'Back'
))
{
unset
(
$_POST
[
'tries'
]);
array_unshift
(
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'quiz_questions'
],
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'previous_quiz_questions'
]);
}
// Check for answer submission.
if
(
$_POST
[
'op'
]
==
t
(
'Submit'
))
{
if
(
!
isset
(
$_POST
[
'tries'
]))
{
drupal_set_message
(
t
(
'You must select an answer before you can progress to the next question!'
),
'error'
);
}
else
{
unset
(
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'previous_quiz_questions'
]);
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'previous_quiz_questions'
]
=
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'quiz_questions'
][
0
];
$former_question_array
=
array_shift
(
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'quiz_questions'
]);
$former_question
=
node_load
(
array
(
'nid'
=>
$former_question_array
[
'nid'
]));
$result
=
module_invoke
(
$former_question
->
type
,
'evaluate_question'
,
$former_question
,
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'result_id'
]);
...
...
@@ -977,10 +993,19 @@ function quiz_take_quiz() {
* Store a quiz question result.
*/
function
quiz_store_question_result
(
$nid
,
$vid
,
$rid
,
$is_correct
)
{
db_query
(
"INSERT INTO
{
quiz_node_results_answers
}
"
.
"(question_nid, question_vid, result_id, is_correct, points_awarded, answer_timestamp) "
.
"VALUES (%d, %d, %d, %d, %d, %d)"
,
$nid
,
$vid
,
$rid
,
$is_correct
,
(
$is_correct
)
?
1
:
0
,
time
());
$result
=
db_query
(
"SELECT result_id FROM
{
quiz_node_results_answers
}
WHERE question_nid = %d AND question_vid = %d AND result_id = %d"
,
$nid
,
$vid
,
$rid
);
if
(
db_num_rows
(
$result
))
{
db_query
(
"UPDATE
{
quiz_node_results_answers
}
"
.
"SET is_correct = %d, points_awarded = %d, answer_timestamp = %d "
.
"WHERE question_nid = %d AND question_vid = %d AND result_id = %d"
,
$is_correct
,
(
$is_correct
)
?
1
:
0
,
time
(),
$nid
,
$vid
,
$rid
);
}
else
{
db_query
(
"INSERT INTO
{
quiz_node_results_answers
}
"
.
"(question_nid, question_vid, result_id, is_correct, points_awarded, answer_timestamp) "
.
"VALUES (%d, %d, %d, %d, %d, %d)"
,
$nid
,
$vid
,
$rid
,
$is_correct
,
(
$is_correct
)
?
1
:
0
,
time
());
}
}
/**
...
...
@@ -2272,7 +2297,7 @@ function theme_quiz_take_question($quiz, $question_node) {
//Calculation for quiz progress bar.
$number_of_questions
=
quiz_get_number_of_questions
(
$quiz
->
vid
,
$quiz
->
nid
);
$question_number
=
$number_of_questions
-
count
(
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'quiz_questions'
]);
$question_node
->
question_number
=
$question_number
;
// Set the title here in case themers want to do something different.
drupal_set_title
(
check_plain
(
$quiz
->
title
));
...
...
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