Inspiration

In a classroom, AI help is needed on both sides of the desk. Teachers spend hours writing quizzes and even more grading them. Students in Saudi Arabia study for school and for two national exams, Qudrat and Tahsili, with scarce free practice. Most AI tools for either side need an account, a subscription, a computer or an API key. We wanted one free, private classroom project that lives on the phones teachers and students already own.

About Qudrat and Tahsili. These are Saudi Arabia's two national standardized tests, run by the National Center for Assessment (Qiyas), and nearly every secondary-school student who wants to go to university takes them. Qudrat measures verbal and quantitative reasoning; Tahsili measures what the student learned in math, physics, chemistry and biology. Most Saudi universities rank applicants by a composite of the high-school GPA and these two scores, so they decide admission.

What it does

Revisal & Gradal is one project in two iPhone apps. Each user installs the app for their role.

Gradal, for the teacher:

  • Writes questions from the textbook: the teacher adds a PDF in any subject, Arabic or English, picks the pages, and names the paper's parts with their question types and counts. The AI writes the questions, and the teacher reviews every one.
  • Prints everything from the phone: the question paper, the answer key, and a named answer sheet for every student, on any AirPrint printer.
  • Grades with the camera, offline: green on the right answer, red on a wrong choice.
  • Results: scores, class statistics, per-question analysis, and an Excel gradebook. Students are imported from the school system's Excel or PDF list.

Revisal, for the student:

  • Review any curriculum: the student adds a textbook or summary as a PDF, and the AI writes four-option questions across the unit's skills. Refresh brings new ones.
  • Explain: the AI explains why the correct answer is right, only when asked, and a label shows whether it was answered on this iPhone or by Gemini in the cloud.
  • Qudrat and Tahsili banks: 6,011 bundled questions that work offline, with no repeats until the bank is done.
  • Results by skill, every answer next to the correct one, and Retry my mistakes.

Both apps follow the phone's language, Arabic or English, keep all data on the phone, and need no account and no key.

How we built it (how we used Firebase AI Logic)

Both apps are SwiftUI and share one hybrid engine, FirebaseHybrid.swift (identical copies in gradal/ios/Gradal/AI/ and revisal/ios/Revisal/AI/):

  1. On-device first. If Apple Intelligence is available, the prompt is in a supported language and it fits the 4,096-token context, the request runs on the iPhone through Apple's Foundation Models: private, free and offline. A few pages of English text, or one explanation, qualify.
  2. Cloud fallback through Firebase AI Logic. Long chapters, Arabic, scanned pages and phones without Apple Intelligence go to Gemini, with a second Gemini model when the first is busy. JSON question writing and multimodal PDF input use generativeModel with InlineDataPart; on iOS 27 the same Foundation Models LanguageModelSession API runs Gemini through ai.geminiLanguageModel(name:).
  3. Supporting Firebase products: App Check is enforced for AI Logic (debug tokens in the builds), and Remote Config holds the cloud model names and an on-device switch.
  4. No-Mac CI: both apps are built and checked on GitHub Actions (xcode-27 runner): Gradal's camera reader on synthetic sheets, Revisal's review rules and bundled banks, and workflows that record the real apps in the simulator calling Firebase live.

What we built during the submission period (existing apps, significantly updated)

Gradal (v2.7) and Revisal (v1.0) existed before the hackathon, with AI only through API keys the user pasted. During #BuildHybridAI we added to both:

  • The built-in hybrid AI through Firebase AI Logic: Apple Foundation Models on the device, Gemini in the cloud. No key needed.
  • App Check and Remote Config.
  • Complete English interfaces that follow the phone's language, and a Built-in AI section in Settings.
  • The demo-recording CI workflows, and this combined repository presenting both apps as one project.

Core value of the existing apps

A free, phone-only classroom cycle: the teacher writes, prints and grades quizzes from the textbook; the student reviews the same material and practices for the national exams. The hybrid AI removes the biggest barrier for both: nobody has to create and paste an API key.

Challenges we ran into

  • Arabic is not yet supported by the on-device model. Language detection routes Arabic to Gemini, while short English requests stay on the device.
  • The on-device context is 4,096 tokens, so whole chapters go to the cloud.
  • Two full apps, one engine: we kept them as two apps so neither user carries the other's weight, and shared the AI engine between them.
  • No Mac: everything is built, tested and recorded on GitHub Actions.

Accomplishments that we're proud of

  • Both sides of the classroom served for free, on one phone each.
  • Zero AI setup for teachers and students.
  • One engine that chooses between on-device and cloud by language, length and modality, and says which one answered.

What we learned

Hybrid AI is a routing problem. Making the routing explicit (language, size, modality) gives predictable privacy and cost, and keeps a fallback for every case.

What's next for Revisal & Gradal

  • Sharing a Gradal quiz with the class so students review it in Revisal.
  • Structured output and question tuning on the device.
  • Arabic on the device when Apple's model supports it.

Built With

  • apple-foundation-models
  • firebase
  • firebase-ai-logic
  • firebase-app-check
  • firebase-remote-config
  • gemini
  • github-actions
  • pdfkit
  • swift
  • swiftui
  • vision
Share this project:

Updates

Submission history