newbi problems

Hi. I've only just started playing with Drupal and run into some problems :/

Description of the problem (hope it will be understable):

"Primary link" cointains link called "quiz". It goes to webform containing actual quiz.

Every month new quiz is generated.

Problem is when I create the new quiz I'm setting the menu to the "quiz" link in "primary links" but it doesn't seem to update it.

First quiz was under node/3, but new one gets located under node 12. How can I - during creation of new webform - update the link in the "primary links" so it matches to the newest published webform?

thanks

darren's picture

Have you tried removing the

Have you tried removing the old quiz link before you add the new one?

Wll, I could do it like that but...

I'm not the person who will be posting the quiz. To explain:

Site will have 3 types of user, Admin (me), Moderator, and comp_user.

The person who will be creating the new quiz every month and uploading it will be the moderator and i don't won't him/her to mess around with menu links. Automatic update of the link seems the best option, if it is duable, that is.

darren's picture

yep, in that case (as

yep, in that case (as mentioned below) create a view that just selects and shows the latest 'quiz'.

 

Views, wonderful views....

Have you used the views module yet?

It's very powerful. Basically it's a means of selecting and sorting nodes and then outputting them. And it's all done through a point and click interface.

Veiws are often used to prepare a list of nodes for site users to browse. But they can just as easily select a single node - as you want to do.

You want to output the most recently submited quiz. So add a view to display this node, then change your primary link to point to this view.

I know it must sound daunting if you've never heard of views, but I would say that if you don't want to learn how to use views (or cck for that matter) you might as well forget drupal because for the non-programmer they are the most powerful means of getting drupal to do all sorts of amazing things that will make you gasp the first time you see them. They're both a must.

Here's a link to a Views screencast:

http://www.masteringdrupal.com/screencast/new-features-in-views2/play

Good luck.

sorted out with views, work

sorted out with views, works nice, thanks guys:)

got another question

the quiz is restricted to 1 entry only.

now when user open the link to the quiz he already filled, he just gets a message saying "you have already submited this form" and a link to view previous sumbissions.

is there a way to changed it so when user open a link to already filled quiz he will see a different message and a summary of his last quiz below (on the same page without clicking a link).

 

all the help appreciated

This isn't going to be very

This isn't going to be very easy.

I'm sure it's possible. Anything's possible in Drupal - especially if you're willing to write some php! But I'm not too comfortable with that.

The problem is that the "this quiz is restricted to 1 entry only" message is a part of the quiz module, and you cannot overide through its admin interface.

However, it might be possible to change this behaviour using the 'rules' module.

Take a look at this video to familiarise yourself with it:

http://gotdrupal.com/videos/drupal-workflow-automation

I just came accross 'rules' a couple of days ago. It allows you to remap all sorts of behaviours.

The idea would be to set up a rule that checks whether or not you are allowed to take a quiz and if not redirect the user to a page saying "you have already submited this form" which displays the link you want, or better still shows the result of the quiz.

Good luck, if you're not there already.

Mark

You can get this to work

You can get this to work using rules. But it's a much simpler process to edit your quiz.module file, (which sits in the quiz directory).

After line 1591 (in the current version, 6.x-3.4) just add the hilighted text shown below. You don't have to delete any of the existing code.

      // If the user has already taken this quiz too many times, stop the user.
      elseif ($taken >= $quiz->takes) {
        drupal_set_message(t('You have already taken this quiz @really. You may not take it again.', array('@really' => $taken_times)), 'error');
        if ($quiz->takes == 1) {
          drupal_set_message(t('Your results are shown below.'), 'error');
          $result_id = db_result(db_query("SELECT result_id FROM {quiz_node_results} WHERE uid = '%s' AND nid = '%s' AND vid = '%s'", $user->uid, $quiz->nid, $quiz->vid));
          drupal_goto('user/quiz/'. $result_id. '/userresults');
        }

        return FALSE;
      }

This worked for me.

Note that this only kicks in if you're allowing your users to take the quiz once.

Also when a new update of quiz is installed you will have to modify the code again!

the only problem is

the only problem is i'm not using quiz. i'm using webform

I missed that! Ah well.You

I missed that! Ah well.

You have to laugh, I suppose.

I think the solution will be similar for webforms.

Will have a look.

Try this

Add the following to the webform.module file, line 1213:

  // If the user has exceeded the limit of submissions, explain the limit.
  elseif ($limit_exceeded) {
    // if submission limit is one and one form has already been submitted
    if ($node->webform['submit_limit'] == 1 && $submission_count == 1) {
      drupal_set_message('You can only submit this form once. Your submission is below.');
      $my_sid = db_result(db_query("SELECT sid FROM {webform_submissions} WHERE uid=%d and nid=%d",$user->uid,$node->nid));
      drupal_goto('node/'. $node->nid. '/submission/'. $my_sid);
    }
    else
if ($node->webform['submit_interval'] == -1 && $node->webform['submit_limit'] > 1) {
      $message = t('You have submitted this form the maximum number of times (@count).', array('@count' => $node->webform['submit_limit']));
    }
    elseif ($node->webform['submit_interval'] == -1 && $node->webform['submit_limit'] == 1) {
      $message = t('You have already submitted this form.');
    }
    else {
      $message = t('You may not submit another entry at this time.');
    }
    $type = 'error';
  }

Remember to chage the if to elseif on the existing line after the additional code.

As before, this only applies to the case where the number of submissions is limited to one.

If you want this change to survive webform updates you'd need to write a separate module. That's the Drupal way of doing this kind of thing. But I'm not quite up to that yet!