github-actions[bot] commited on
Commit
117b749
·
1 Parent(s): bf8d35c

deploy: backend from 9bbd9a6

Browse files
Files changed (1) hide show
  1. routes/at_risk_resolution.py +21 -5
routes/at_risk_resolution.py CHANGED
@@ -82,15 +82,31 @@ def _resolve_topic(
82
 
83
  if doc.exists:
84
  data = doc.to_dict() or {}
85
- module_id = topic.topic_id
86
- module_status = data.get("moduleStatus") or data.get("status") or "unavailable"
87
- else:
 
 
 
 
 
 
 
 
88
  # Fallback: query by topicId field
89
- query = modules_ref.where("topicId", "==", topic.topic_id).limit(1).stream()
90
  for match in query:
91
  data = match.to_dict() or {}
 
 
 
 
 
 
 
 
92
  module_id = match.id
93
- module_status = data.get("moduleStatus") or data.get("status") or "unavailable"
94
  break
95
 
96
  if not module_id or not module_status:
 
82
 
83
  if doc.exists:
84
  data = doc.to_dict() or {}
85
+ candidate_status = data.get("moduleStatus") or data.get("status") or "unavailable"
86
+ assigned_to = data.get("assignedTo")
87
+ is_teacher_uploaded = (
88
+ data.get("moduleType") == "teacher_uploaded"
89
+ or candidate_status == "teacher_uploaded"
90
+ )
91
+ if not (is_teacher_uploaded and assigned_to and assigned_to != uid):
92
+ module_id = topic.topic_id
93
+ module_status = candidate_status
94
+
95
+ if not module_id:
96
  # Fallback: query by topicId field
97
+ query = modules_ref.where("topicId", "==", topic.topic_id).stream()
98
  for match in query:
99
  data = match.to_dict() or {}
100
+ candidate_status = data.get("moduleStatus") or data.get("status") or "unavailable"
101
+ assigned_to = data.get("assignedTo")
102
+ is_teacher_uploaded = (
103
+ data.get("moduleType") == "teacher_uploaded"
104
+ or candidate_status == "teacher_uploaded"
105
+ )
106
+ if is_teacher_uploaded and assigned_to and assigned_to != uid:
107
+ continue
108
  module_id = match.id
109
+ module_status = candidate_status
110
  break
111
 
112
  if not module_id or not module_status: