custom permissions for score quizzes I need your help I need to make a very custom way of scoring quizzes and need some opinions and ideas.

I'm making a job applicants website, when you try to apply to a job in the website you have to take a quiz, and if you pass it your resume is sent to the creator of the job.

The complex part is that the quiz for the job is bound in the job content type with an entity reference field, the creator of the job can choose the quiz with an autocomplete field.

Now, I already have that part until the applicant finishes the quiz and then notify the creator of the job (instead of the creator of the quiz) if the applicant passed the quiz.

What I do not know how to do, is that the result of the quiz must be scored by the creator of the job, and not by the creator of the quiz.

A quiz can be reference to unlimited jobs, but when a quiz is bound into a job and somebody applies to a job, and answer the quiz, the results must be scored by the creator of the job instead of the creator of the quiz.

Any ideas how to achieve this?
When the quiz is completed I guess you need to email the job creator. You could do this using hook_node_insert().

E.g.

function hook_node_insert($node) {
  if($node-&gt;type == 'quiz') {

    // Get the job nid from the quiz nid
    $job_nid = db_select('field_data_field_quiz', 'q')
      -&gt;fields('entity_id')
      -&gt;condition('field_quiz_target_id', $node-&gt;nid)
      -&gt;condition('entity_type', 'node')
      -&gt;condition('bundle', 'job')
      -&gt;condition('deleted', 0)
      -&gt;execute()
      -&gt;fetchField();

    $job = node_load($job_nid);

    $job_author = user_load($job-&gt;uid);

    drupal_mail (
      // The name of your module
      'my_module',
      // An arbitrary mail key, that you decide (used in hook_mail())
      'new_quiz_submission',
      // The destination mail address
      $to-&gt;mail,
      // The language that the mail should be sent in (requires translation if not English)
      $to-&gt;language,
      // Some parameters we can use in hook_mail()
      array (
        'account' =&gt; $job_author, // Pass the user account to hook_mail
      )
    );

  }
}

function my_module_mail($key, &amp;$message, $params) {
  // The key allows for a module to define multiple mails. This
  // key needs to be the same as the first parameter in drupal_mail() above
  if($key ==  'new_quiz_submission') {
    $message['subject'] = t('New Quiz submission');
    // Each element of the body array becomes a new line in the email.
    $message['body'][] = t('Hello @user', array('@user' =&gt; format_username($params['to'])));
    // Adding an empty string to the body array adds an extra line in the email
    $message['body'][] = '';
    $message['body'][] = t('A user submitted a quiz. To see the results &lt;a href="#link-to-site"&gt;click here&lt;/a&gt;.');
  }
}


I pretty much just copied and pasted the code for sending simple emails from here.

I would create a view with a contextual filter that shows all of a particular authors quizzes that need scoring and then the link the in the email could just link to that view.

When they marked the quiz then I would also use a boolean field to mark the quiz as scored.