summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsivaji2012-12-30 14:37:27 (GMT)
committer sivaji2012-12-30 14:37:27 (GMT)
commit85af411a638f3fdf696e87c9f68111bcf5423c0c (patch)
tree70f6f79d344c1b2dd8d351444c113109dc495f58
parent8063383a61c74df5b3f11dd6773285f22a0a1fe0 (diff)
parentfdb20b9430c0c2d78ea70a07de3000b10640d795 (diff)
Merge branch '7.x-4.x' of git.drupal.org:project/quiz into 7.x-4.x
-rw-r--r--includes/views/quiz.views.inc12
-rw-r--r--question_types/long_answer/long_answer.module16
-rw-r--r--question_types/matching/matching.module16
-rw-r--r--question_types/multichoice/multichoice.module13
-rw-r--r--question_types/quiz_directions/quiz_directions.classes.inc2
-rw-r--r--question_types/short_answer/short_answer.module16
-rw-r--r--question_types/truefalse/truefalse.module21
-rw-r--r--quiz.admin.inc2
-rw-r--r--quiz.module43
-rw-r--r--quiz.pages.inc3
10 files changed, 95 insertions, 49 deletions
diff --git a/includes/views/quiz.views.inc b/includes/views/quiz.views.inc
index 9b6119c..afc3396 100644
--- a/includes/views/quiz.views.inc
+++ b/includes/views/quiz.views.inc
@@ -15,6 +15,9 @@ function quiz_views_handlers() {
'quiz_views_handler_field_takes' => array(
'parent' => 'views_handler_field',
),
+ 'quiz_views_handler_field_node_link_take' => array(
+ 'parent' => 'views_handler_field_node_link',
+ ),
'quiz_views_handler_field_time' => array(
'parent' => 'views_handler_field',
),
@@ -270,6 +273,15 @@ function quiz_views_data() {
),
'sort' => array('handler' => 'views_handler_sort'),
),
+ 'take' => array(
+ 'field' => array(
+ 'title' => t('Take quiz link'),
+ 'help' => t('Allows users to take the quiz if available.'),
+ 'handler' => 'quiz_views_handler_field_node_link_take',
+ 'click sortable' => TRUE,
+ ),
+ 'sort' => array('handler' => 'views_handler_sort'),
+ ),
'tid' => array(
'title' => t('Term ID'),
'help' => t('The term ID used to select questions based on taxonomy.'),
diff --git a/question_types/long_answer/long_answer.module b/question_types/long_answer/long_answer.module
index a3d058b..b0f77a6 100644
--- a/question_types/long_answer/long_answer.module
+++ b/question_types/long_answer/long_answer.module
@@ -291,3 +291,19 @@ function long_answer_report_validate($values, $form_key) {
form_set_error($form_key . '][score', t('The score needs to be a number between @min and @max', array('@min' => 0, '@max' => $max)));
}
}
+
+/**
+ * Implements hook_field_extra_fields().
+ */
+function long_answer_field_extra_fields() {
+ $extra['node']['long_answer'] = array(
+ 'form' => array(
+ 'rubric' => array(
+ 'label' => t('Rubric'),
+ 'description' => t('Specify the criteria for grading the response'),
+ 'weight' => -4,
+ ),
+ ),
+ );
+ return $extra;
+}
diff --git a/question_types/matching/matching.module b/question_types/matching/matching.module
index 1f55f6b..cb1ce76 100644
--- a/question_types/matching/matching.module
+++ b/question_types/matching/matching.module
@@ -102,3 +102,19 @@ function matching_theme() {
);
}
+
+/**
+ * Implements hook_field_extra_fields().
+ */
+function matching_field_extra_fields() {
+ $extra['node']['matching'] = array(
+ 'form' => array(
+ 'match' => array(
+ 'label' => t('Answer'),
+ 'description' => t('The sets of matches for this question.'),
+ 'weight' => -4,
+ ),
+ ),
+ );
+ return $extra;
+}
diff --git a/question_types/multichoice/multichoice.module b/question_types/multichoice/multichoice.module
index 8db4185..a75ee3b 100644
--- a/question_types/multichoice/multichoice.module
+++ b/question_types/multichoice/multichoice.module
@@ -84,10 +84,11 @@ function multichoice_config_validate($form, $form_state) {
* Implements hook_theme().
*/
function multichoice_theme($existing, $type, $theme, $path) {
+ $path = drupal_get_path('module', 'multichoice') . '/theme';
return array(
'multichoice_creation_form' => array(
'render element' => 'form',
- 'path' => drupal_get_path('module', 'multichoice') . '/theme',
+ 'path' => $path,
'file' => 'multichoice.theme.inc',
),
'multichoice_answer_node_view' => array(
@@ -95,29 +96,29 @@ function multichoice_theme($existing, $type, $theme, $path) {
'alternatives' => NULL,
'show_correct' => NULL,
),
- 'path' => drupal_get_path('module', 'multichoice') . '/theme',
+ 'path' => $path,
'file' => 'multichoice.theme.inc',
),
'multichoice_response' => array(
'variables' => array(
'data' => array(),
),
- 'path' => drupal_get_path('module', 'multichoice') . '/theme',
+ 'path' => $path,
'file' => 'multichoice.theme.inc',
),
'multichoice_alternative_creation' => array(
'render element' => 'form',
- 'path' => drupal_get_path('module', 'multichoice') . '/theme',
+ 'path' => $path,
'template' => 'multichoice-alternative-creation',
),
'multichoice_answering_form' => array(
'render element' => 'form',
- 'path' => drupal_get_path('module', 'multichoice') . '/theme',
+ 'path' => $path,
'template' => 'multichoice-answering-form',
),
'multichoice_alternative' => array(
'render element' => 'form',
- 'path' => drupal_get_path('module', 'multichoice') . '/theme',
+ 'path' => $path,
'template' => 'multichoice-alternative',
),
);
diff --git a/question_types/quiz_directions/quiz_directions.classes.inc b/question_types/quiz_directions/quiz_directions.classes.inc
index 58ee74a..f5b998c 100644
--- a/question_types/quiz_directions/quiz_directions.classes.inc
+++ b/question_types/quiz_directions/quiz_directions.classes.inc
@@ -160,7 +160,7 @@ class QuizDirectionsResponse extends QuizQuestionResponse {
*
* @see QuizQuestionResponse#getReportForm($showpoints, $showfeedback, $allow_scoring)
*/
- public function getReportForm($showpoints = TRUE, $showfeedback = TRUE) {
+ public function getReportForm($showpoints = TRUE, $showfeedback = TRUE, $allow_scoring = FALSE) {
return array(
'#no_report' => TRUE,
);
diff --git a/question_types/short_answer/short_answer.module b/question_types/short_answer/short_answer.module
index c528ad7..4083310 100644
--- a/question_types/short_answer/short_answer.module
+++ b/question_types/short_answer/short_answer.module
@@ -227,3 +227,19 @@ function short_answer_get_answer($question_nid, $question_vid, $result_id) {
WHERE sa.question_nid = :qnid AND sa.question_vid = :qvid AND sa.result_id = :rid', array(':qnid' => $question_nid, ':qvid' => $question_vid, ':rid' => $result_id))->fetchAssoc();
return $results ? $results : FALSE;
}
+
+/**
+ * Implements hook_field_extra_fields().
+ */
+function short_answer_field_extra_fields() {
+ $extra['node']['short_answer'] = array(
+ 'form' => array(
+ 'answer' => array(
+ 'label' => t('Answer'),
+ 'description' => t('Provide the answer and the method by which the answer will be evaluated.'),
+ 'weight' => -4,
+ ),
+ ),
+ );
+ return $extra;
+}
diff --git a/question_types/truefalse/truefalse.module b/question_types/truefalse/truefalse.module
index dacacb0..c7abcda 100644
--- a/question_types/truefalse/truefalse.module
+++ b/question_types/truefalse/truefalse.module
@@ -77,3 +77,24 @@ function theme_truefalse_response($variables) {
$data = $variables['data'];
return theme('table', array('header' => $metadata, 'rows' => $data));
}
+
+/**
+ * Implements hook_field_extra_fields().
+ */
+function truefalse_field_extra_fields() {
+ $extra['node']['truefalse'] = array(
+ 'form' => array(
+ 'correct_answer' => array(
+ 'label' => t('Correct answer'),
+ 'description' => t('The answer for this question.'),
+ 'weight' => -4,
+ ),
+ 'feedback_fields' => array(
+ 'label' => t('Feedback Settings'),
+ 'description' => t('Settings pertaining to feedback given along with results.'),
+ 'weight' => -4,
+ ),
+ ),
+ );
+ return $extra;
+}
diff --git a/quiz.admin.inc b/quiz.admin.inc
index 6022e46..bdd5db0 100644
--- a/quiz.admin.inc
+++ b/quiz.admin.inc
@@ -833,7 +833,7 @@ function _quiz_add_fields_for_creating_questions(&$form, &$types, &$quiz) {
'#type' => 'fieldset',
'#title' => t('Create new question'),
'#collapsible' => TRUE,
- '#collapsed' => FALSE,
+ '#collapsed' => TRUE,
);
$url_query = drupal_get_destination();
diff --git a/quiz.module b/quiz.module
index 110b152..39549b0 100644
--- a/quiz.module
+++ b/quiz.module
@@ -241,9 +241,10 @@ function quiz_access_my_results($quiz) {
*/
function quiz_access_my_result($rid) {
global $user;
- if (!user_access('view own quiz results'))
+ if (!user_access('view own quiz results')) {
return FALSE;
- $time_end = db_result(db_query('SELECT time_end FROM {quiz_node_results} WHERE result_id = %d AND uid = %d', $rid, $user->uid));
+ }
+ $time_end = db_query('SELECT time_end FROM {quiz_node_results} WHERE result_id = :result_id AND uid = :uid', array(':result_id' => $rid, ':uid' => $user->uid))->fetchField();
return $time_end > 0;
}
@@ -3639,44 +3640,6 @@ function quiz_get_questions($quiz_nid = NULL, $quiz_vid = NULL, $include_all_typ
return $questions;
}
-
-/**
- * Get all results, or results for a given user and/or quiz.
- *
- * @param $nid
- * Node ID for the quiz.
- * @param $uid
- * Optional user ID to constrain results to just that user.
- *
- * @return
- * A list of results.
- */
-function _quiz_get_results($nid = '', $uid = 0) {
- $results = array();
- $args = array();
- $sql = "SELECT n.nid, n.title, u.name, u.uid, qnrs.result_id, qnrs.score, qnrs.time_start, qnrs.time_end, qnp.pass_rate
- FROM {node} n
- INNER JOIN {quiz_node_results} qnrs ON qnrs.nid = n.nid
- INNER JOIN {users} u ON u.uid = qnrs.uid
- INNER JOIN {quiz_node_properties} qnp ON qnrs.vid = qnp.vid
- WHERE n.type = 'quiz'";
- if ($nid) {
- $sql .= " AND qnrs.nid = %d";
- $args[] = $nid;
- }
- if ($uid != 0) {
- $sql .= " AND qnrs.uid = %d";
- $args[] = $uid;
- }
- $sql .= " ORDER BY qnrs.result_id DESC";
- // TODO Please convert this statement to the D7 database API syntax.
- $dbresult = db_query(db_rewrite_sql($sql), $args);
- while ($line = db_fetch_array($dbresult)) {
- $results[$line['result_id']] = $line;
- }
- return $results;
-}
-
/**
* Get a list of all available quizzes.
*
diff --git a/quiz.pages.inc b/quiz.pages.inc
index 3644749..b47057b 100644
--- a/quiz.pages.inc
+++ b/quiz.pages.inc
@@ -607,7 +607,8 @@ function theme_quiz_user_summary($variables) {
$output .= '<div id="quiz_summary">' . $summary['result'] . '</div>' . "\n";
}
// Get the feedback for all questions.
- $output .= drupal_render(drupal_get_form('quiz_report_form', $questions, FALSE, TRUE));
+ $form = drupal_get_form('quiz_report_form', $questions, FALSE, TRUE);
+ $output .= drupal_render($form);
return $output;
}