expose per-node lessonIds in GET /api/home
The skill-map response gave units -> nodes with id/title/status but no way to map a node to its lessons, and no other endpoint fills that gap (/api/progress/nodes doesn't either). Any client rendering the map needs this to know which lesson to open when a node is tapped. The ids are already computed in the cached _grade_tree; this just surfaces them. Additive and backward-compatible; content tests pass. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,9 @@ class NodeStatusSerializer(serializers.Serializer):
|
||||
id = serializers.CharField()
|
||||
title = serializers.CharField()
|
||||
status = serializers.ChoiceField(choices=['locked', 'unlocked', 'completed'])
|
||||
# شناسهی درسهای همین گره تا کلاینت بدونه با کلیک روی گره کدوم درس رو
|
||||
# باز کنه (endpointهای lessons/{id}/... مستقیم با همین id کار میکنن).
|
||||
lessonIds = serializers.ListField(child=serializers.IntegerField())
|
||||
|
||||
|
||||
class UnitWithNodesSerializer(serializers.Serializer):
|
||||
|
||||
@@ -183,7 +183,12 @@ class HomeView(APIView):
|
||||
node_status = _node_status(node['lesson_ids'], completed_ids, unlock_next)
|
||||
if node_status != 'completed':
|
||||
unlock_next = False
|
||||
node_payload.append({'id': node['id'], 'title': node['title'], 'status': node_status})
|
||||
node_payload.append({
|
||||
'id': node['id'],
|
||||
'title': node['title'],
|
||||
'status': node_status,
|
||||
'lessonIds': node['lesson_ids'],
|
||||
})
|
||||
units_payload.append({'id': unit['id'], 'title': unit['title'], 'nodes': node_payload})
|
||||
|
||||
stats = UserStats.objects.filter(user_id=user_id).first()
|
||||
|
||||
Reference in New Issue
Block a user