r20736 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r20735‎ | r20736 | r20737 >
Date:10:26, 27 March 2007
Author:lrbabe
Status:old
Tags:
Comment:
Layout improvement and two bugs solved.
Modified paths:
  • /trunk/extensions/Quiz/Quiz.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Quiz/Quiz.php
@@ -28,7 +28,7 @@
2929 * * Add this line at the end of your LocalSettings.php file :
3030 * require_once 'extensions/quiz/Quiz.php';
3131 *
32 - * @version 0.5b
 32+ * @version 0.6b
3333 * @link http://www.mediawiki.org/wiki/Extension:Quiz
3434 *
3535 * @author BABE Louis-R�mi <lrbabe@gmail.com>
@@ -39,7 +39,7 @@
4040 */
4141 $wgExtensionCredits['parserhook'][] = array(
4242 'name'=>'Quiz',
43 - 'version'=>'0.5b',
 43+ 'version'=>'0.6b',
4444 'author'=>'lrbabe',
4545 'url'=>'http://www.mediawiki.org/wiki/Extension:Quiz',
4646 'description' => 'Quiz tool for MediaWiki'
@@ -199,6 +199,8 @@
200200 $head .= ".quiz .correction { background-color: ".$this->getColor('correction').";}\n";
201201 $head .= ".quiz .hideCorrection .correction { display: none; }\n";
202202 $head .= ".quiz .settings td { padding: 0.1em 0.4em 0.1em 0.4em }\n";
 203+ $head .= ".quiz .sign {text-align:center; }\n";
 204+ $head .= ".quiz .sign>input {border: none !important; }\n";
203205 $head .= "</style>\n";
204206 global $wgJsMimeType, $wgScriptPath, $wgOut;
205207 $head .= "<script type=\"$wgJsMimeType\" src=\"$wgScriptPath/extensions/quiz/quiz.js\"></script>\n";
@@ -210,21 +212,21 @@
211213 $output .= "<table class=\"settings\"><tbody>";
212214 $output .= "<tr><td>".wfMsgHtml('quiz_addedPoints')." : </td>" .
213215 "<td><input class=\"text\" type=\"text\" name=\"addedPoints\" value=\"$this->mAddedPoints\"/></td><td></td>" .
214 - "<td>".wfMsgHtml('quiz_colorError')." : </td>" .
215 - "<td style=\"background: ".$this->getColor('error')."\"></td></tr>";
 216+ "<td style=\"background: ".$this->getColor('error')."\"></td>" .
 217+ "<td>".wfMsgHtml('quiz_colorError')."</td></tr>";
216218 $output .= "<tr><td>".wfMsgHtml('quiz_cutoffPoints')." : </td>" .
217219 "<td><input class=\"text\" type=\"text\" name=\"cutoffPoints\" value=\"$this->mCutoffPoints\"/></td><td></td>" .
218 - "<td class=\"correction\" style=\"background: transparent;\">".wfMsgHtml('quiz_colorRight')." : </td>" .
219 - "<td class=\"correction\" style=\"background: ".$this->getColor('right')."\"></td></tr>";
220 - $bChecked = ($this->mIgnoringCoef)? "checked" : "";
 220+ "<td class=\"correction\" style=\"background: ".$this->getColor('right')."\"></td>" .
 221+ "<td class=\"correction\" style=\"background: transparent;\">".wfMsgHtml('quiz_colorRight')."</td></tr>";
 222+ $bChecked = ($this->mIgnoringCoef)? "checked=\"checked\"" : "";
221223 $output .= "<tr><td>".wfMsgHtml('quiz_ignoreCoef')." : </td>" .
222224 "<td><input type=\"checkbox\" name=\"ignoringCoef\" $bChecked/></td><td></td>" .
223 - "<td class=\"correction\" style=\"background: transparent;\">".wfMsgHtml('quiz_colorWrong')." : </td>" .
224 - "<td class=\"correction\" style=\"background: ".$this->getColor('wrong')."\"></td></tr>";
 225+ "<td class=\"correction\" style=\"background: ".$this->getColor('wrong')."\"></td>" .
 226+ "<td class=\"correction\" style=\"background: transparent;\">".wfMsgHtml('quiz_colorWrong')."</td></tr>";
225227 $output .= "<tr><td></td>" .
226228 "<td><input type=\"hidden\" name=\"quizId\" value=\"$this->mQuizId\"/></td><td></td>" .
227 - "<td class=\"correction\" style=\"background: transparent;\">".wfMsgHtml('quiz_colorNA')." : </td>" .
228 - "<td class=\"correction\" style=\"background: ".$this->getColor('NA')."\"></td></tr>";
 229+ "<td class=\"correction\" style=\"background: ".$this->getColor('NA')."\"></td>" .
 230+ "<td class=\"correction\" style=\"background: transparent;\">".wfMsgHtml('quiz_colorNA')."</td></tr>";
229231 $output .= "</tbody></table>";
230232
231233 $input = $this->parseIncludes($input);
@@ -499,7 +501,8 @@
500502 $typeId = substr($this->mType, 0, 1);
501503 $typeId .= array_key_exists(1, $matches)? "c" : "n";
502504 foreach($matches as $signId => $sign) {
503 - $cellStyle = "";
 505+ //$ieStyle = $ffStyle = "";
 506+ $inputStyle = "";
504507 # Determine the input's name and value.
505508 switch($typeId) {
506509 case "mn":
@@ -520,7 +523,7 @@
521524 break;
522525 }
523526 # Determine if the input had to be checked.
524 - $checked = ($quiz->mBeingCorrected && $quiz->mRequest->getVal($name) == $value)? "checked" : NULL;
 527+ $checked = ($quiz->mBeingCorrected && $quiz->mRequest->getVal($name) == $value)? "checked=\"checked\"" : NULL;
525528 # Determine the color of the cell and modify the state of the question.
526529 switch($sign) {
527530 case "+":
@@ -530,16 +533,16 @@
531534 if($this->mType == "singleChoice" && $expectOn > 1) {
532535 $expected = "=";
533536 $this->setState("error");
534 - $cellStyle = " style=\"background: ".$quiz->getColor('error').";\"";
 537+ $inputStyle = "style=\"outline: ".$quiz->getColor('error')." solid 3px; border: 3px solid ".$quiz->getColor('error').";\"";
535538 }
536539 if($quiz->mBeingCorrected) {
537540 if($checked) {
538541 $checkedCount++;
539542 $this->setState("right");
540 - $cellStyle = " style=\"background: ".$quiz->getColor('right').";\"";
 543+ $inputStyle = "style=\"outline: ".$quiz->getColor('right')." solid 3px; border: 3px solid ".$quiz->getColor('right').";\"";
541544 } else {
542545 $this->setState("na_wrong");
543 - $cellStyle = " style=\"background: ".$quiz->getColor('wrong').";\"";
 546+ $inputStyle = "style=\"outline: ".$quiz->getColor('wrong')." solid 3px; border: 3px solid ".$quiz->getColor('wrong').";\"";
544547 }
545548 }
546549 break;
@@ -549,7 +552,7 @@
550553 if($checked) {
551554 $checkedCount++;
552555 $this->setState("wrong");
553 - $cellStyle = " style=\"background: ".$quiz->getColor('wrong').";\"";
 556+ $inputStyle = "style=\"outline: ".$quiz->getColor('wrong')." solid 3px; border: 3px solid ".$quiz->getColor('wrong').";\"";
554557 } else {
555558 $this->setState("na_right");
556559 }
@@ -558,11 +561,11 @@
559562 default:
560563 $expected = "=";
561564 $this->setState("error");
562 - $cellStyle = " style=\"background: ".$quiz->getColor('error').";\"";
 565+ $inputStyle = "style=\"outline: ".$quiz->getColor('error')." solid 3px; border: 3px solid ".$quiz->getColor('error').";\"";
563566 break;
564567 }
565 - $signesOutput .= "<td$cellStyle>";
566 - $signesOutput .= "<input class=\"$expected\" type=\"$inputType\" name=\"$name\" value=\"$value\" $checked/>";
 568+ $signesOutput .= "<td class=\"sign\">";
 569+ $signesOutput .= "<input class=\"$expected\" $inputStyle type=\"$inputType\" name=\"$name\" value=\"$value\" $checked/>";
567570 $signesOutput .= "</td>";
568571 }
569572 if($typeId == "sc") {
@@ -594,7 +597,7 @@
595598 }
596599 }
597600 # A single choice object with no correct proposal is a syntax error.
598 - if($typeId == "sn" && $expectOn == 0) {
 601+ if(isset($typeId) && $typeId == "sn" && $expectOn == 0) {
599602 $this->setState("error");
600603 }
601604 return $output;