r21357 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21356‎ | r21357 | r21358 >
Date:22:16, 18 April 2007
Author:lrbabe
Status:old
Tags:
Comment:
Fixed a mistakes on texfield's questions state.
New layout fo the corrected textfields.
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.8.1
 32+ * @version 0.8
3333 * @link http://www.mediawiki.org/wiki/Extension:Quiz
3434 * @author BABE Louis-Remi <lrbabe@gmail.com>
3535 */
@@ -38,10 +38,10 @@
3939 */
4040 $wgExtensionCredits['parserhook'][] = array(
4141 'name'=>'Quiz',
42 - 'version'=>'0.8.1',
 42+ 'version'=>'0.8.2',
4343 'author'=>'lrbabe',
4444 'url'=>'http://www.mediawiki.org/wiki/Extension:Quiz',
45 - 'description' => 'Quiz tool for MediaWiki'
 45+ 'description' => 'Allows creation of quizzes'
4646 );
4747
4848 /**
@@ -205,9 +205,9 @@
206206 $head .= ".quiz .sign {text-align:center; }\n";
207207 # Part for the inputfields
208208 $head .= ".quiz a.input, .quiz a.input:hover, .quiz a.input:active, .quiz a.input:visited { text-decoration:none; color:black; outline:0 }";
209 - $head .= ".quiz a.input span { outline:black solid 1px}";
210 - $head .= "* html .quiz a.input span { border:1px solid black }";
211 - $head .= ".quiz a.input big { font-weight:bold; font-family:sans-serif; }";
 209+ $head .= ".quiz a.input span { outline:#7F9DB9 solid 1px}";
 210+ $head .= "* html .quiz a.input span { border:1px solid #7F9DB9 }";
 211+ $head .= ".quiz a.input em { color:black; background-color:#DFDFDF; margin-right:1px; }";
212212 $head .= ".quiz a.input input { padding-left:2px; border:0; }";
213213 $head .= ".quiz a.input span.correction { padding:3px; margin:0; list-style-type:none; display:none; background-color:".Quiz::getColor("correction")."; }";
214214 $head .= ".quiz a.input:active span.correction, .quiz a.input:focus span.correction { display:inline; position:absolute; margin:1.8em 0 0 0.1em; }";
@@ -367,13 +367,16 @@
368368 case "right":
369369 $this->mTotal += $this->mAddedPoints * $question->mCoef;
370370 $this->mScore += $this->mAddedPoints * $question->mCoef;
 371+ $output .= "title=\" ".wfMsgHtml('quiz_colorRight')." | ".($this->mAddedPoints * $question->mCoef)." \"";
371372 break;
372373 case "wrong":
373374 $this->mTotal += $this->mAddedPoints * $question->mCoef;
374375 $this->mScore -= $this->mCutoffPoints * $question->mCoef;
 376+ $output .= "title=\" ".wfMsgHtml('quiz_colorWrong')." | -".($this->mCutoffPoints * $question->mCoef)." \"";
375377 break;
376378 case "NA":
377379 $this->mTotal += $this->mAddedPoints * $question->mCoef;
 380+ $output .= "title=\" ".wfMsgHtml('quiz_colorNA')." | 0 \"";
378381 break;
379382 }
380383 }
@@ -424,10 +427,11 @@
425428 */
426429 function setState($pState) {
427430 if ($pState == "error"
428 - || ($pState == "wrong" && $this->mState != "error")
429 - || ($pState == "right" && ($this->mState == "right" || $this->mState == "NA" || $this->mState == "na_right"))
430 - || ($pState == "na_wrong" && ($this->mState == "NA" || $this->mState == "na_right"))
431 - || ($pState == "na_right" && ($this->mState == "NA"))
 431+ || ($pState == "wrong" && $this->mState != "error")
 432+ || ($pState == "right" && ($this->mState == "NA" || $this->mState == "na_right"))
 433+ || ($pState == "na_wrong" && ($this->mState == "NA" || $this->mState == "na_right"))
 434+ || ($pState == "na_right" && ($this->mState == "NA"))
 435+ || ($pState == "new_NA" && $this->mState == "right")
432436 ) {
433437 $this->mState = $pState;
434438 }
@@ -446,7 +450,7 @@
447451 function getState() {
448452 if ($this->mState == "na_right") {
449453 return "right";
450 - } elseif ($this->mState == "na_wrong") {
 454+ } elseif ($this->mState == "na_wrong" || $this->mState == "new_NA") {
451455 return "NA";
452456 } else {
453457 return $this->mState;
@@ -753,7 +757,7 @@
754758 if(array_key_exists(5, $matches)) $strlen = $size = $maxlength = "";
755759 elseif(array_key_exists(3, $matches)) $strlen = strlen($matches[1]) > strlen($matches[3])? strlen($matches[1]) : strlen($matches[3]);
756760 else $strlen = strlen($matches[1]);
757 - if($this->mBeingCorrected && $value != "") {
 761+ if($this->mBeingCorrected && !empty($value)) {
758762 $state = (is_numeric($value) &&
759763 ( (array_key_exists(5, $matches) && $value >= ($matches[1]-($matches[1]*$matches[4])/100) && $value <= ($matches[1]+($matches[1]*$matches[4])/100) )
760764 || (array_key_exists(3, $matches) && $value >= $matches[1] && $value <= $matches[3])
@@ -762,7 +766,7 @@
763767 } else {
764768 $strlen = strlen($possibility);
765769 $class = "class=\"words\"";
766 - if($this->mBeingCorrected && $value != "") $state = ($value == $possibility)? "right" : "wrong";
 770+ if($this->mBeingCorrected && !empty($value)) $state = ($value == $possibility)? "right" : "wrong";
767771 }
768772 if(array_key_exists(3, $input) && $strlen > $input[3]) {
769773 # The textfield is too short for the answer
@@ -772,16 +776,16 @@
773777 }
774778 if($this->mBeingCorrected) $a_inputBeg.= "$possibility<br/>";
775779 }
776 - $value = "value=\"".Sanitizer::removeHTMLtags($value)."\"";
 780+ $value = empty($value)? "" : "value=\"".str_replace('"', "'", $value)."\"";
777781 if($this->mBeingCorrected) {
778782 $a_inputBeg.= "</span>";
779783 $a_inputEnd = "</a>";
780 - $big = "<big>v</big>";
 784+ $big = "<em>&#9660;</em>";
781785 }
782786 }
783787 if($state == "error" || $this->mBeingCorrected) {
784788 $style = "style=\"border-left:3px solid ".Quiz::getColor($state)."; \"";
785 - $this->setState($state);
 789+ $this->setState(empty($value)? "new_NA" : $state);
786790 if($state == "error") {
787791 $size = "";
788792 $maxlength = "";