Complete Socratic adaptive exams in Flutter, Guardian WhatsApp alerts, and curriculum robustness

This commit is contained in:
Hamza-Ayed
2026-09-03 10:14:34 +03:00
parent ab482d85e4
commit 12049fd7da
12 changed files with 1444 additions and 26 deletions
+75
View File
@@ -230,4 +230,79 @@ class NabehService
'response' => $response
];
}
/**
* Send direct WhatsApp text notification via Nabeh Gateway
*/
public function sendMessage(string $receiver, string $message): array
{
$bearerToken = $this->getBearerToken();
if (!$bearerToken) {
return [
'success' => false,
'error' => 'فشل الحصول على توكن المصادقة من منصة نبيه.'
];
}
$phoneRaw = preg_replace('/\D+/', '', $receiver);
if (str_starts_with($phoneRaw, '07')) {
$phoneRaw = '962' . substr($phoneRaw, 1);
} elseif (str_starts_with($phoneRaw, '7') && strlen($phoneRaw) === 9) {
$phoneRaw = '962' . $phoneRaw;
}
$payload = json_encode([
'phone' => $phoneRaw,
'type' => 'text',
'message' => $message,
]);
$ch = curl_init($this->sendUrl);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 25,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
"Authorization: Bearer {$bearerToken}",
],
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curlError = curl_error($ch);
curl_close($ch);
if ($curlError) {
return ['success' => false, 'error' => $curlError];
}
return ['success' => $httpCode === 200, 'response' => $response];
}
/**
* Send Guardian Remedial Alert via WhatsApp
*/
public function sendGuardianRemedialAlert(
string $guardianPhone,
string $studentName,
string $subjectName,
string $weakTopic,
string $portalUrl = 'https://saqel.intaleqapp.com/guardian'
): array {
$message = "🔔 *تنبيه متابعة دراسية من منصة صَقِل* 🧠\n\n"
. "ولي أمر الطالب/ـة: *{$studentName}* المحترم،\n"
. "نحيطكم علماً بأنه أثناء فحص الاستيعاب السقراطي في مادة *{$subjectName}*، تم رصد تعثر في مفهوم:\n"
. "📌 *[{$weakTopic}]*\n\n"
. "✅ *الإجراء المتخذ من المنصة:* تم إرجاع الطالب تلقائياً لمشاهدة المقطع الشارح للمفهوم بدقة لترسيخ الفهم.\n\n"
. "📊 يمكنكم متابعة جاهزية الطالب والتقرير التشخيصي المفصل عبر بوابة ولي الأمر:\n"
. "{$portalUrl}\n\n"
. "مع تحيات فريق الدعم الأكاديمي لمنصة صَقِل ✨";
return $this->sendMessage($guardianPhone, $message);
}
}