Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 24 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
WMCAssessSeeds | |
0.00% |
0 / 21 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | /** |
3 | * This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation; either version 2 of the License, or |
6 | * (at your option) any later version. |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License along |
14 | * with this program; if not, write to the Free Software Foundation, Inc., |
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
16 | * http://www.gnu.org/copyleft/gpl.html |
17 | * |
18 | * @ingroup Maintenance |
19 | */ |
20 | |
21 | use MediaWiki\MediaWikiServices; |
22 | |
23 | require_once __DIR__ . '/../../../maintenance/Maintenance.php'; |
24 | |
25 | class WMCAssessSeeds extends Maintenance { |
26 | |
27 | private $DEFAULT_ASSESSMENT = 2; |
28 | |
29 | public function __construct() { |
30 | parent::__construct(); |
31 | $this->addDescription( 'Automatically creates assessment for formulae and revisions ' . |
32 | 'that have been used to create the topics.' ); |
33 | $this->addArg( 'user', 'The user that is marked as assessor.', true ); |
34 | $this->requireExtension( 'MathSearch' ); |
35 | } |
36 | |
37 | public function execute() { |
38 | $user = User::newFromName( $this->getArg( 0 ) ); |
39 | $uId = $user->getId(); |
40 | if ( $uId > 0 ) { |
41 | $dbw = MediaWikiServices::getInstance() |
42 | ->getConnectionProvider() |
43 | ->getPrimaryDatabase(); |
44 | $this->output( "Insert formula assessments...\n" ); |
45 | $dbw->query( "INSERT IGNORE INTO math_wmc_assessed_formula " |
46 | . "SELECT {$uId}, math_inputhash, qId, {$this->DEFAULT_ASSESSMENT} " |
47 | . "FROM math_wmc_ref" ); |
48 | $this->output( "Inserted {$dbw->affectedRows()} formula assessments.\n" ); |
49 | $this->output( "Insert revision assessments...\n" ); |
50 | $dbw->query( "INSERT IGNORE INTO math_wmc_assessed_revision " |
51 | . "SELECT {$uId}, oldId, qId, {$this->DEFAULT_ASSESSMENT} FROM math_wmc_ref" ); |
52 | $this->output( "Inserted {$dbw->affectedRows()} revision assessments.\n" ); |
53 | } else { |
54 | $this->output( "User {$this->getArg( 0 )} is invalid.\n" ); |
55 | } |
56 | } |
57 | } |
58 | |
59 | $maintClass = WMCAssessSeeds::class; |
60 | /** @noinspection PhpIncludeInspection */ |
61 | require_once RUN_MAINTENANCE_IF_MAIN; |