diff --git a/includes/views/quiz.views.inc b/includes/views/quiz.views.inc index 9b6119cc7878631e33e161d353af534d7486541a..afc33964df09051927ed8f97990af02eb794eea9 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 a3d058bd4448566f9b4396124368e5b28b4a1fce..b0f77a67fab134e371ac0ada8fc31a8fbe98e95e 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 1f55f6b3a3ba9f593e5da5b952e3d192e7246381..cb1ce76bd21b512ff7bf32f89e811c5abb3e27d3 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 8db418521d976ea43075d3582e00da521459f84c..a75ee3b50bb59cbf659c316577aea09a9b17ced4 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 58ee74a2981e98c2bf6c2729eaabbaa511c3f29c..f5b998c67629408d269e2ef20c2792f42a5cc50e 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 c528ad7be71f108f4c5785695a7b4fff7c85d7e0..408331026f0d740a94bcd04b4eb9746eb050121c 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 dacacb06c85502e1c0c69a23bd54c208f862bf91..c7abcda3887b8b993292e4806b3dfcc8e0eff6fa 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 6022e464b24deb060e9bee01f9a82702cf6e7cb1..bdd5db0c45f81ec4caf4866273d1ae010b86ec41 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 110b152ec8095b11aa1052ea24e3c4ed79492764..39549b023a2cf9a70247b5d397edb4a7f481823b 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 3644749d4342b6ffcc8a02d65f813cc352c5e6ee..b47057ba01d1bbc7ca96a4373194dd1d6e19990b 100644 --- a/quiz.pages.inc +++ b/quiz.pages.inc @@ -607,7 +607,8 @@ function theme_quiz_user_summary($variables) { $output .= '
' . $summary['result'] . '
' . "\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; }