phpBB2 UQM - No Quiz Authors ACP

All web design discussion, including Ultimate Quiz MOD support.

Moderator: CricketMX Forum Moderators

User avatar
quahappy
Happy, not Quappy
Happy, not Quappy
Posts: 2266
Joined: Fri Oct 10, 2008 8:56 pm
Location: South Yorkshire, UK

Just picked up on a problem where I think I know what's causing it. In Quiz ACP, the necessary options are:

Can quiz authors have moderative status over their own quizzes? YES
Only quiz moderators can submit quizzes? NO
Should users only be able to play each quiz once? YES
Should the quiz author be able to play their own quizzes? NO

After all the code changes that I've done in Dynamic Timer thread, this is what happens:

1. A Quiz Author submits a quiz

2. If they try to play a quiz they submitted they get this message: You cannot play a quiz you have submitted. Underneath this it gives the Moderator controls (Edit, Delete, Move) - This is correct, but...

3. If the Quiz Author attempts to play the quiz they submitted a second time, they get this message: You have already attempted to play this quiz! - but NO Moderator controls!

I think the problem lies here:

Code: Select all

       // 06-11-08 quiz_play_once_addition
$qpo_sql = $db->sql_query("SELECT quiz_user_list FROM " . QUIZ_GENERAL_TABLE . " WHERE quiz_id = $quiz_id");
       $qpo_row = $db->sql_fetchrow($qpo_sql);

       $qpo_user_plays = explode(',', $qpo_row['quiz_user_list']);

          for( $exp = 0; $exp < count($qpo_user_plays); $exp++ )
          {
             if( is_numeric($qpo_user_plays[$exp]) && $qpo_user_plays[$exp] == $userdata['user_id'] )
             {
	$message = 'You have already attempted to play this quiz!' . '<br /><br />' . sprintf($lang['Quiz_click_return_quiz'], '<a href="' . append_sid("quiz.$phpEx") . '">', '</a> ');
	message_die(GENERAL_MESSAGE, $message);
             }
          }
Somewhere in the above it needs (I think):

Code: Select all

		if($board_config['Quiz_Author_Play'] == OFF && $quiz_author_id == $userdata['user_id'])
		{
			if( quiz_check_moderative_status($userdata['user_id'], $quiz_id) == ON )
			{
			message_die(GENERAL_MESSAGE, $lang['Quiz_author_cannot_play'] . '<br />' . sprintf($lang['Quiz_author_cannot_play_give_edit_options'], '<a href="' . append_sid("quiz_cp.$phpEx?mode=edit&q=$quiz_id") . '">', '</a>', '<a href="' . append_sid("quiz_cp.$phpEx?mode=delete&q=$quiz_id") . '">', '</a>', '<a href="' . append_sid("quiz_cp.$phpEx?mode=move&q=$quiz_id") . '">', '</a>'));
			}
			
			else
			{
			message_die(GENERAL_MESSAGE, $lang['Quiz_author_cannot_play']);
			}
		}
Tried altering options in Quiz ACP "just" to double-check everything and it's not that.

Sorry again, battye. I believe this one may help towards phpBB3 UQM though? I hope! ;)
If you don't ask...
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

FIND

message_die(GENERAL_MESSAGE, $message);

WHERE IT SAYS $message

AFTER ADD

Code: Select all

 . sprintf($lang['Quiz_author_cannot_play_give_edit_options'], '<a href="' . append_sid("quiz_cp.$phpEx?mode=edit&q=$quiz_id") . '">', '</a>', '<a href="' . append_sid("quiz_cp.$phpEx?mode=delete&q=$quiz_id") . '">', '</a>', '<a href="' . append_sid("quiz_cp.$phpEx?mode=move&q=$quiz_id") . '">', '</a>')
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
quahappy
Happy, not Quappy
Happy, not Quappy
Posts: 2266
Joined: Fri Oct 10, 2008 8:56 pm
Location: South Yorkshire, UK

That worked except a Quiz Author can now moderate any quiz - even those they have not created themselves... unless I need to adjust something in Quiz ACP?
If you don't ask...
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Do they get an error message if they try?
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
quahappy
Happy, not Quappy
Happy, not Quappy
Posts: 2266
Joined: Fri Oct 10, 2008 8:56 pm
Location: South Yorkshire, UK

No error messages. Just Quiz Authors having ability to moderate all quizzes.

Am I right in saying that in Quiz ACP there are two functions?

1) Quiz Moderators - Get moderator controls for ALL quizzes.

2) Quiz Authors - Get moderator controls for quizzes they create themselves.

Administrators by default have moderator control for all quizzes?

Is this part:

Code: Select all

      if($board_config['Quiz_Author_Play'] == OFF && $quiz_author_id == $userdata['user_id'])
      {
         if( quiz_check_moderative_status($userdata['user_id'], $quiz_id) == ON )
         {
... responsible for checking if it's a Quiz Author and giving them Moderator control for there own quizzes.
If you don't ask...
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

This is where it starts to get tricky, as the user playing a quiz once overrides a user being able to moderate their own quizzes.

Certainly they should not be able to moderate everyone's quizzes though.

Please make sure that in quiz_cp.php you have this code:

Code: Select all

$users = explode(',', $board_config['Quiz_Moderators']);

	for( $o = 0; $o < count($users); $o++ )
	{
		if( $userdata['user_id'] == intval($users[$o]) )
		{
			$quiz_moderator = ON;
		}
	}
I can't see why that wouldn't stop a user who is not a quiz moderator from altering any quiz. Only administrators can alter/moderate any quiz they want.

But none-the-less, try this:

Delete that code above

And replace it with:

Code: Select all

$quiz_moderator = quiz_check_moderative_status($userdata['user_id'], $quiz_id); 



That should at least stop a person from editing any quiz.
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
quahappy
Happy, not Quappy
Happy, not Quappy
Posts: 2266
Joined: Fri Oct 10, 2008 8:56 pm
Location: South Yorkshire, UK

Hi battye, ;)

Right, I started all over again as I was getting just a little confused as to what options were stopping what. Firstly, replacing:

Code: Select all

    $users = explode(',', $board_config['Quiz_Moderators']);

       for( $o = 0; $o < count($users); $o++ )
       {
          if( $userdata['user_id'] == intval($users[$o]) )
          {
             $quiz_moderator = ON;
          }
       }
with what you mentioned didn't make any difference. :(

I've reinserted the above original code.

After much testing and fiddling, I've isolated the problem down to this:

Code: Select all

       // 06-11-08 quiz_play_once_addition
       $qpo_sql = $db->sql_query("SELECT quiz_user_list FROM " . QUIZ_GENERAL_TABLE . " WHERE quiz_id = $quiz_id");
       $qpo_row = $db->sql_fetchrow($qpo_sql);

       $qpo_user_plays = explode(',', $qpo_row['quiz_user_list']);

          for( $exp = 0; $exp < count($qpo_user_plays); $exp++ )
          {
             if( is_numeric($qpo_user_plays[$exp]) && $qpo_user_plays[$exp] == $userdata['user_id'] )
             {
             message_die(GENERAL_MESSAGE, 'You have already attempted to play this quiz' . '<br /><br />' . sprintf($lang['Quiz_click_return_quiz'], '<a href="' . append_sid("quiz.$phpEx") . '">', '</a>') . '<br /><br />' . sprintf($lang['Quiz_author_cannot_play_give_edit_options'], '<a href="' . append_sid("quiz_cp.$phpEx?mode=edit&q=$quiz_id") . '">', '</a>', '<a href="' . append_sid("quiz_cp.$phpEx?mode=delete&q=$quiz_id") . '">', '</a>', '<a href="' . append_sid("quiz_cp.$phpEx?mode=move&q=$quiz_id") . '">', '</a>'));
             }
          }

       $qpo_addition_list = $qpo_row['quiz_user_list'] . ',' . $userdata['user_id'];

       $db->sql_query("UPDATE " . QUIZ_GENERAL_TABLE . " SET quiz_user_list = '" . $qpo_addition_list . "' WHERE quiz_id = $quiz_id");

       // -- end qpo addition
From my understanding, a Quiz Author who submits a Quiz should ONLY be able to EDIT, MOVE, DELETE there OWN quiz.

When a Quiz Author clicks on one they've created, they get this:

You cannot play quizzes which you have submitted!

Click Here to return to the Quiz Page


No Moderator controls appear with the above but If they then click on there own same quiz again, you get this:

You have already attempted to play this quiz

Click Here to return to the Quiz Page

Moderator Options: Edit, Delete, Move


The first two lines above are correct.

So what's the problem? A Quiz Author is getting the Moderator controls above for a quiz they've NOT submitted.

I hope that makes sense and do apologise for all this.

Quiz ACP settings:


Can quiz authors have moderative status over their own quizzes? YES
Only quiz moderators can submit quizzes? NO
Should users only be able to play each quiz once? YES
Should the quiz author be able to play their own quizzes? NO
If you don't ask...
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

So if you take out this:

Code: Select all

// 06-11-08 quiz_play_once_addition
       $qpo_sql = $db->sql_query("SELECT quiz_user_list FROM " . QUIZ_GENERAL_TABLE . " WHERE quiz_id = $quiz_id");
       $qpo_row = $db->sql_fetchrow($qpo_sql);

       $qpo_user_plays = explode(',', $qpo_row['quiz_user_list']);

          for( $exp = 0; $exp < count($qpo_user_plays); $exp++ )
          {
             if( is_numeric($qpo_user_plays[$exp]) && $qpo_user_plays[$exp] == $userdata['user_id'] )
             {
             message_die(GENERAL_MESSAGE, 'You have already attempted to play this quiz' . '<br /><br />' . sprintf($lang['Quiz_click_return_quiz'], '<a href="' . append_sid("quiz.$phpEx") . '">', '</a>') . '<br /><br />' . sprintf($lang['Quiz_author_cannot_play_give_edit_options'], '<a href="' . append_sid("quiz_cp.$phpEx?mode=edit&q=$quiz_id") . '">', '</a>', '<a href="' . append_sid("quiz_cp.$phpEx?mode=delete&q=$quiz_id") . '">', '</a>', '<a href="' . append_sid("quiz_cp.$phpEx?mode=move&q=$quiz_id") . '">', '</a>'));
             }
          }

       $qpo_addition_list = $qpo_row['quiz_user_list'] . ',' . $userdata['user_id'];

       $db->sql_query("UPDATE " . QUIZ_GENERAL_TABLE . " SET quiz_user_list = '" . $qpo_addition_list . "' WHERE quiz_id = $quiz_id");

       // -- end qpo addition
It works correctly?
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
quahappy
Happy, not Quappy
Happy, not Quappy
Posts: 2266
Joined: Fri Oct 10, 2008 8:56 pm
Location: South Yorkshire, UK

Yep! But then the ability to refresh a quiz in play restarts the countdown timer, whereby with the additional code, you would had received the 'You have already attempted to play this quiz' if browser page is reloaded.

In Quiz ACP: Can quiz authors have moderative status over their own quizzes? YES. In effect, ONLY Display Moderator controls only for quizzes they've created themselves. This isn't the case, Quiz Authors are getting Moderator Controls for all quizzes. I've been checking the code to see if I can insert after:

Code: Select all

             if( is_numeric($qpo_user_plays[$exp]) && $qpo_user_plays[$exp] == $userdata['user_id'] )
             {
... check if quiz_author is ON and if it's equal to quiz_id (IS the quiz creator), then display Moderator controls, else, don't display moderator controls.

Administrators and Quiz Moderators ability to EDIT, MOVE, DELETE quizzes is functioning properly.
If you don't ask...
User avatar
quahappy
Happy, not Quappy
Happy, not Quappy
Posts: 2266
Joined: Fri Oct 10, 2008 8:56 pm
Location: South Yorkshire, UK

What function is it to detect:

If Quiz Author is ON and Quiz member is attempting to click on Quiz they created, then display Moderator Controls. I thought it might had been:

Code: Select all

		if($board_config['Quiz_Author_Play'] == ON && $quiz_author_id == $userdata['user_id'])
		{
			if( quiz_check_moderative_status($userdata['user_id'], $quiz_id) == ON )
                       {
as this part (in quiz_cp.php a bit below 06-11-08 quiz_play_once_addition):

Code: Select all

                 if( is_numeric($qpo_user_plays[$exp]) && $qpo_user_plays[$exp] == $userdata['user_id'] )
                 {
                 message_die(GENERAL_MESSAGE, 'You have already attempted to play this quiz' . '<br /><br />' . sprintf($lang['Quiz_click_return_quiz'], '<a href="' . append_sid("quiz.$phpEx") . '">', '</a>') . '<br /><br />' . sprintf($lang['Quiz_author_cannot_play_give_edit_options'], '<a href="' . append_sid("quiz_cp.$phpEx?mode=edit&q=$quiz_id") . '">', '</a>', '<a href="' . append_sid("quiz_cp.$phpEx?mode=delete&q=$quiz_id") . '">', '</a>', '<a href="' . append_sid("quiz_cp.$phpEx?mode=move&q=$quiz_id") . '">', '</a>'));
... Moderator Controls are still showing for a Quiz Author for a Quiz they've not created.
If you don't ask...
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Undo the changes I suggested here:

http://forums.cricketmx.com/viewtopic.p ... 524#p93524

FIND

Code: Select all

             if( is_numeric($qpo_user_plays[$exp]) && $qpo_user_plays[$exp] == $userdata['user_id'] )
             {
AFTER ADD

Code: Select all

         if( quiz_check_moderative_status($userdata['user_id'], $quiz_id) == ON )
         {
         $message_ctl = sprintf($lang['Quiz_author_cannot_play_give_edit_options'], '<a href="' . append_sid("quiz_cp.$phpEx?mode=edit&q=$quiz_id") . '">', '</a>', '<a href="' . append_sid("quiz_cp.$phpEx?mode=delete&q=$quiz_id") . '">', '</a>', '<a href="' . append_sid("quiz_cp.$phpEx?mode=move&q=$quiz_id") . '">', '</a>');
          }
FIND

Code: Select all

message_die(GENERAL_MESSAGE, $message);
REPLACE WITH

Code: Select all

message_die(GENERAL_MESSAGE, $message . $message_ctl);




Fingers crossed. I don't like this though, it's all getting very messy because they are just stop gap solutions. Thankfully when you upgrade to phpBB3 it will all be much more elegant.
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
quahappy
Happy, not Quappy
Happy, not Quappy
Posts: 2266
Joined: Fri Oct 10, 2008 8:56 pm
Location: South Yorkshire, UK

And the answer is nope I'm afraid. But, unless I'm very much mistaken, I believe the ability of a Quiz Author to Moderate there own Quiz may be a bug? I dropped all quiz related SQL tables (including session_quiz_categories and quiz config tables), deleted all quiz files, edits, countdown timer file, template changes, etc and performed a complete fresh install at my test site.

I then setup Quiz ACP as follows (after creating a test category):

Can quiz authors have moderative status over their own quizzes? Yes
Do users have to be registered to participate in / or submit quizzes? Yes
Do you want users to reach a certain post count before they can participate in / or submit quizzes? Yes
Enter the minimum number of posts here: 1
Enter all users which you wish to have quiz moderator status (move, edit, delete quizzes).
Separate user id's with commas! <none entered>
Enter all users which you wish to banned from participating in quizzes.
Separate user id's with commas! <none entered>

Quiz Configuration
Do you wish for answers to be shown after the quiz is played? Yes
Should cash be enabled? (Only to be used if the Cash MOD is installed!) No
Only quiz moderators can submit quizzes? No
How many statistics will be displayed for each module? 10
Should users only be able to play each quiz once? Yes
Should the quiz author be able to play their own quizzes? No
Give the Quiz Bot a name (the name Quiz Packs are submitted under):
Set a time limit for each question. If this time limit is exceeded, the user will not see their results. Set to 0 for unlimited time. 10
Select which category quiz packs are submitted to by default:
What is the minimum and maximum number of questions a user can have in quiz?
Separate with commas, and put the same number twice (x,x) to make a set number for everybody. 5, 10


I then logged in as a member (with no special rank assigned), submitted a quiz, clicked on the quiz I had created and get this message: You cannot play quizzes which you have submitted! ... and no Moderator Controls! If Quiz ACP >> Should users only be able to play each quiz once? is set to YES, then the message is: You are only permitted to play each quiz once. Again, no Moderator Controls. :(

battye - Please tell me I'm not going nuts and the below IS how it should be in UQM:

1. Administrators have global moderator controls

2. Quiz Moderators (selected by entering User ID in Quiz ACP) have same powers as Administrator.

3. Quiz Authors (by selecting YES for Can quiz authors have moderative status over their own quizzes? in Quiz ACP) SHOULD be getting Moderator Controls for OWN quizzes they've created.

.... or have I overlooked something? I appreciate that work is now focussed on phpBB3 UQM and if necessary, when UQM (phpBB2) goes live at my site on 1st December, I would point out to members that although they can Submit Quizzes, they will not be able to edit, move or delete them and will need to ask either an Administrator or Quiz Moderator. ;)
If you don't ask...
User avatar
quahappy
Happy, not Quappy
Happy, not Quappy
Posts: 2266
Joined: Fri Oct 10, 2008 8:56 pm
Location: South Yorkshire, UK

Well I must admit, I think I know UQM inside out now after reading through every topic there is here. lol.

It seems that a coding error was made within includes/functions_quiz.php that prevented Quiz Authors from having moderating controls over there OWN quizzes.

In includes/functions_quiz.php:

FIND

Code: Select all

    if( $row['user_id'] == intval($user_id) )
REPLACE WITH

Code: Select all

if( $row['quiz_author'] == intval($user_id) ) 
Hey presto! Quiz Author Moderator Controls only for quizzes they've created and NOT anyone elses.

I now need to reinsert all the code changes to do with countdown timer and hopefully, all should be well. Will keep you posted. ;)
If you don't ask...
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

quahappy wrote:Well I must admit, I think I know UQM inside out now after reading through every topic there is here. lol.

It seems that a coding error was made within includes/functions_quiz.php that prevented Quiz Authors from having moderating controls over there OWN quizzes.

In includes/functions_quiz.php:

FIND

Code: Select all

    if( $row['user_id'] == intval($user_id) )
REPLACE WITH

Code: Select all

if( $row['quiz_author'] == intval($user_id) ) 
Hey presto! Quiz Author Moderator Controls only for quizzes they've created and NOT anyone elses.

I now need to reinsert all the code changes to do with countdown timer and hopefully, all should be well. Will keep you posted. ;)
I'm so sorry :cry: I was thinking too much about it instead of looking at the obvious :cry:
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
quahappy
Happy, not Quappy
Happy, not Quappy
Posts: 2266
Joined: Fri Oct 10, 2008 8:56 pm
Location: South Yorkshire, UK

battye wrote:I'm so sorry :cry: I was thinking too much about it instead of looking at the obvious :cry:
Not a problem lol. It was the same with Arcade / Activity MOD whereby forum members complained that no-one was receiving Arcade PM's and after much deciphering of the code - which it had nothing to do with - was down to a switch in members Profile (and ensuring Arcade PM switch was ON in Admin ACP) which required them to accept / deny PM's from the Arcade (when High Score was beat / new game added, etc). Unfortuantely it just wasn't highlighted in installation file or anywhere else lol.

Not inserted all the code yet (countdown timer and play once addition code) but guessing that all should be ok. :D

I can't seem to find the topic though which highlighted install problems, quiz packs, timer, etc. so this moderator control code change can go in it. :D
If you don't ask...
Post Reply