Skip to content
Snippets Groups Projects
Commit 9ecd9f6b authored by Sivaji Ganesh Jojodae's avatar Sivaji Ganesh Jojodae
Browse files

Matching question type result page themeing problem has been fixed

parent 6420f991
No related branches found
No related tags found
No related merge requests found
......@@ -308,10 +308,12 @@ class MatchingResponse extends AbstractQuizQuestionResponse {
//exit;
foreach ($correct_answers as $correct_answer) {
$id = $user_answers[$correct_answer['match_id']];
$theme = ($correct_answer['answer'] == $correct_answers[$id]['answer']) ? 'quiz_score_correct' : 'quiz_score_incorrect';
$rows[] = array(
'match' => $correct_answer['question'],
'correct_answer' => $correct_answer['answer'],
'user_answer' => $correct_answers[$id]['answer']
'correct_answer' => ($showpoints) ? $correct_answer['answer'] : '',
'user_answer' => ($showfeedback) ? $correct_answers[$id]['answer'] : '',
'image' => ($showfeedback) ? array('data' => theme($theme), 'class' => 'quiz_summary_qcell') : '',
);
}
......
......@@ -811,7 +811,7 @@ function theme_quiz_admin_summary($quiz, $questions, $score, $summary) {
drupal_set_title(check_plain($quiz->title));
if (!$score['is_evaluated']) {
drupal_set_message('This quiz has not been scored yet.', 'error');
drupal_set_message(t('This quiz has not been scored yet.'), 'error');
}
// Display overall result.
......@@ -863,13 +863,64 @@ function theme_question_selection_table($form) {
}
function quiz_remove_partial_quiz_record_value() {
$list = array();
/*$list = array();
$list[0] = t('Never');
for ($i=1; $i<31; $i++) {
$list[$i * 86400] = $i . ' ' . t('Day(s)');
}
for ($i=35; $i<125; $i+=5) {
$list[$i * 86400] = $i . ' ' . t('Day(s)');
}
return $list;
}*/
//return $list;
return array(
'0' => t('Never'),
'86400' => t('1 Day'),
'172800' => t('2 Days'),
'259200' => t('3 Days'),
'345600' => t('4 Days'),
'432000' => t('5 Days'),
'518400' => t('6 Days'),
'604800' => t('7 Days'),
'691200' => t('8 Days'),
'777600' => t('9 Days'),
'864000' => t('10 Days'),
'950400' => t('11 Days'),
'1036800' => t('12 Days'),
'1123200' => t('13 Days'),
'1209600' => t('14 Days'),
'1296000' => t('15 Days'),
'1382400' => t('16 Days'),
'1468800' => t('17 Days'),
'1555200' => t('18 Days'),
'1641600' => t('19 Days'),
'1728000' => t('20 Days'),
'1814400' => t('21 Days'),
'1900800' => t('22 Days'),
'1987200' => t('23 Days'),
'2073600' => t('24 Days'),
'2160000' => t('25 Days'),
'2246400' => t('26 Days'),
'2332800' => t('27 Days'),
'2419200' => t('28 Days'),
'2505600' => t('29 Days'),
'2592000' => t('30 Days'),
'3024000' => t('35 Days'),
'3456000' => t('40 Days'),
'3888000' => t('45 Days'),
'4320000' => t('50 Days'),
'4752000' => t('55 Days'),
'5184000' => t('60 Days'),
'5616000' => t('65 Days'),
'6048000' => t('70 Days'),
'6480000' => t('75 Days'),
'6912000' => t('80 Days'),
'7344000' => t('85 Days'),
'7776000' => t('90 Days'),
'8208000' => t('95 Days'),
'8640000' => t('100 Days'),
'9072000' => t('105 Days'),
'9504000' => t('110 Days'),
'9936000' => t('115 Days'),
'10368000' => t('120 Days'),
);
}
......@@ -11,21 +11,21 @@
*/
function quiz_user_results($result_id) {
global $user;
$sql = 'SELECT qnp.nid, qnrs.uid
$sql = 'SELECT qnp.nid, qnrs.uid
FROM {quiz_node_properties} qnp
INNER JOIN {quiz_node_results} qnrs ON qnrs.nid = qnp.nid
WHERE qnrs.result_id = %d';
$result = db_fetch_object(db_query( $sql, $result_id));
if ($result->nid) {
// User can view own results (quiz_menu sets access to 'own results').
// User with role 'user results' can view other user's results.
if ($result->uid != $user->uid && !user_access('view user results')) {
drupal_access_denied();
return;
}
$quiz = node_load($result->nid);
$questions = _quiz_get_answers($result_id);
$score = quiz_calculate_score($quiz, $result_id);
......@@ -45,18 +45,18 @@ function quiz_user_results($result_id) {
*/
function quiz_get_user_results($user_id) {
global $user;
if ($user_id == $user->uid || user_access('view user results')) {
$results = array();
$sql = "SELECT n.nid, n.title, u.name, qnrs.result_id, qnrs.time_start, qnrs.time_end
FROM {node} n
FROM {node} n
INNER JOIN {quiz_node_properties} qnp ON n.nid = qnp.nid
INNER JOIN {quiz_node_results} qnrs ON qnrs.nid = qnp.nid
INNER JOIN {users} u ON u.uid = qnrs.uid
WHERE n.type = 'quiz'
AND u.uid = %d
ORDER BY qnrs.result_id ASC";
$dbresult = db_query($sql, $user_id);
// Create an array out of the results.
while ($line = db_fetch_array($dbresult)) {
......@@ -73,7 +73,7 @@ function quiz_get_user_results($user_id) {
/**
* Theme a message about the quiz's availability for quiz takers.
*
*
* @ingroup themeable
*/
function theme_quiz_availability($node) {
......@@ -97,7 +97,7 @@ function theme_quiz_availability($node) {
/**
* Theme the node view for quizzes.
*
*
* @ingroup themeable
*/
function theme_quiz_view($node, $teaser = FALSE, $page = FALSE) {
......@@ -211,12 +211,12 @@ function theme_quiz_view($node, $teaser = FALSE, $page = FALSE) {
/**
* Theme the user results page.
*
*
* @param $results
* An array of quiz information.
* @return
* Themed html.
*
*
* @ingroup themeable
*/
function theme_quiz_get_user_results($results) {
......@@ -252,7 +252,7 @@ function theme_quiz_get_user_results($results) {
/**
* Theme the filtered question list.
*
*
* @ingroup themeable
*/
function theme_quiz_filtered_questions($form) {
......@@ -289,7 +289,7 @@ function theme_quiz_filtered_questions($form) {
* Array of question nodes.
* @return
* HTML for a table.
*
*
* @ingroup themeable
*/
function theme_quiz_question_table($questions, $quiz_id = NULL) {
......@@ -316,7 +316,7 @@ function theme_quiz_question_table($questions, $quiz_id = NULL) {
/**
* Pass the correct mark to the theme so that theme authors can use an image.
*
*
* @ingroup themeable
*/
function theme_quiz_score_correct() {
......@@ -334,14 +334,14 @@ function theme_quiz_score_incorrect() {
/**
* Theme a progress indicator for use during a quiz.
*
*
* @param $question_number
* The position of the current question in the sessions' array.
* @param $num_of_question
* The number of questions for this quiz as returned by quiz_get_number_of_questions().
* @return
* Themed html.
*
*
* @ingroup themeable
*/
function theme_quiz_progress($question_number, $num_of_question) {
......@@ -361,14 +361,14 @@ function theme_quiz_progress($question_number, $num_of_question) {
/**
* Theme a question page.
*
*
* @param $quiz
* The quiz node object.
* @param $question_node
* The question node.
* @return
* Themed html.
*
*
* @ingroup themeable
*
* @deprecated This should not be used. Rendering is now done through the standard node rendering system.
......@@ -390,7 +390,7 @@ function theme_quiz_take_question($quiz, $question_node) {
/**
* Theme the summary page after the quiz has been completed.
*
*
* @param $quiz
* The quiz node object.
* @param $questions
......@@ -401,22 +401,22 @@ function theme_quiz_take_question($quiz, $question_node) {
* Filtered text of the summary.
* @return
* Themed html.
*
*
* @ingroup themeable
*/
function theme_quiz_take_summary($quiz, $questions, $score, $summary) {
// Set the title here so themers can adjust.
drupal_set_title(check_plain($quiz->title));
// Display overall result.
$output = '';
// Only display scoring information if this is not a personality test:
//if ($score['percentage_score']) {
if (!empty($score['possible_score'])) {
if (!$score['is_evaluated']) {
$msg = t(
'Parts of this @quiz have not been evaluated yet. The score below is not final.',
'Parts of this @quiz have not been evaluated yet. The score below is not final.',
array('@quiz' => QUIZ_NAME)
);
drupal_set_message($msg, 'error');
......@@ -427,13 +427,13 @@ function theme_quiz_take_summary($quiz, $questions, $score, $summary) {
$output .= '<div id="quiz_summary">'. $summary .'</div><br />'."\n";
// Get the feedback for all questions.
$output .= theme('quiz_feedback', $questions, ($quiz->pass_rate > 0), TRUE);
return $output;
}
/**
* Theme the summary page for user results.
*
*
* @param $quiz
* The quiz node object.
* @param $questions
......@@ -444,13 +444,13 @@ function theme_quiz_take_summary($quiz, $questions, $score, $summary) {
* Filtered text of the summary.
* @return
* Themed html.
*
*
* @ingroup themeable
*/
function theme_quiz_user_summary($quiz, $questions, $score, $summary) {
// Set the title here so themers can adjust.
drupal_set_title(check_plain($quiz->title));
if (!$score['is_evaluated']) {
$msg = t('Parts of this @quiz have not been evaluated yet. The score below is not final.', array('@quiz' => QUIZ_NAME));
drupal_set_message($msg, 'status');
......@@ -468,37 +468,38 @@ function theme_quiz_user_summary($quiz, $questions, $score, $summary) {
/**
* Theme the question feedback.
*
*
* @param $questions
* Array of quiz objects as returned by _quiz_get_answers.
* Array of quiz questions objects as returned by _quiz_get_answers.
* @param showpoints
* Binary flag for whether to show the actual answers or not.
* @param $showfeedback
* Binary flag for whether to show question feedback.
* @return
* Themed html.
*
*
* @ingroup themeable
*/
function theme_quiz_feedback($questions, $showpoints = TRUE, $showfeedback = FALSE) {
$header = array(format_plural(count($questions), 'Question Result', 'Question Results'));
$rows = array();
// Go through each of the questions.
foreach ($questions as $question) {
$cols = array();
// Ask each question to render a themed report of how the user did.
$module = quiz_module_for_type($question->type);
$report = theme($module .'_report', $question, $showpoints, $showfeedback);
// Only include reports with actual data:
if (!empty($report) && strlen($report) > 0) {
$cols[] = array('data' => $report, 'class' => 'quiz_summary_qrow');
// Get the score result for each question only if it's a scored quiz.
if ($showpoints) {
if ($showpoints && $question->type != 'matching') {
$theme = ($question->correct) ? 'quiz_score_correct' : 'quiz_score_incorrect';
$cols[] = array('data' => theme($theme), 'class' => 'quiz_summary_qcell');
}
......@@ -506,6 +507,7 @@ function theme_quiz_feedback($questions, $showpoints = TRUE, $showfeedback = FAL
$rows[] = array('data' => $cols, 'class' => 'quiz_summary_qrow');
}
}
return theme('table', $header, $rows);
}
......@@ -520,7 +522,7 @@ function theme_quiz_feedback($questions, $showpoints = TRUE, $showfeedback = FAL
* User's response to previous question.
* @return
* Themed html.
*
*
* @ingroup themeable
*/
function theme_quiz_single_question_feedback($quiz, $report) {
......@@ -532,7 +534,7 @@ function theme_quiz_single_question_feedback($quiz, $report) {
/**
* Allow the option to theme the questions form.
*
*
* @ingroup themeable
*/
function theme_quiz_questions($form) {
......@@ -546,7 +548,7 @@ function theme_quiz_questions($form) {
*
* @return
* Themed html feedback.
*
*
* @ingroup themeable
*/
function theme_quiz_no_feedback() {
......@@ -556,4 +558,3 @@ function theme_quiz_no_feedback() {
function theme_quiz_single_question_node($node) {
return $node->body;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment