Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

quizmyscores.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: quizmyscores.php 9344 2002-03-06 08:56:33Z jhe $
5 //
6 // Created on: <28-May-2001 11:24:41 pkej>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // First check if this game is open
28 // Check if there are other open games
29
30 // include_once( "classes/ezlocale.php" );
31 // include_once( "classes/INIFile.php" );
32 // include_once( "classes/ezlist.php" );
33 // include_once( "classes/eztemplate.php" );
34 // include_once( "classes/ezlocale.php" );
35 // include_once( "ezuser/classes/ezuser.php" );
36 // include_once( "ezquiz/classes/ezquizquestion.php" );
37 // include_once( "ezquiz/classes/ezquizgame.php" );
38 // include_once( "ezquiz/classes/ezquizanswer.php" );
39 // include_once( "ezquiz/classes/ezquizscore.php" );
40
41 $ini =& eZINI::instance( 'site.ini' );
42
43 $Limit = $ini->variable( "eZQuizMain", "ScoreLimit" );
44 $Language = $ini->variable( "eZQuizMain", "Language" );
45 $ScoreCurrent = $ini->variable( "eZQuizMain", "ScoreCurrent" );
46
47 $t = new eZTemplate( "kernel/ezquiz/user/" . $ini->variable( "eZQuizMain", "TemplateDir" ),
48 "kernel/ezquiz/user/intl/", $Language, "quiz.php" );
49
50 $intl = new eZINI( "kernel/ezquiz/user/intl/". $Language . "/quiz.php.ini" );
51
52 $t->setAllStrings();
53
54 $t->set_file( "score_page_tpl", "quizmyscores.tpl" );
55
56 $t->set_block( "score_page_tpl", "error_item_tpl", "error_item" );
57 $t->set_block( "score_page_tpl", "logged_in_user_item_tpl", "logged_in_user_item" );
58 $t->set_block( "score_page_tpl", "no_scores_item_tpl", "no_scores_item" );
59 $t->set_block( "no_scores_item_tpl", "game_item_tpl", "game_item" );
60 $t->set_block( "score_page_tpl", "score_list_item_tpl", "score_list_item" );
61 $t->set_block( "score_list_item_tpl", "score_item_tpl", "score_item" );
62
63 $t->set_var( "error_item", "" );
64 $t->set_var( "no_scores_item", "" );
65 $t->set_var( "logged_in_user_item", "" );
66 $t->set_var( "score_list_item", "" );
67 $t->set_var( "score_item", "" );
68 $t->set_var( "game_item", "" );
69
70 $printScores = false;
71
72 $user =& eZUser::currentUser();
73
74 if ( is_a( $user, "eZUser" ) )
75 {
76 $UserID = $user->id();
77
78 $t->set_var( "user_id", $UserID );
79 $t->set_var( "user_login", $user->login() );
80 $t->set_var( "user_first", $user->firstName() );
81 $t->set_var( "user_last", $user->lastName() );
82
83 $t->parse( "logged_in_user_item", "logged_in_user_item_tpl" );
84
85 $score = new eZQuizScore();
86 $scores = $score->getAllByUser( $user, $Offset, $Limit );
87
88 $count = count( $scores );
89 $scoreCount = $score->countAllByUser( $user );
90
91 $last = 0;
92 $lastColor = "bgdark";
93 $position = $Offset + 1;
94 $locale = new eZLocale( $Language );
95 if ( $scoreCount > 0 )
96 {
97 $printScores = true;
98 }
99 else
100 {
101 // Is there a game?
102 $t->parse( "no_scores_item", "no_scores_item_tpl" );
103 }
104 }
105 else
106 {
107 $error = "login";
108 }
109
110 if ( $printScores == true )
111 {
112 foreach ( $scores as $score )
113 {
114
115 $currentScore = $score->totalScore();
116
117 if ( $currentScore == $last && $position != ( $Offset + 1 ) )
118 {
119 $t->set_var( "score_position", "&nbsp;" );
120
121 if ( $lastColor == "bglight" || $i = 0 )
122 {
123 $t->set_var( "td_class", "bglight" );
124 }
125 else
126 {
127 $t->set_var( "td_class", "bgdark" );
128 }
129 }
130 else
131 {
132 $t->set_var( "score_position", $position );
133 if ( $lastColor == "bglight" )
134 {
135 $t->set_var( "td_class", "bgdark" );
136 $lastColor = "bgdark";
137 }
138 else
139 {
140 $t->set_var( "td_class", "bglight" );
141 $lastColor = "bglight";
142 }
143 }
144
145
146 $game = $score->game();
147
148 $t->set_var( "game_name", $game->name() );
149 $t->set_var( "game_id", $game->id() );
150 $t->set_var( "game_score", $currentScore );
151 $t->set_var( "game_questions", $game->numberOfQuestions() );
152 $t->set_var( "game_players", $game->numberOfPlayers() );
153
154 $t->parse( "score_item", "score_item_tpl", true );
155
156 $last = $currentScore;
157 $position++;
158 $i++;
159 }
160
161 $t->parse( "score_list_item", "score_list_item_tpl" );
162 }
163
164 eZList::drawNavigator( $t, $scoreCount, $Limit, $Offset, "score_page_tpl" );
165
166 if ( $error )
167 {
168 switch ( $error )
169 {
170 case "login":
171 {
172 $t->set_var( "error_message", $intl->variable( "strings", "error_login" ) );
173 $t->parse( "error_item", "error_item_tpl" );
174 }
175 break;
176
177 default:
178 {
179 $t->set_var( "error_message", $intl->variable( "strings", "error_undefined" ) );
180 $t->parse( "error_item", "error_item_tpl" );
181 }
182 break;
183 }
184 }
185
186 $t->pparse( "output", "score_page_tpl" );
187
188 ?>
$locale
$locale
Definition: admin/adlist.php:127
$i
$i
Definition: admin/adlist.php:91
eZINI
Reads and writes .ini style configuration files.
eZList\drawNavigator
static drawNavigator(&$t, $total_types, $max_types, $index, $parent=false, $variables=false)
Definition: ezlist.php:401
eZLocale
Definition: ezlocale.php:119
eZQuizScore
Definition: ezquizscore.php:43
eZTemplate
Definition: eztemplate.php:107
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$error
$error
Definition: ezarticle/admin/categoryedit.php:51
$Offset
$Offset
Definition: ezarticle/user/search.php:110
$count
$count
Definition: onlinetypelist.php:108
$game
$game
Definition: quizlist.php:60
$score
$score
Definition: quizlist.php:61
$Limit
$Limit
Definition: quizmyscores.php:43
$t
$t
Definition: quizmyscores.php:47
$intl
$intl
Definition: quizmyscores.php:50
$user
$user
Definition: quizmyscores.php:72
$printScores
$printScores
Definition: quizmyscores.php:70
$Language
$Language
Definition: quizmyscores.php:44
$ini
$ini
Definition: quizmyscores.php:41
$ScoreCurrent
$ScoreCurrent
Definition: quizmyscores.php:45
$lastColor
$lastColor
Definition: quizscores.php:84
$position
$position
Definition: quizscores.php:85
$scores
$scores
Definition: quizscores.php:78
$scoreCount
$scoreCount
Definition: quizscores.php:81
$last
$last
Definition: quizscores.php:83
$UserID
$UserID
Definition: todoedit.php:122
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.