Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-05-2010, 10:09 AM
ahmed19 ahmed19 is offline
 
Join Date: Sep 2008
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to print results

Hello everyone. I need little help because i don't know how to create script. I wont to display quiz results on one of my vbulletin templates (quiz_thanks). I know that it is very simple but i don't know php language so i have big problem with this.

I have function to create results
PHP Code:
// Assume Your Usergroup Has Access To Participate In A Quiz
    
$Your_ID $vbulletin->userinfo['usergroupid'];
    
$Perms   unserialize($Quiz['q_perms']);
            if(!
in_array($Your_ID,$Perms['Participate'])){
            
RunError("Your usergroup does not have access to participate in this particular quiz.");
        }

    
$Questions $DB->query("select * from ".TABLE_PREFIX."quiz_questions where q_forquiz='{$Quiz['qid']}' order by qqid");
        while(
$Question $DB->fetch_array($Questions)){
        
$Q[$Question['qqid']] = $Question;
        }

    
$Answers $_POST['question'];
    
$Report "Here are your quiz results for '".str_replace('"','"',$Quiz['q_name'])."' {$vbulletin->userinfo['username']}.\n\n[list]";

    
$Count 1;
    
$Score 0;

        if(
is_array($Q)){
            foreach(
$Q as $id => $Quest){
            
$Result $Engine->Compile_Answer($Quest,$Answers[$id]);
            
$Report .= "[*][b]Question {$Count}:[/b] ".str_replace('"','"',$Quest['q_question'])."\n";

            
$Report .= "[list][*][b]You Answered:[/b] ".implode(', ',$Result[2])."\n";
            
$Report .= "[*]This was {$Result[0]}% Correct. (Actual Answer(s): ".iif($Quiz['q_viewanswer'],$Result[1],"[i]Hidden[/i]").")\n[/list]";

    
$Score += $Result[0];
            
$Count++;
            }
        }

    
$Overall floor($Score / ($Count 1));
    
$Report .= "[/list]\n\nYour overall score was: {$Overall}%";

    
// Send PM
    
SendPM($Report,"Quiz Results",$vbulletin->userinfo['userid'],$vbulletin->userinfo['userid']);



In that function script make result and send them by PM function (DataManager_PM). But i don't wont to send them like that. I just wont to show them on quiz_thanks template.

SendPM function
PHP Code:
//////////////////
function SendPM($message,$title,$to,$from 0){
    global 
$vbulletin$DB;
    
$to             $DB->query_first("select username, userid from ".TABLE_PREFIX."user where userid='{$to}'");
    
$DataManager_PM =& datamanager_init('PM'$vbulletinERRTYPE_ARRAY); 
    
$DataManager_PM->set('fromuserid'$to['userid']); 
    
$DataManager_PM->set('fromusername'$to['username']); 
    
$DataManager_PM->set('title'$title); 
    
$DataManager_PM->set('message'$message); 
    
$DataManager_PM->set_recipients($to['username'],$to['permissions']); 
    
$DataManager_PM->set('dateline'TIMENOW); 
    
$DataManager_PM->save();
    }
////////////////// 
How to do that? How to print that results on quiz_thanks template. I know that i need to make plugin and put it in quiz_thanks template. But i don't know how to do that. Please help me.

After user submits quiz his redirected to quiz_thanks template by that function
PHP Code:
    if($_GET['done']){

        eval(
'$quiz_page .= "' fetch_template('quiz_thanks') . '";');

        } 
Please give me some hint.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:18 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06945 seconds
  • Memory Usage 2,186KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete