Extension:AchievementBadges

MediaWiki extensions manual
OOjs UI icon advanced.svg
AchievementBadges
Release status: experimental
Implementation Special page
Description Provides an achievement system
Author(s) Femiwiki Team
Compatibility policy Snapshots releases along with MediaWiki. Master is not backwards compatible.
MediaWiki 1.35+
License GNU Affero General Public License 3.0 or later
Download
CHANGELOG
Translate the AchievementBadges extension

Check usage and version matrix.

AchievementBadges is an extension that provides an achievement system for MediaWiki wikis.

  • No Dependencies: There are only optional dependencies, unlike other similar achievement system extensions.
  • Customizability: There are built-in achievements, but you can disable each of them as needed.
  • Extensibility: If you are a developer, you can create your own achievements via hooks.

FeaturesEdit

  • Special:Achievements shows the list of the achieved achievements to logged-in users.
  • The user who earned an achievement will get notification. (Echo required)
  • You can install AchievementBadges as a beta feature. (BetaFeatures required)

InstallationEdit

  • Download and place the file(s) in a directory called AchievementBadges in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    wfLoadExtension( 'AchievementBadges' );
    
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

ConfigurationEdit

ParametersEdit

TBD. See the extension.json for live update.

OthersEdit

SNS sharing links display in Special:ShareAchievement are just plain text. The interface administrator of the wiki can styling it via Common.css. See below example.

.mw-special-ShareAchievement .share-media a {
  display: inline-block;
  width: 2em;
  height: 2em;
  background-size: 2em;
}
.mw-special-ShareAchievement .share-media span {
  display: none;
}
.mw-special-ShareAchievement #share-achievement-facebook {
  background-image: url(https://PATH/TO/SOME_LOGO.png);
}
.mw-special-ShareAchievement #share-achievement-twitter {
  background-image: url(https://PATH/TO/SOME_LOGO2.png);
}

Creating a new achievementEdit

Do not create a new achievement during the beta period.

DefinitionsEdit

Achievement definitions happen in the method that responds to the BeforeCreateAchievement hook.

If you are adding a achievement type, its name should be 32 bytes or less including the index number(edit-page-3). The numbers is appended to the key of stats achievements automatically based on the thresholds of the achievements.

public static function onBeforeCreateAchievement( array &$achievements ) {
    global $wgScriptPath;
	$achievements['my-new-achievement'] = [
		'type' => 'instant',
		'priority' => 500,
		'icon' => "$ScriptPath/path/to/icon.svg",
		'og-image' => "$ScriptPath/path/to/og-image.png",
	];
}
description default allowed value
type TBD. 'instant' or 'stats'
priority TBD. 1000 int
icon TBD. $wgAchievementBadgesAchievementFallbackIcon string
og-image TBD. $wgAchievementBadgesAchievementFallbackOpenGraphImage string

Your i18n messages:

  • achievementbadges-achievement-name-my-new-achievement - for the name of the achievement. This is appears as a title of notification, displayed as a description in Special:Log, and displayed in Special:Achievements and Special:ShareAchievement.
  • achievementbadges-achievement-hint-my-new-achievement - for the Special:Achievements description that appears when the achievement is not achieved.
  • achievementbadges-achievement-description-my-new-achievement - for the Special:Achievements description that appears when the achievement is achieved and displayed in Special:ShareAchievement.

TBD.

Trigger the achievementEdit

public static function onSomeHook( User $user ) {
    if ( !$user->isAnon() ) {
        Achievement::achieve( [ 'key' => 'my-new-achievement', 'user' => $user ] );
    }
}

TBD.

Additional notesEdit

Currently, a record of user achievement is stored in logging table as a log. If a log is suppressed, the achievement is also removed.

See alsoEdit


This extension was originally made for Femiwiki.