a function to return the quiz nid
Here is a very simple way to get the nid of the node currently being viewed:

$path = current_path();
list($entity_type, $entity_id) = explode('/', $path);


After this, you will have the entity id (the nid in the case of nodes) in the variable $entity_id.