News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

SMF Quiz

Started by Diego Andrés, February 18, 2009, 01:08:19 PM

Previous topic - Next topic

Diego Andrés

You can change the query a bit

// Get the admins
$adminQuery = $smcFunc['db_query']('', '
SELECT id_member
FROM {db_prefix}members
WHERE id_group = {int:admin}
AND id_member NOT IN ({array_int:exclude_admins})',
array(
'admin' => 1,
'exclude_admins' => array(1,2,3), // IDs of admins to exclude
)
);

SMF Tricks - Free & Premium Responsive Themes for SMF.

Dave J

Thanks again Diego, I'll test it out tomorrow and reply here
If you want quizzes to add to the new SMF2.1 quiz mod go here . There are also walkthroughs in the forum to explain how to install them and other tips.

Dave J

That works a treat Diego, thank you very much for the help
If you want quizzes to add to the new SMF2.1 quiz mod go here . There are also walkthroughs in the forum to explain how to install them and other tips.

jovanddd

diego is the man  8)
dezinsekcija [nofollow]
deratizacija [nofollow]

Bandicoot

#1104
I cannot get the bar graph to show for the Top 10 Quizzes as shown here:

I cannot figure out why and the only place I know it's not the problem is the Quiz.template.php file, because changing to the original one has no effect.

Looking at the page source code, the bar_stats.png image is showing as a width of 0% and height of the correct 15.

For the life of me, I cannot find where this 0% is being set. Does anyone have an idea?

Also pinging @Diego Andrés

Thanks in advance.

Edit: Checked the database and noticed the quiz_session table is empty. Might help and also might explain why playing a quiz a second time does not record any reference to having done so, or record any stats.

Bandicoot

#1105
The bars appeared once I played some more quizzes. Although the top one remained blank.

But I fixed it by removing:

elseif ($max > 0)
Still none the wiser why only the first play records results though. Can play multiple times, but only the first time makes a record.

Dave J

#1106
Quote from: Bandicoot on January 30, 2024, 08:21:37 AMStill none the wiser why only the first play records results though. Can play multiple times, but only the first time makes a record.

Diego,

I can confirm that the first score is the ONLY score recorded, for some reason the quiz will not record a second score even if it's better than the first one.

Can you help please?


NOTE1: I thought this might be to do with the scheduled maintenance bit it's not as I manually ran that and the scores didn't change

NOTE2: I've just tested the original V2.0 quiz on my test site and that also only records the first score from a quiz, I deliberately got most questions wrong the first time round and then played the quiz again beating my previous score but it wasn't recorded
If you want quizzes to add to the new SMF2.1 quiz mod go here . There are also walkthroughs in the forum to explain how to install them and other tips.

Bandicoot

#1107
Found the problem. Figured it must be in either start.php or end.php and it is in end.php

Go to:
Sources/Quiz/End.php

At line 45, find:

if (CheckResultExists($id_quiz, $id_user) == false)
Delete that line.

Every play is now recorded and score is updated.

However, this might be self-defeating, as users will keep playing to increase their score. Setting a play limit of 2 might help, but they still might write down the correct answer from their first run to achieve a perfect score.

Bandicoot

A cleaner way is to change the entire code block from line 41:

        // Don't make these changes if the user playing is the creator of the quiz, only kill the session
        if ($creatorId != $id_user)
        {
            // Add result for every play
                InsertQuizEnd($id_quiz, $id_user, $questions, $correct, $incorrect, $timeouts, $total_seconds, $totalResumes);
                UpdateQuiz($id_quiz, $questions, $correct, $total_seconds, $id_user, $name);
        }
    }

That way it removes unnecessary braces and updates the comment line.

Bandicoot

The quiz ignores the play limit. the only reference I can find is at:

Themes/default/scripts/quiz/QuizClient.js
Line 479:

alert(textPlayedQuizOverMaximum);
window.close();

Is there somewhere else it is found?

I created an entry in /Themes/default/languages/Quiz/Quiz.english.php

$txt['SMFQuiz_Javascript'] = array(
'PlayedQuizOverMaximum' => 'You have already played this quiz the maximum amount of times allowed',

But this didn't help.

Bandicoot

I tried moving

alert(textPlayedQuizOverMaximum);
window.close();

To various places within the file to trigger earlier and trying if code, but nothing worked.

I don't believe that javascript file "knows" that information.

I have given up since my cPanel file manager says that file:

"Has too many errors. 23% scanned"

I think it's just too old and no longer does what it's supposed to do.

So, I've gone back to the original function of only recording the first play result and users can play as many times as they like, just to see if they can get them all right.

It's a shame, because this Mod has great potential.

Dave J

Hi Diego,

When you get the chance could you look into the errors as shown in the attachment please?
If you want quizzes to add to the new SMF2.1 quiz mod go here . There are also walkthroughs in the forum to explain how to install them and other tips.

duban1

Hi guys, I hope someone can help me.

I am using the mod and every time a user finishes the quiz it reports me this error:

2: Undefined array key "SMFQuiz_SendPMOnBrokenTopScore"
/index.php?action=SMFQuizEnd;id_quiz=17;questions=10;correct=5;incorrect=5;timeouts=0;id_session=8b6b16c93e46d9b9fa0aac896ce13a2a;total_seconds=92;creator_id=3;totalResumes=0&_=1720487648197
/home/u964766853/domains/xxxxx.com/public_html/foro/Sources/Quiz/End.php (Línea 221)

I leave the screenshots with the detail.

Any idea where I should modify?




Diego Andrés

I'll have a look at the issues next week.

SMF Tricks - Free & Premium Responsive Themes for SMF.

Dave J

If you want quizzes to add to the new SMF2.1 quiz mod go here . There are also walkthroughs in the forum to explain how to install them and other tips.

duban1

Thank you so much Diego   :laugh:

Advertisement: