Found this handy enough to commit back. It is a link like the Views core "Edit link" (based directly off of it actually).

It uses the quiz.module function quiz_take_access($node) to only display the link if the user has permission to access it and the quiz is available.

Files: 

Comments

sivaji@knackforge.com’s picture

Status:Needs review» Fixed

Awesome!! Thanks for the patch. Committed to git.

When you share views related patch next time please include a sample views export as well for testing :-)

covenantd’s picture

Great idea with including a views export - will do in the future!

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Niremizov’s picture

Status:Closed (fixed)» Active

Sivaji look like you have forgotten to add to this commit /includes/views/handlers/quiz_views_handler_field_node_link_take.inc handler file.
See commit viewer http://drupalcode.org/project/quiz.git/commitdiff/62ad920 , and also i can not found this file in current 7.x-4.x-dev branch.

dmegatool’s picture

I manually created the quiz_views_handler_field_node_link_take.inc file with code in the quiz-Add_Take_quiz_link_as_Views_field-000.patch but I'm getting the following error. Don't have the knowledge to fix it :\

Notice : Undefined index: entity type dans views_handler_field_entity->init() (line 44 in /home/doolysqu/tests/sites/all/modules/views/handlers/views_handler_field_entity.inc).

Niremizov’s picture

quiz_views_handler_field_node_link_take extends views_handler_field_node_link and views_handler_field_node_link extends views_handler_field_entity

views_handler_field_entity : 44line

<?php
 
public function init(&$view, &$options) {
   
parent::init($view, $options);

   
// Initialize the entity-type used.
   
$table_data = views_fetch_data($this->table);
   
// line 44
   
$this->entity_type = $table_data['table']['entity type'];
  }
?>

Look like your views base table do not have entity_type value. I suppose that you need to add Quiz relationship to your Views, probably.

dmegatool’s picture

Seems like no matter what relations I add, it keeps saying this. Tried on the provided views and all to no avail. It would be nice anyway to get a release which would include all the files and the patch applied.

dmegatool’s picture

Meh... just realised the default views ain't working either. I created some quizzes and answered them. If I go to the url to show all quizzes taken by a user (quiz by taker), all I get is a "Quizzes taken by admin" and no results displayed. Must be doing something wrong cause when I try to use the "Quiz: Quiz Version" filter critera I get :

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= 'SELECT MAX(__subselect.) FROM {} __subselect WHERE __subselect. = . AND __sub' at line 4

michaelk’s picture

I was also running into the following error message just using the base Quiz module:

Notice: Undefined index: entity type in views_handler_field_entity->init() (line 44 of .../views_handler_field_entity.inc).

Please take a look at the following issue for a solution to that issue: #2066537: Notice: Undefined index: entity type in views_handler_field_entity->init() (line 44 of .../views_handler_field_entity.inc).

  • Commit 62ad920 on 7.x-4.x, 7.x-5.x authored by covenantd, committed by sivaji:
    Fix #1866404 - Add 'Take quiz' link as Views field by covenantd
    

  • Commit 62ad920 on 7.x-4.x, 7.x-5.x, quiz-pages authored by covenantd, committed by sivaji:
    Fix #1866404 - Add 'Take quiz' link as Views field by covenantd
    

  • Commit 62ad920 on 7.x-4.x, 7.x-5.x, quiz-pages, 2269219 authored by covenantd, committed by sivaji:
    Fix #1866404 - Add 'Take quiz' link as Views field by covenantd
    

  • Commit 62ad920 on 7.x-4.x, 7.x-5.x, 2269219 authored by covenantd, committed by sivaji:
    Fix #1866404 - Add 'Take quiz' link as Views field by covenantd
    

  • sivaji committed 62ad920 on 7.x-6.x authored by covenantd
    Fix #1866404 - Add 'Take quiz' link as Views field by covenantd