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
1c259ce2
Commit
1c259ce2
authored
15 years ago
by
falcon
Browse files
Options
Downloads
Patches
Plain Diff
#635580
reported by neorg: Making feedback after each question work...(not finished yet)
parent
91d6f6e2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
question_types/short_answer/short_answer.classes.inc
+5
-1
5 additions, 1 deletion
question_types/short_answer/short_answer.classes.inc
quiz.module
+32
-34
32 additions, 34 deletions
quiz.module
with
37 additions
and
35 deletions
question_types/short_answer/short_answer.classes.inc
+
5
−
1
View file @
1c259ce2
...
...
@@ -303,7 +303,11 @@ class ShortAnswerResponse extends AbstractQuizQuestionResponse {
}
}
else
{
$this
->
answer
=
$answer
;
if
(
is_array
(
$answer
))
{
$this
->
answer
=
$answer
[
'answer'
];
}
else
{
$this
->
answer
=
$answer
;
}
}
}
...
...
This diff is collapsed.
Click to expand it.
quiz.module
+
32
−
34
View file @
1c259ce2
...
...
@@ -1173,34 +1173,33 @@ function quiz_take_quiz($quiz) {
if
(
!
isset
(
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'result_id'
]))
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'result_id'
]
=
quiz_create_rid
(
$quiz
);
// Previous quiz questions: Questions that have been asked already. We save a record of all of them
// so that a user can navigate backward all the way to the beginning of the quiz.
$_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'
]));
// Call hook_evaluate_question().
$types
=
_quiz_get_question_types
();
$module
=
$types
[
$former_question
->
type
][
'module'
];
$result
=
module_invoke
(
$module
,
'evaluate_question'
,
$former_question
,
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'result_id'
]);
$q_passed_validation
=
$result
->
is_valid
;
quiz_store_question_result
(
$result
,
array
(
'set_msg'
=>
TRUE
));
// Stash feedback in the session, since the $_POST gets cleared.
if
(
$quiz
->
feedback_time
==
QUIZ_FEEDBACK_QUESTION
)
{
// Invoke hook_get_report().
//$report = module_invoke($former_question->type, 'get_report', $former_question_array['nid'], $former_question_array['vid'], $_SESSION['quiz_'. $quiz->nid]['result_id']);
$report
=
module_invoke
(
$module
,
'get_report'
,
$former_question_array
[
'nid'
],
$former_question_array
[
'vid'
],
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'result_id'
]);
$path
=
drupal_get_path
(
'module'
,
'quiz'
);
require_once
(
$path
.
'/quiz.pages.inc'
);
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'feedback'
]
=
rawurlencode
(
drupal_get_form
(
'quiz_report_form'
,
array
(
$report
)));
}
// If anonymous user, refresh url with unique hash to prevent caching.
if
(
!
$user
->
uid
)
{
//drupal_goto('node/'. $quiz->nid .'/quiz/start/'. md5(mt_rand() . time())); #460550
drupal_goto
(
'node/'
.
$quiz
->
nid
,
array
(
'quizkey'
=>
md5
(
mt_rand
()
.
time
())));
}
//}
// Previous quiz questions: Questions that have been asked already. We save a record of all of them
// so that a user can navigate backward all the way to the beginning of the quiz.
$_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'
]));
// Call hook_evaluate_question().
$types
=
_quiz_get_question_types
();
$module
=
$types
[
$former_question
->
type
][
'module'
];
$result
=
module_invoke
(
$module
,
'evaluate_question'
,
$former_question
,
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'result_id'
]);
$q_passed_validation
=
$result
->
is_valid
;
quiz_store_question_result
(
$result
,
array
(
'set_msg'
=>
TRUE
));
// Stash feedback in the session, since the $_POST gets cleared.
if
(
$quiz
->
feedback_time
==
QUIZ_FEEDBACK_QUESTION
)
{
// Invoke hook_get_report().
//$report = module_invoke($former_question->type, 'get_report', $former_question_array['nid'], $former_question_array['vid'], $_SESSION['quiz_'. $quiz->nid]['result_id']);
$report
=
module_invoke
(
$module
,
'get_report'
,
$former_question_array
[
'nid'
],
$former_question_array
[
'vid'
],
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'result_id'
]);
$path
=
drupal_get_path
(
'module'
,
'quiz'
);
require_once
(
$path
.
'/quiz.pages.inc'
);
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'feedback'
]
=
rawurlencode
(
drupal_get_form
(
'quiz_report_form'
,
array
(
$report
)));
}
// If anonymous user, refresh url with unique hash to prevent caching.
if
(
!
$user
->
uid
)
{
//drupal_goto('node/'. $quiz->nid .'/quiz/start/'. md5(mt_rand() . time())); #460550
drupal_goto
(
'node/'
.
$quiz
->
nid
,
array
(
'quizkey'
=>
md5
(
mt_rand
()
.
time
())));
}
}
// Check for a skip.
elseif
(
$_POST
[
'op'
]
==
t
(
'Skip'
)
&&
$allow_skipping
)
{
...
...
@@ -1225,12 +1224,6 @@ function quiz_take_quiz($quiz) {
// The content array:
//$content['body'] = array();
// If we had feedback from the last question.
if
(
isset
(
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'feedback'
])
&&
$quiz
->
feedback_time
==
QUIZ_FEEDBACK_QUESTION
)
{
$content
[
'body'
][
'feedback'
][
'#value'
]
=
rawurldecode
(
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'feedback'
]);
//$output .= rawurldecode($_SESSION['quiz_'. $quiz->nid]['feedback']);
}
// If this quiz is in progress, load the next questions and return it via the theme.
if
(
!
empty
(
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'quiz_questions'
])
||
is_string
(
$q_passed_validation
))
{
if
(
!
is_string
(
$q_passed_validation
))
{
...
...
@@ -1302,6 +1295,11 @@ function quiz_take_quiz($quiz) {
// quiz_node_view() function, which performs the steps in node_view(), but in a way more
// specific to our needs.
$content
[
'body'
][
'#value'
]
=
quiz_node_view
(
$question_node
,
$quiz
);
// If we had feedback from the last question.
if
(
isset
(
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'feedback'
])
&&
$quiz
->
feedback_time
==
QUIZ_FEEDBACK_QUESTION
)
{
$content
[
'body'
][
'feedback'
][
'#value'
]
=
rawurldecode
(
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'feedback'
]);
//$output .= rawurldecode($_SESSION['quiz_'. $quiz->nid]['feedback']);
}
drupal_set_title
(
check_plain
(
$quiz
->
title
));
unset
(
$_SESSION
[
'quiz_'
.
$quiz
->
nid
][
'feedback'
]);
}
...
...
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