Re: phpBB2 UQM - No Quiz Authors ACP
Posted: Fri Nov 21, 2008 10:44 pm
Back again for one final time and this topic can be resolved.
I've modified quiz_play_once_addition code to quiz.php as the additional AFTER, ADD below:
FIND
AFTER, ADD
.... allowed countdown timer to be restarted if browser page was refreshed or browser back selected instead of the "You have already attempted to play this Quiz" message. Basically I've moved the quiz_check_moderative_status function to before $qpo_sql = $db->sql_query("SELECT quiz_user_list....
Anyhow, to save confusion, here's the modified code. Slightly messy but it works.
The above also includes option (link) for the user to return to Quiz Index page.
Also, in an ideal situation, the You have already attempted to play this Quiz shouldn't be true if it's a quiz created by the quiz author as on first "play" the You cannot play quizzes which you have submitted! is correctly displayed (along with moderator controls). Of course, thereafter, the quiz_user_list gets updated meaning that subsequent selection of a Quiz created by the Quiz Author results in You have already attempted to play this Quiz (again, with Moderator controls).
Like I've said elsewhere, I'm not an expert on php and still getting to grips with it so forgive me if it's not quite the right way to do what I've done.
I've modified quiz_play_once_addition code to quiz.php as the additional AFTER, ADD below:
FIND
Code: Select all
if( is_numeric($qpo_user_plays[$exp]) && $qpo_user_plays[$exp] == $userdata['user_id'] )
{
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>');
}
Anyhow, to save confusion, here's the modified code. Slightly messy but it works.
Code: Select all
// 06-11-08 quiz_play_once_addition
$message = 'You have already attempted to play this Quiz' . '<br /><br />' . sprintf($lang['Quiz_click_return_quiz'], '<a href="' . append_sid("quiz.$phpEx") . '">', '</a>');
if( quiz_check_moderative_status($userdata['user_id'], $quiz_id) == ON )
{
$message_ctl = '<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_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, $message . $message_ctl);
}
}
$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
Also, in an ideal situation, the You have already attempted to play this Quiz shouldn't be true if it's a quiz created by the quiz author as on first "play" the You cannot play quizzes which you have submitted! is correctly displayed (along with moderator controls). Of course, thereafter, the quiz_user_list gets updated meaning that subsequent selection of a Quiz created by the Quiz Author results in You have already attempted to play this Quiz (again, with Moderator controls).
Like I've said elsewhere, I'm not an expert on php and still getting to grips with it so forgive me if it's not quite the right way to do what I've done.