Physikerwelt has uploaded a new change for review. https://gerrit.wikimedia.org/r/160613
Change subject: Add user feedback ...................................................................... Add user feedback Change-Id: I74fc3e07fc0e3efc4552fbb84e304721a15f6047 --- M SpecialUploadResult.php A db/snippets/math_wmc_rank_success.sql M i18n/en.json 3 files changed, 76 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MathSearch refs/changes/13/160613/1 diff --git a/SpecialUploadResult.php b/SpecialUploadResult.php index 8d0d041..35b2af0 100644 --- a/SpecialUploadResult.php +++ b/SpecialUploadResult.php @@ -17,7 +17,7 @@ } private static function formatErrors( $errors ) { - return wfMessage( 'math-wmc-Warnings' )->text() . ' ' . implode( "<br />", $errors ); + return wfMessage( 'math-wmc-Warnings' )->text() . "<br />" . implode( "<br />", $errors ); } function execute( $query ) { @@ -28,12 +28,18 @@ $this->getOutput()->addWikiText( wfMessage( 'math-wmc-Introduction' )->text() ); $formDescriptor = $this->printRunSelector(); - $formDescriptor['File'] = array( 'label-message' => 'math-wmc-FileLabel', + $formDescriptor['File'] = array( + 'label-message' => 'math-wmc-FileLabel', 'help-message' => 'math-wmc-FileHelp', 'class' => 'HTMLTextField', 'type' => 'file', 'required' => true, 'validation-callback' => array( $this, 'runFileCheck' ), + ); + $formDescriptor['displayFormulae'] = array( + 'label-message' => 'math-wmc-display-formulae-label', + 'help-message' => 'math-wmc-display-formulae-help', + 'type' => 'check', ); $htmlForm = new HTMLForm( $formDescriptor, $this->getContext() ); @@ -111,7 +117,7 @@ function runFileCheck( ) { $out = $this->getOutput(); - $out->addWikiMsg( 'dt_import_importing' ); + $uploadResult = ImportStreamSource::newFromUpload( 'wpFile' ); if ( ! $uploadResult->isOK() ) { @@ -121,7 +127,7 @@ $source = $uploadResult->value; $this->results = array(); - + $out->addWikiMsg( 'math-wmc-importing' ); $error_msg = $this->importFromFile( $source->mHandle ); if ( ! is_null( $error_msg ) ) { @@ -157,14 +163,20 @@ $this->printResultRow( $result ); } $this->getOutput()->addHTML('</table>'); + $this->displayFeedback(); return true; } private function printResultRow( $row ){ $md5 = MathObject::hash2md5( $row['math_inputhash'] ); - $renderer = MathRenderer::newFromMd5($md5); - if ( $renderer->render() ){ - $renderedMath = $renderer->getHtmlOutput(); + if( $this->getRequest()->getBool( "wpdisplayFormulae" ) ){ + $this->getOutput()->addModuleStyles( array( 'ext.math.styles' ) ); + $renderer = MathLaTeXML::newFromMd5($md5); + if ( $renderer->render() ){ + $renderedMath = $renderer->getHtmlOutput(); + } else { + $renderedMath = $md5; + } } else { $renderedMath = $md5; } @@ -278,4 +290,44 @@ 'rank' => $rank, 'math_inputhash' => $fHash ); } + + private function displayFeedback(){ + $runId=$this->runID; + $dbr=wfGetDB(DB_SLAVE); + $res = $dbr->select( + array('l'=>'math_wmc_rank_levels','r'=>'math_wmc_ref','math_wmc_results'), + array( 'count(DISTINCT `r`.`qId`) AS `c`', + '`l`.`level` AS `level`'), + array( "(`math_wmc_results`.`rank` <= `l`.`level`)" , + 'runId'=>$runId, + '`math_wmc_results`.`oldId` = `r`.`oldId`', + '`math_wmc_results`.`qId` = `r`.`qId`' + ), + __METHOD__, + array( 'GROUP BY' => '`l`.`level`', + 'ORDER BY' => 'count(DISTINCT `r`.`qId`) DESC') + ); + if ( ! $res || $res->numRows() == 0 ){ + $this->getOutput()->addWikiText( "Score is 0. Check your submission"); + return ; + } else { + $this->getOutput()->addWikiText( "'''Scored in " . $res->numRows() . " evaluation levels'''"); + } + + $this->getOutput()->addHTML('<table border="1" style="width:100%"> + <tr> + <th>number of correct results</th> + <th>rank cutoff</th> + </tr>'); + foreach ( $res as $result ) { + $c=$result->c; + $l=$result->level; + $this->getOutput()->addHTML(" + <tr> + <td>$c</td> + <td>$l</td> + </tr>"); + } + $this->getOutput()->addHTML('</table>'); + } } diff --git a/db/snippets/math_wmc_rank_success.sql b/db/snippets/math_wmc_rank_success.sql new file mode 100644 index 0000000..083085a --- /dev/null +++ b/db/snippets/math_wmc_rank_success.sql @@ -0,0 +1,12 @@ +CREATE OR REPLACE ALGORITHM = UNDEFINED + SQL SECURITY DEFINER VIEW `wmc_rank_sucess` AS ( + SELECT + count(DISTINCT `r`.`qId`) AS `c`, + `math_wmc_results`.`runId` AS `runId`, + `l`.`level` AS `level` + FROM (math_wmc_rank_levels `l` JOIN (`math_wmc_ref` `r` JOIN `math_wmc_results` + ON (((`math_wmc_results`.`oldId` = `r`.`oldId`) AND + (`math_wmc_results`.`qId` = `r`.`qId`))))) + WHERE (`math_wmc_results`.`rank` <= `l`.`level`) + GROUP BY `math_wmc_results`.`runId`, `l`.`level` + ORDER BY count(DISTINCT `r`.`qId`) DESC); \ No newline at end of file diff --git a/i18n/en.json b/i18n/en.json index 9ac4816..be81c15 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -40,5 +40,9 @@ "math-wmc-too-many-results": "Line $1: Reason too many results for $2. \n Calculated rank for formulae \"$3\" was \"$4\". This is higher than the maximal allowed number of submission ($wgMathWmcMaxResults=$5).", "math-wmc-malformed-formula-reference":"Line $1: Formula reference \"$2\" does not match the pattern \"$3\".", "math-wmc-wrong-formula-reference": "Line $1: Formula reference (revision \"$2\", formula \"$3\") is invalid.", - "math-wmc-wrong-query-reference": "Line $1: Query reference \"$2\" is invalid." + "math-wmc-wrong-query-reference": "Line $1: Query reference \"$2\" is invalid.", + "math-wmc-importing": "Importing...", + "math-wmc-display-formulae-label": "Display rendering of submitted formulae", + "math-wmc-display-formulae-help": "Not recommended for large input files.", + "action-mathwmcsubmit": "submit results to the NTCIR Wikipedia Math Search Task" } \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/160613 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I74fc3e07fc0e3efc4552fbb84e304721a15f6047 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MathSearch Gerrit-Branch: master Gerrit-Owner: Physikerwelt <w...@physikerwelt.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits