Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

quizscores.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: quizscores.php 6226 2001-07-20 11:24:09Z jakobn $
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( "ezquiz/classes/ezquizquestion.php" );
36 // include_once( "ezquiz/classes/ezquizgame.php" );
37 // include_once( "ezquiz/classes/ezquizanswer.php" );
38 // include_once( "ezquiz/classes/ezquizscore.php" );
39
40 $ini =& eZINI::instance( 'site.ini' );
41
42 $Limit = $ini->variable( "eZQuizMain", "ScoreLimit" );
43 $Language = $ini->variable( "eZQuizMain", "Language" );
44 $ScoreCurrent = $ini->variable( "eZQuizMain", "ScoreCurrent" );
45
46 $t = new eZTemplate( "kernel/ezquiz/user/" . $ini->variable( "eZQuizMain", "TemplateDir" ),
47 "kernel/ezquiz/user/intl/", $Language, "quiz.php" );
48
49 $intl = new eZINI( "kernel/ezquiz/user/intl/". $Language . "/quiz.php.ini" );
50
51 $t->setAllStrings();
52
53 $t->set_file( array(
54 "score_page_tpl" => "scores.tpl"
55 ) );
56
57 $t->set_block( "score_page_tpl", "error_item_tpl", "error_item" );
58 $t->set_block( "score_page_tpl", "no_scores_item_tpl", "no_scores_item" );
59 $t->set_block( "score_page_tpl", "not_closed_item_tpl", "not_closed_item" );
60 $t->set_block( "score_page_tpl", "future_item_tpl", "future_item" );
61 $t->set_block( "score_page_tpl", "score_list_item_tpl", "score_list_item" );
62 $t->set_block( "score_list_item_tpl", "score_item_tpl", "score_item" );
63
64 $t->set_var( "error_item", "" );
65 $t->set_var( "no_scores_item", "" );
66 $t->set_var( "not_closed_item", "" );
67 $t->set_var( "future_item", "" );
68 $t->set_var( "score_list_item", "" );
69 $t->set_var( "score_item", "" );
70
71 $game = new eZQuizGame( $GameID );
72 $t->set_var( "game_id", $GameID );
73 $t->set_var( "game_name", $game->name() );
74 $t->set_var( "questions", $game->numberOfQuestions() );
75 $t->set_var( "players", $game->numberOfPlayers() );
76
77 $score = new eZQuizScore();
78 $scores = $score->getAllByGame( $game, $Offset, $Limit );
79
80 $count = count( $scores );
81 $scoreCount = $score->countAllByGame( $game );
82
83 $last = 0;
84 $lastColor = "bgdark";
85 $position = $Offset + 1;
86 $locale = new eZLocale( $Language );
87
88 if( $game->isClosed() )
89 {
90 $printScores = true;
91 }
92 else
93 {
94 $printScores = false;
95 $GenerateStaticPage = false;
96
97 if( $game->isFutureGame() )
98 {
99 $start = $game->startDate();
100 $t->set_var( "game_start", $locale->format( $start, false ) );
101 $t->parse( "future_item", "future_item_tpl" );
102 }
103 elseif( $ScoreCurrent == "disabled" )
104 {
105 $stop = $game->stopDate();
106 $t->set_var( "game_stop", $locale->format( $stop, false ) );
107 $t->parse( "not_closed_item", "not_closed_item_tpl" );
108 }
109 else
110 {
111 $printScores = true;
112 }
113 }
114
115 if( $printScores == true )
116 {
117 if( $count > 0 )
118 {
119 foreach( $scores as $score )
120 {
121
122 $currentScore = $score->totalScore();
123
124 if( $currentScore == $last && $position != ( $Offset + 1 ) )
125 {
126 $t->set_var( "score_position", "&nbsp;" );
127
128 if( $lastColor == "bglight" || $i = 0 )
129 {
130 $t->set_var( "td_class", "bglight" );
131 }
132 else
133 {
134 $t->set_var( "td_class", "bgdark" );
135 }
136 }
137 else
138 {
139 $t->set_var( "score_position", $position );
140 if( $lastColor == "bglight" )
141 {
142 $t->set_var( "td_class", "bgdark" );
143 $lastColor = "bgdark";
144 }
145 else
146 {
147 $t->set_var( "td_class", "bglight" );
148 $lastColor = "bglight";
149 }
150 }
151
152
153 $t->set_var( "score", $currentScore );
154
155 $user = $score->user();
156
157 $t->set_var( "player", $user->login() );
158 $t->set_var( "player_id", $user->id() );
159
160 $t->parse( "score_item", "score_item_tpl", true );
161
162 $last = $currentScore;
163 $position++;
164 $i++;
165 }
166
167 $t->parse( "score_list_item", "score_list_item_tpl" );
168 }
169 else
170 {
171 $t->parse( "no_scores_item", "no_scores_item_tpl" );
172 }
173 }
174
175 eZList::drawNavigator( $t, $scoreCount, $Limit, $Offset, "score_page_tpl" );
176
177 if( $error )
178 {
179 switch( $error )
180 {
181 default:
182 {
183 $t->set_var( "error_message", $intl->variable( "strings", "error_undefined" ) );
184 $t->parse( "error_item", "error_item_tpl" );
185 }
186 break;
187 }
188 }
189
190 $t->pparse( "output", "score_page_tpl" );
191
192 ?>
$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
eZQuizGame
Definition: ezquizgame.php:43
eZQuizScore
Definition: ezquizscore.php:43
eZTemplate
Definition: eztemplate.php:107
$error
$error
Definition: ezarticle/admin/categoryedit.php:51
$Offset
$Offset
Definition: ezarticle/user/search.php:110
$printScores
$printScores
Definition: quizmyscores.php:70
$Limit
$Limit
Definition: quizscores.php:42
$locale
$locale
Definition: quizscores.php:86
$t
$t
Definition: quizscores.php:46
$intl
$intl
Definition: quizscores.php:49
$GenerateStaticPage
$GenerateStaticPage
Definition: quizscores.php:95
$lastColor
$lastColor
Definition: quizscores.php:84
$position
$position
Definition: quizscores.php:85
$game
$game
Definition: quizscores.php:71
$Language
$Language
Definition: quizscores.php:43
$ini
$ini
Definition: quizscores.php:40
$ScoreCurrent
$ScoreCurrent
Definition: quizscores.php:44
$scores
$scores
Definition: quizscores.php:78
$score
$score
Definition: quizscores.php:77
$scoreCount
$scoreCount
Definition: quizscores.php:81
$last
$last
Definition: quizscores.php:83
$count
$count
Definition: quizscores.php:80
$user
$user
Definition: user/adlist.php:39
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.