Gamification in Alfresco by Francisco Javier Álvarez
Talking about gamification...
Original post can be found here
Gamification is becoming very popular nowadays. Actually, when I was introduced to the concept, I heard Gamification was going to be as revelant in the future as Cloud Computing is at present.That comment shocked me and I started to pay attention to everything which was related to Gamification.
For those who are not very familiar with the concept, I will include the Wikipedia definition of gamification here.
"Gamification is the use of game design techniques and mechanics to enhance non-games. Typically gamification applies to non-game applications and processes (also known as "funware"), in order to encourage people to adopt them, or to influence how they are used. Gamification works by making technology more engaging, by encouraging users to engage in desired behaviors, by showing a path to mastery and autonomy, and by taking advantage of humans' psychological predisposition to engage in gaming. The technique can encourage people to perform chores that they ordinarily consider boring, such as completing surveys, shopping, filling out tax forms, or reading web sites.[3] Available data from gamified websites, applications, and processes indicate potential improvements in areas like user engagement, ROI, data quality, timeliness, or learning."
Instead of words, we might use some images:
The question you see above is a very good one, and I have wondered this many times myself. Does gamification make sense in the context of a ECM? The first time I asked myself that question, my answer was "probably not". But world changes, and so does Alfresco. In the last release, Alfresco 3 and its revision plus the latest release, Alfresco 4, everything is evolutioning in order to become Alfresco as a more social product. Not only social, but collaborative. For example, did you realize one of the biggest news for Alfresco 3 release was the inclusion of Alfresco Share? And did you also realize one of the greatest news for Alfresco 4 has been the Social content stuff?
And since Alfresco is immersing in a collaborative continous improvement, why not include in this collaboration some kind of gamification? Okay, most of ECM projects might not require to include nothing related to gamification in its scope, not even collaboration. But we can't skip this topic for that reason, we should give gamification a try.
That's why we've answered the question with "Let's do gamification!"
Obviously, as gamification makes complete sense inside collaboratives environments, this concept will be introduced into Alfresco as Share dashlets for Sites. But the information to show, or to be configured needs to be backened into Alfresco. Due to those facts, the Alfresco gamification module is compounded by two separated items: A module for Alfresco, an another one for Share.
Inside the share module, we have three dashlets right now (we want to create many more): A ranking dashlets wheresite's users are sorted according to their activity inside the site, an achievement configuration dashlet, where sites admin users can configure the achievements for a site, an a user achievements dashlet, where every user can see the achievements he has obtained. Let's go through them.
Although the tangible side of the tool is focused on the Share interface, the repository must be aware of these features. Not only being aware but also support the communication with share. In other words, actually Alfresco manages from the webscript call Share to the model built for gamification purpose, so although apparently everything needed to be development is done inside Share, we will find a lot of stuff inside the Alfresco module.
(Currently under ranking namespace because it was the first dashlet created. It will be modified)
Two aspects has been created: rankingable, to manage the ranking feature, and achievable, to manage the achievement one.
<?xml version='1.0' encoding='UTF-8'?> <model name="rk:contentmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0"> <description>Ranking Model</description> <author>Zaizi Ltd</author> <version>1.0</version> <imports> <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" /> <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" /> </imports> <namespaces> <namespace uri="http://www.alfresco.org/model/ranking/1.0" prefix="rk" /> </namespaces> <constraints> <constraint name="rk:actionList" type="LIST"> <parameter name="allowedValues"> <list> <value>Creations</value> <value>Own Updates</value> <value>Other Updates</value> <value>Comments</value> </list> </parameter> </constraint> </constraints> <aspects> <aspect name="rk:rankingable"> <title>Ranking Aspect</title> <properties> <property name="rk:creations"> <title>Documents Created</title> <type>d:int</type> <default>0</default> </property> <property name="rk:updates"> <title>Documents Updated</title> <type>d:int</type> <default>0</default> </property> <property name="rk:updates_owner"> <title>Documents Owner Updated</title> <type>d:int</type> <default>0</default> </property> <property name="rk:comments"> <title>Comments</title> <type>d:int</type> <default>0</default> </property> <property name="rk:others"> <title>Other Considerations</title> <type>d:int</type> <default>0</default> </property> </properties> </aspect> <aspect name="rk:achievable"> <title>Achievement Aspect</title> <properties> <property name="rk:title"> <title>Achievement title</title> <type>d:text</type> <mandatory>true</mandatory> </property> <property name="rk:action"> <title>Achievement action</title> <type>d:text</type> <mandatory>true</mandatory> <constraints> <constraint ref="rk:actionList" /> </constraints> </property> <property name="rk:value"> <title>Number of times</title> <type>d:int</type> <mandatory>true</mandatory> <default>0</default> </property> <property name="rk:image"> <title>Achievement image</title> <type>d:noderef</type> </property> <property name="rk:users"> <title>Users who achieved this</title> <type>d:text</type> <multiple>true</multiple> </property> </properties> </aspect> </aspects> </model>
Behaviour to persist the information
Once the model has been created, it is likely to be used. The features related above are oriented to score the work within the repository by the users. It means, user created documents, editted them, etc. And this information must be stored within the model. Following the best practices, the best way to solve that is by creating a behaviour which control the manipulation of the nodes of a site, so these operations inside the repository must be tracked easily, and adding some logic to map those operations in Alfresco by the aspects related above. Plus, if we want to change the logic concerning the events to be managed (e.g. we also could give importance to the node readings) we could do it adding some code inside the behaviour class.
(As before, right now it is called UpdateRankingBehaviour so the name needs to be modified)
We won't focus on the whole code, it will be avalaible to be inspected as soon as we make the changes I've been relating.
public class UpdateRankingBehaviour implements NodeServicePolicies.OnUpdatePropertiesPolicy, NodeServicePolicies.BeforeDeleteNodePolicy, NodeServicePolicies.OnCreateChildAssociationPolicy
DAOs, services, and webscripts
In order to map the concepts Score and Achievement inside Java objects, a typical Java structure has been created for operate with them. So for both entities we have a model class, a model DAO to handle the objects within the repository, and a service to provide operations for those entities. Last but not least, we have the webscripts to be used by Share, which manage the information by calling the services just related. Since the achievement configuration dashlet is a CRUS dashlet, there are four webscripts, plus the achievement users dashlet and the ranking dashlet. So there are six webscripts in total. The diagram below is self-explanatory:
When and how store the information? Since the dashlets are site oriented, the best place is inside the site folder. So the structure inside the repository will be like this:
- Company Home/Sites/"site_x"/ranking
- Company Home/Sites/"site_x"/achievements
And inside those folders there will be as many nodes as site's users. Once the where has been resolved, let's answer the 'how' question. It seems clear that the very best moment where the folders above must be created are when the site is created. Because of that, an interceptor to the function "createSite" of the siteService has been created. In addition, the node for managing the information of every single user is created/removed when the membership of a site is given/ungiven respectively.
As the Alfresco backend side must be considered as understood, the next step is showing the different dashlets than can be found in the Gamification module for share.
The ranking dashlet provides information about how active and proactive are the users of a site. Depending of the operations the users do in the scope of a site, and the weights associated (configured by properties) the ranking service related above will build an ordered list of all the users of a site, from the more active to the least. An example of that could be:
Concept Weight Create a document 4 Edit a document 2 Post a comment1
In this case, creations will take relevance over other operations, and the most creator users may occupy the top positions of the ranking.
Achievement configuration dashlet
This dashlet will alow the admin user to create the own achievements for a site, where an operation, a number of times and an image give the shape to the object.
This dashlet will provide to every user the information of all the achievements obtained by himself.
As the same way Alfresco and gamification evolves, we do. So this is just one out of the many blog posts about this cool integration that we will be writing. So, please, staty tuned! You will be rewarded!