Page 1 of 2

Moderative status over authors' own quizzes

Posted: Tue Nov 27, 2007 3:40 pm
by ABTOP
The option to make authors the ability to edit their quizzes can't seem to kick in no matter what.
I set "Can quiz authors have moderative status over their own quizzes?" to YES, but I still can't get those "Edit Quiz, Move Quiz, Delete Quiz" links at the bottom. They will only appear if a user has global administrative privileges, or designated as Quiz Moderator in Quiz Permissions.

Version 1.3.3 (although still says "The latest version of the Ultimate Quiz MOD: 1.2.0" at the bottom of ACP Quiz settings)

Posted: Tue Nov 27, 2007 5:24 pm
by kikkotm
i think you'll find the answer while reading the post under this.

Posted: Wed Nov 28, 2007 9:02 am
by battye
Yeah, as kikkotm said, have a browse through the other topics about moderation.

If that fails, open up functions_quiz.php and look for:

Code: Select all

	if( $board_config['Quiz_Author_Mod'] == ON )
	{
		$sql = "SELECT quiz_author FROM " . QUIZ_GENERAL_TABLE . " WHERE quiz_id = '$quiz_id'";
		
		if(!$result = $db->sql_query($sql))
		{
			message_die(GENERAL_ERROR, '', 'Could not obtain the user id', __LINE__, __FILE__, $sql);
		}
		
		$row = $db->sql_fetchrow($result);

		if( $row['user_id'] == intval($user_id) )
		{
			$quiz_moderator = ON;
		}
	}
If you see that, I see no reason why it wouldn't work?

Posted: Wed Nov 28, 2007 6:08 pm
by ABTOP
Yes, that code is present. Still I can't moderate my own quizzes unless I enter myself as a Quiz Moderator.

BTY I noticed that you have a missing 'to' between two 'have' in

Code: Select all

$lang['Quiz_post_requirement_not_met'] = 'You have have %s posts to participate in, or submit quizzes';
But more importantly, seems like the language choice for the error massages like the one above or $lang['Quiz_author_cannot_play'] is dependent on the board default language, not the user's language, which seems wrong to me.

Is it possible that somehow because of that

Code: Select all

$lang['Quiz_author_cannot_play_give_edit_options']
gets omitted?

Also there is no index defined for my phpbb_quiz table. Is that OK?

Posted: Thu Nov 29, 2007 6:00 am
by battye
Sorry, I'm not sure what you mean about the board default language.

quiz_id is the primary key in phpbb_quiz. As long as that is set, you should be fine.

Posted: Thu Nov 29, 2007 6:44 am
by ABTOP
battye wrote:Sorry, I'm not sure what you mean about the board default language.
I have two languages on the board - English and Russian. Naturally, in this case one can choose a Default Language in ACP > General Configuration.

The registered users, however, also have a choice of either language.

If I set the board default language to, say, English, and set Quizzes to be playable by only registered users, and if a guest tries to play a Quiz then the guest get the error in the board's default language - English - which is logical. But if a registered user who has set Russian as the preferred language gets an error, than the error will be in English. Most of regular dialogs will be displaying correctly in Russian, but the errors tend to be in English.

See what I mean? :D

Posted: Thu Nov 29, 2007 2:29 pm
by battye
Oh, with regards to error messages by phpBB coding standards they are permitted to be hard-coded (ie. not in the language files) :)

Posted: Thu Nov 29, 2007 3:00 pm
by ABTOP
battye wrote:Oh, with regards to error messages by phpBB coding standards they are permitted to be hard-coded (ie. not in the language files) :)
Well, they are in $lang files and I translated them. It's more of a convenience issue by itself and the only reason I have mentioned it is in the context of troubleshooting this problem.

The layouts do show the extra line for the missing "Edit Quiz", "Move Quiz" and "Delete Quiz" buttons, it's just the buttons themselves do not display.

Posted: Thu Nov 29, 2007 3:35 pm
by battye
In functions_quiz.php

FIND

Code: Select all

   if( $board_config['Quiz_Author_Mod'] == ON )
   {
      $sql = "SELECT quiz_author FROM " . QUIZ_GENERAL_TABLE . " WHERE quiz_id = '$quiz_id'";
      
      if(!$result = $db->sql_query($sql))
      {
         message_die(GENERAL_ERROR, '', 'Could not obtain the user id', __LINE__, __FILE__, $sql);
      }
      
      $row = $db->sql_fetchrow($result);

      if( $row['user_id'] == intval($user_id) )
      {
         $quiz_moderator = ON;
      }
   }
AFTER ADD

Code: Select all

echo 'MOD STATUS: ' . $quiz_moderator;
And try again. I don't expect it to fix it (you'll probably get an error) but tell me which number follows MOD STATUS - I'm hoping it's a '1'

You can remove the echo line once you've seen which number is displayed.

Posted: Thu Nov 29, 2007 4:05 pm
by ABTOP
I get a bunch of errors at the start of the page:

Code: Select all

MOD STATUS: 
Warning: Cannot modify header information - headers already sent by (output started at /home/my_account_name/public_html/forum/includes/functions_quiz.php:75) in /home/my_account_name/public_html/forum/includes/page_header.php on line 943

Warning: Cannot modify header information - headers already sent by (output started at /home/my_account_name/public_html/forum/includes/functions_quiz.php:75) in /home/my_account_name/public_html/forum/includes/page_header.php on line 947

Warning: Cannot modify header information - headers already sent by (output started at /home/my_account_name/public_html/forum/includes/functions_quiz.php:75) in /home/my_account_name/public_html/forum/includes/page_header.php on line 949
Under the overall header I get:

Code: Select all

MOD STATUS: 
Yep, there is nothing.

If I login as Admin, I get the same error on the top of the page and

Code: Select all

MOD STATUS: 1

Posted: Fri Nov 30, 2007 2:45 am
by battye
Ah, silly mistake on my part :wink:

REPLACE

Code: Select all

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

Code: Select all

if( $row['quiz_author'] == intval($user_id) ) 

Posted: Fri Nov 30, 2007 4:51 am
by ABTOP
Well, I have a bit of improvement to report.

Now I get:
You cannot play quizzes which you have submitted!
Moderator Options: Edit, Delete, Move
So far so good.
But if I click on any of the links I get:
You are not a quiz moderator!

Posted: Fri Nov 30, 2007 10:35 pm
by ABTOP
What is the purpose of this section in functions_quiz.php?

Code: Select all

	if( $quiz_moderator != ON )
	{
		$quiz_moderator = OFF;
	}

Posted: Sat Dec 01, 2007 2:52 pm
by battye
Hi,

Have been quite busy today. I will have a look into the code tomorrow morning :)

Posted: Tue Dec 04, 2007 5:11 am
by ABTOP
battye wrote:... I will have a look into the code tomorrow morning :)
How's the progress?