app.engine.greengageStrategy module¶
- class app.engine.greengageStrategy.GREENGAGEGamificationStrategy[source]¶
Bases:
BaseStrategy- get_DPTE(points, minutes=0)[source]¶
Returns the Default Points Time Elapsed (DPTE) based on the number of minutes elapsed, using the floor of the time range.
- Parameters:
minutes (int) – The number of minutes elapsed.
- Returns:
int – The Default Points Time Elapsed (DPTE).
- get_BP(points=0, minutes=0)[source]¶
Returns the Bonus Points (BP) based on the number of minutes elapsed.
- Parameters:
minutes (int) – The number of minutes elapsed.
points (int)
- Returns:
int – The Bonus Points (BP).
- get_PBP(points=0, minutes=0)[source]¶
- Returns the Personal Bonus Points (PBP) based on the number of minutes
elapsed.
- Parameters:
minutes (int) – The number of minutes elapsed.
points (int)
- Returns:
int – The Personal Bonus Points (PBP).
- generate_logic_graph(format='png')[source]¶
Render this strategy’s decision tree as a Graphviz diagram.
Builds a labelled flowchart (legend, decision nodes and the Case 1.1–4.2 outcomes) describing how minutes, records and global/personal averages map to a point award. Used by the dashboard to visualize the strategy.
- Parameters:
format (str) – Graphviz output format (e.g.
"png","svg").- Returns:
graphviz.Digraph – The constructed diagram.
- async calculate_points(externalGameId, externalTaskId, externalUserId, data)[source]¶
Award points from reported effort minutes and task complexity.
Requires a numeric
minutesvalue indata. The award follows the Case 1.1–4.2 decision tree (seegenerate_logic_graph()), weighting the configured default points by total complexity and the user’s history/averages.- Parameters:
externalGameId – External identifier of the game.
externalTaskId – External identifier of the task.
externalUserId – External identifier of the user.
data (dict) – Event payload; must contain an integer
minutes.
- Returns:
tuple –
(points, caseName)on success, or(-1, message)whenminutesis missing or invalid.