Score/Progression (Phase 1.1 de la feuille de route produit)
Concept de premier ordre, distinct du système de variables globales — préalable identifié aux futurs exports SCORM/xAPI (note de cadrage .claude/Forge_Engine_Cadrage.pdf) : ces standards ont besoin d'un signal "score"/"terminé" propre, pas d'une convention sur une variable choisie par le créateur. - db/scoring/ (même patron que db/global_vars/) : table _scoring, un score numérique + un statut (non_commence/en_cours/termine/reussi/ echoue) par joueur (voir db.PLAYER_SHARED pour l'aperçu créateur). - Deux nouvelles actions de flux, dans les deux éditeurs (document et scène) : "Modifier le score" (réutilise le vocabulaire d'opérations déjà là pour "Modifier une variable" — incrémenter/définir/etc., aucune nouvelle colonne de nœud) et "Définir le statut de la partie". - Routes créateur (routes/flow/flow_node_run_score.py, flow_node_run_status.py) + miroirs publics par joueur (routes/public_play/) — même principe que flow_node_run_variable.py. - GET /game/<slug>/scoring/<player_id> : lecture interne, pas exposée au joueur, préparée pour être consommée par le futur export Web/SCORM. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
76a50fa87a
commit
9776fbc057
@@ -6,6 +6,8 @@ from . import (
|
||||
flow_edge_delete,
|
||||
flow_node_run_data,
|
||||
flow_node_run_variable,
|
||||
flow_node_run_score,
|
||||
flow_node_run_status,
|
||||
flow_node_run_add_row,
|
||||
runtime_payload,
|
||||
)
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
from flask import jsonify
|
||||
|
||||
import screens
|
||||
|
||||
from core.flask_app import app
|
||||
|
||||
|
||||
@app.route("/game/<slug>/flow/nodes/<int:node_id>/run-score", methods=["POST"])
|
||||
def flow_node_run_score(slug, node_id):
|
||||
"""Exécuté côté serveur au moment du clic, en mode jouable, pour un
|
||||
nœud Action de type "Modifier le score" — même principe que
|
||||
flow_node_run_variable.py, pour le score plutôt qu'une variable
|
||||
globale (voir db/scoring/, screens/data_actions/apply_score_action.py)."""
|
||||
node = screens.get_flow_node(slug, node_id)
|
||||
if not node or node.get("node_type") != "action" or node.get("action_type") != "modifier_score":
|
||||
return jsonify({"ok": False}), 400
|
||||
ok = screens.apply_score_action(slug, node)
|
||||
return jsonify({"ok": ok})
|
||||
@@ -0,0 +1,17 @@
|
||||
from flask import jsonify
|
||||
|
||||
import screens
|
||||
|
||||
from core.flask_app import app
|
||||
|
||||
|
||||
@app.route("/game/<slug>/flow/nodes/<int:node_id>/run-status", methods=["POST"])
|
||||
def flow_node_run_status(slug, node_id):
|
||||
"""Exécuté côté serveur au moment du clic, en mode jouable, pour un
|
||||
nœud Action de type "Définir le statut de la partie" — voir
|
||||
db/scoring/, screens/data_actions/apply_status_action.py."""
|
||||
node = screens.get_flow_node(slug, node_id)
|
||||
if not node or node.get("node_type") != "action" or node.get("action_type") != "definir_statut_partie":
|
||||
return jsonify({"ok": False}), 400
|
||||
ok = screens.apply_status_action(slug, node)
|
||||
return jsonify({"ok": ok})
|
||||
@@ -1 +1 @@
|
||||
from . import index, games_new, game_dashboard, game_rename, game_delete, game_toggle_public_played
|
||||
from . import index, games_new, game_dashboard, game_rename, game_delete, game_toggle_public_played, game_scoring_view
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
from flask import jsonify
|
||||
|
||||
import db
|
||||
|
||||
from core.flask_app import app
|
||||
|
||||
|
||||
@app.route("/game/<slug>/scoring/<player_id>")
|
||||
def game_scoring_view(slug, player_id):
|
||||
"""Lecture du score/statut d'UN joueur (voir db/scoring/) — route
|
||||
interne (protégée comme toute route /game/<slug>, voir
|
||||
core/auth_guard.py), pas destinée au joueur lui-même : préparée pour
|
||||
être consommée par les futurs exports SCORM/xAPI (voir le plan
|
||||
"Feuille de route produit"), qui ont besoin de lire ce signal une fois
|
||||
la partie terminée."""
|
||||
return jsonify(db.get_score(slug, player_id))
|
||||
@@ -21,5 +21,7 @@ def game_play(slug):
|
||||
runtime_payload_url=url_for("runtime_payload", slug=slug),
|
||||
flow_node_run_data_url=url_for("flow_node_run_data", slug=slug, node_id=999999),
|
||||
flow_node_run_variable_url=url_for("flow_node_run_variable", slug=slug, node_id=999999),
|
||||
flow_node_run_score_url=url_for("flow_node_run_score", slug=slug, node_id=999999),
|
||||
flow_node_run_status_url=url_for("flow_node_run_status", slug=slug, node_id=999999),
|
||||
flow_node_run_add_row_url=url_for("flow_node_run_add_row", slug=slug, node_id=999999),
|
||||
)
|
||||
|
||||
@@ -3,5 +3,7 @@ from . import (
|
||||
runtime_payload_public,
|
||||
flow_node_run_data_public,
|
||||
flow_node_run_variable_public,
|
||||
flow_node_run_score_public,
|
||||
flow_node_run_status_public,
|
||||
flow_node_run_add_row_public,
|
||||
)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
from flask import jsonify, abort
|
||||
|
||||
import db
|
||||
import screens
|
||||
|
||||
from core.flask_app import app
|
||||
from core.player_identity import get_or_create_player_id, set_player_id_cookie
|
||||
|
||||
|
||||
@app.route("/jouer/<slug>/flow/nodes/<int:node_id>/run-score", methods=["POST"])
|
||||
def flow_node_run_score_public(slug, node_id):
|
||||
"""Miroir public de routes/flow/flow_node_run_score.py (aperçu
|
||||
créateur) — voir routes/public_play/game_play_public.py pour le
|
||||
principe général."""
|
||||
if not db.is_public_played(slug):
|
||||
abort(404)
|
||||
player_id, is_new = get_or_create_player_id()
|
||||
node = screens.get_flow_node(slug, node_id)
|
||||
if not node or node.get("node_type") != "action" or node.get("action_type") != "modifier_score":
|
||||
return jsonify({"ok": False}), 400
|
||||
ok = screens.apply_score_action(slug, node, player_id)
|
||||
resp = app.make_response(jsonify({"ok": ok}))
|
||||
if is_new:
|
||||
set_player_id_cookie(resp, player_id)
|
||||
return resp
|
||||
@@ -0,0 +1,25 @@
|
||||
from flask import jsonify, abort
|
||||
|
||||
import db
|
||||
import screens
|
||||
|
||||
from core.flask_app import app
|
||||
from core.player_identity import get_or_create_player_id, set_player_id_cookie
|
||||
|
||||
|
||||
@app.route("/jouer/<slug>/flow/nodes/<int:node_id>/run-status", methods=["POST"])
|
||||
def flow_node_run_status_public(slug, node_id):
|
||||
"""Miroir public de routes/flow/flow_node_run_status.py (aperçu
|
||||
créateur) — voir routes/public_play/game_play_public.py pour le
|
||||
principe général."""
|
||||
if not db.is_public_played(slug):
|
||||
abort(404)
|
||||
player_id, is_new = get_or_create_player_id()
|
||||
node = screens.get_flow_node(slug, node_id)
|
||||
if not node or node.get("node_type") != "action" or node.get("action_type") != "definir_statut_partie":
|
||||
return jsonify({"ok": False}), 400
|
||||
ok = screens.apply_status_action(slug, node, player_id)
|
||||
resp = app.make_response(jsonify({"ok": ok}))
|
||||
if is_new:
|
||||
set_player_id_cookie(resp, player_id)
|
||||
return resp
|
||||
@@ -29,6 +29,8 @@ def game_play_public(slug):
|
||||
runtime_payload_url=url_for("runtime_payload_public", slug=slug),
|
||||
flow_node_run_data_url=url_for("flow_node_run_data_public", slug=slug, node_id=999999),
|
||||
flow_node_run_variable_url=url_for("flow_node_run_variable_public", slug=slug, node_id=999999),
|
||||
flow_node_run_score_url=url_for("flow_node_run_score_public", slug=slug, node_id=999999),
|
||||
flow_node_run_status_url=url_for("flow_node_run_status_public", slug=slug, node_id=999999),
|
||||
flow_node_run_add_row_url=url_for("flow_node_run_add_row_public", slug=slug, node_id=999999),
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user