JR&CO
Safety Inspection Admin — Help
Admin Guide

Overview

The Safety Inspection Admin controls inspection templates, questions, schedules, and field deployment for Weekly Safety, QC layers, surveys, and closeout checklists. Changes take effect immediately — the mobile form always fetches the latest question configuration from the database.

Five Admin Tabs

Questions — add, edit, reorder, and deactivate inspection questions.

Branch Tree — visual map of all conditional parent–child relationships.

Score Legend — view which questions contribute to each scoring category and their weights.

Submissions — browse, inspect, and delete completed inspection records.

Schedule — configure inspection cadence, crew requirements, and per-job overrides.

🔒
Access & Roles

This admin page uses the Supabase service-role key embedded in the HTML — it is not public-facing. Only share the URL with safety managers and system administrators.

Field crews never access this page. They use the mobile inspection form at safety-inspection.html. Each crew member chooses how questions are displayed on their own phone — scroll through all questions or step through one at a time (see Field Form).


Creating a New Template

Use + New Template in the admin top bar to create a brand-new inspection type (not just add questions to an existing one). The AI wizard defines the template registry row, questions, schedule, and optional field deploy in one flow.

+ New Template vs Import with AI
ActionWhen to use
+ New Template You need a new slug and template in the registry (e.g. a one-off warranty punch list, a new QC checklist type).
Import with AI You already selected a template in the dropdown and want to add or replace questions on that template only.
Wizard steps
  1. 1Define template — enter slug, display title, layer, optional description, and paste your checklist.
  2. 2Clarify — answer AI setup questions (frequency, scoring, deploy mode, federal flag if applicable).
  3. 3Review & create — confirm questions, schedule, score categories, then Create & deploy.

Slug & layer rules

FieldRules
Template slugLowercase letters, numbers, underscores; 3–48 chars; must start with a letter. Immutable after creation (e.g. tpo_warranty_qc).
Layersafety, qc_layer1 (Federal), qc_layer2 (Daily), qc_layer3 (Closeout), or custom.
Statustesting = admin preview only, not on mobile. active = crews see it when schedule says due.
Federal templates (Layer 1): Jobs must also have federal_job = true in tbl_job_inspection_flags for the inspection to appear on mobile. The deploy panel can set this when you enter job IDs.
Import with AI on a selected template does not create a new slug — it only updates questions on the template currently in the dropdown.

Managing Questions

Questions are stored in tbl_safety_question_config. Every active question is fetched fresh each time a field user opens the inspection form, so changes apply to the next submission immediately.

+
Adding a Question
  1. 1Click + Add Question in the top-right corner.
  2. 2Fill in Question ID (unique key, e.g. PPE_05), Question Text, and Field Key (auto-filled from Question ID if left blank).
  3. 3Choose the Section — Intake, Gate, Core, or Conditional.
  4. 4Set the Answer Type. Yes / No / N/A / Not Sure is the most common; use Text for open-ended fields and Multi-select for checklists.
  5. 5Set Display Order to control where the question appears in the form (lower = earlier).
  6. 6Configure Photo, Scoring, and Conditional settings as needed (see sections below).
  7. 7Click Save Question.
Editing & Reordering

Click the Edit button on any row to open the edit drawer. All fields are editable including the question text, answer type, and scoring weight.

To change display order, edit the Order number in the drawer, or use the ⇧ ⇩ arrow buttons on the question row to move it up or down one position. Reordering updates display_order for all affected questions in a single batch.

Deactivating vs. Deleting

Toggling a question inactive hides it from the mobile form without removing it from the database. Past submissions that answered the question are preserved and still visible in the Submissions tab.

There is no delete button by design — deactivate instead of deleting to preserve historical data integrity.

Sections explained: Intake = basic job setup questions shown first. Gate = site access / pre-entry checks. Core = primary safety observations. Conditional = follow-up questions shown only when a parent question triggers them.

Answer Types

TypeWhen to UseScorable?
yes_no_na_notsureStandard safety questions where an observer may be uncertainYes
yes_no_naCompliance checks with a clear pass/fail (no uncertainty option)Yes
pass_fail_naQC / closeout items (PASS / FAIL / N/A on mobile)Yes
number1–5 satisfaction or survey ratings (e.g. GC Check In). Pass values default to 4 and 5.Yes
textFree-form notes, descriptions, names, task identificationNo
multiselectChecklists where multiple answers apply simultaneouslyNo

Scoring System

The inspection generates a percentage score per category and an overall score. Scores are computed server-side when the inspection is submitted and stored permanently in the record.

How Scoring Works

Each scorable question has a Score Weight (points) and a Score Category. When a question is answered, its weight is added to the category’s possible total. If the answer is a pass value (yes or na), the weight is also added to earned points.

Category score = earned ÷ possible × 100. Overall score is the same calculation across all categories combined.

Conditional questions that are never shown (parent answer did not trigger them) are excluded from scoring entirely.

Score Categories

Category KeyDisplay NameTypical Questions
ppe_sitePPE & Site SafetyHard hat, vest, eye protection, housekeeping
fall_protectionFall ProtectionHarness, guardrails, ladder safety
hot_workHot WorkFire extinguisher, permits, combustible clearance
overhead_toolsOverhead / ToolsOverhead hazards, tool tethering, barricades
trafficTraffic & AccessTraffic control, flagging, equipment proximity
Score thresholds (configurable in Schedule tab):
Below 80 → Elevated cadence (2-day re-inspection required until score recovers).
80–89 → Acceptable, standard 7-day cadence resumes.
90+ → Full recovery, standard cadence confirmed.
Configuring Score Weight on a Question
  1. 1Open the edit drawer for the question.
  2. 2Scroll to Scoring. Set Score Category to the relevant category (or leave blank to exclude from scoring).
  3. 3Set Score Weight (1–10). Higher weight = more impact on the category score. Most questions use 1–3; critical items (e.g. fall protection) may use 5–10.
  4. 4Pass Values default to ["yes","na"] for yes/no types, ["pass","na"] for pass/fail, and ["4","5"] for number ratings. Only change when you need custom pass logic.

Photo Configuration

Any question can optionally require or allow a photo. Photos are uploaded to the job-log-photos Supabase storage bucket and linked to the inspection record by UUID.

FieldDefaultBehaviour
photo_enabledOffShows a camera button beneath the question on the mobile form. If off, no photo option appears.
photo_requiredOffBlocks form submission if no photo is attached to this question. Only meaningful when photo_enabled is also on.
photo_promptEmptyHelper text shown above the camera button (e.g. “Photograph the first-aid kit location”). Optional.
Photos are stored as private objects. The Submissions tab generates 1-hour signed URLs when displaying thumbnails. Direct links are not publicly accessible.

Conditional Logic

Conditional questions are hidden until a specified parent question is answered with a trigger value. This keeps the form concise while enabling drill-down on problem areas.

Setting Up a Conditional Question
  1. 1Create or edit the child question (the one that should be hidden by default).
  2. 2Set Section to conditional.
  3. 3In Parent Question, select the question whose answer controls visibility.
  4. 4In Trigger Values, enter a JSON array of answer values that will show this question — e.g. ["no","not_sure"].
  5. 5Save. The Branch Tree tab will show the new relationship immediately.
Trigger value format: Must be valid JSON array syntax using the answer key values: "yes", "no", "na", "not_sure". Example: ["no","not_sure"]. Do not use display labels like “Yes” or “No”.
🌳
Branch Tree Tab

The Branch Tree tab renders the full parent–child hierarchy. Each parent question is shown with its trigger values and an indented list of the child questions it controls. Useful for auditing logic before adding new conditional questions.

Questions with no parent (top-level) are not shown in the tree — only conditional relationships appear.


Inspection Schedule

The Schedule tab controls when inspections are due, how the system responds to failing scores, and whether crew presence is required before prompting a field user.

📅
Schedule Configuration (Global & Per-Job)

The global row (Job ID = All jobs) applies to every job unless a per-job override exists. Override rows take full precedence for that specific job.

SettingDefaultMeaning
interval_days7Days between inspections when score is acceptable (80+). The next due date is set to submission date + interval on every submit.
elevated_interval_days2Days between inspections when the last score was below the deficiency threshold. A 2-day cadence continues until the score recovers.
deficiency_threshold80Score strictly below this value triggers elevated cadence on next requeue.
recovery_threshold90Score at or above this confirms full recovery; mode returns to standard.
require_active_crewWhen enabled, the inspection button is only shown on the mobile app if Buildertrend timecards show crew activity on the job within the last 7 days. Disabling always shows the button regardless of crew data.
Adding a per-job override: Use the form at the bottom of the Schedule Configuration card. Enter the Job ID (e.g. AR25-020) and adjust any thresholds, then click Add Override. Remove an override to revert to global settings.
📈
Active Job Schedules

The lower section shows a live row for every job that has submitted at least one inspection. Each row displays the job’s next due date, current mode, last score, and whether Buildertrend reports active crew.

Use the Reset Due Date date picker and Set button to manually override the next due date for a job — useful for rescheduling after a site shutdown or holiday.

Schedule Modes

ModeTriggerNext Due
standardScore ≥ 80 on last submission (or default)Submission date + interval (7 days)
elevatedScore < deficiency threshold (< 80)Submission date + elevated interval (2 days)
snoozedUser tapped “Snooze 1 day” on mobileOriginal due date + 1 day
Nightly sweep: A scheduled function (safety-schedule-sweep) runs at 06:00 UTC every day. It refreshes the Crew Active flag for all jobs from Buildertrend timecard data, and automatically restores snoozed rows back to their previous mode once the snoozed date has passed.

Deploy to Field & Suppress Templates

The Deploy to Field panel on the Schedule tab controls whether crews see a template on mobile. Schedule configuration (intervals, thresholds) does not deploy by itself — deployment is a separate step.

Template statusMobile behavior
activeEligible to appear when a per-job schedule row exists and the checklist is due or has a today draft.
testingHidden from Field / Forms Job Checklists. Admin can still open via direct link.

Deploy (turn on for jobs)

  1. 1Select the template from the header dropdown (each federal phase is a separate template).
  2. 2Open Schedule → check Activate template.
  3. 3Enter Job IDs (comma-separated) and First due date.
  4. 4For Layer 1 federal templates, leave Mark jobs federal checked.
  5. 5Click Deploy to jobs.

Suppress (turn off for mobile)

Per-template: Setting Preparatory to testing does not hide Follow-up or Initial. Each federal phase must be suppressed separately.
GoalAction
Hide template everywhereUncheck Activate template, leave Job IDs empty, click Deploy to jobs → status returns to testing.
Hide for one job onlyActive Job SchedulesDelete that job’s row.
Stop federal QC on a non-federal jobDelete schedule row and/or clear federal_job on that job (do not mark federal on deploy).
Remove a stuck draft bannerSubmissions tab → delete the incomplete submission for that job/date.

Auto-queue (no manual deploy)

Field guide: Closeout QC & Job Checklists Help


Inspection Dashboard

safety-inspection-dashboard.html aggregates submissions across jobs. Use the template filter to switch between Weekly Safety, QC layers, surveys, and closeout templates.

📊
KPI labels

The first KPI chip label changes by template filter:

  • Surveys — GC Check In and similar survey-style templates
  • Inspections — Weekly Safety and QC templates
  • Submissions — when viewing All Templates
Failure heatmap

Pass/fail coloring uses each question’s score_pass_values from question config:

Answer typePass values (default)
yes_no_*yes, na
pass_fail_napass, na
number (1–5 surveys)4, 5

A rating of 5 on a satisfaction survey should show Pass (green), not fail.


Submissions

The Submissions tab lists every inspection record in tbl_safety_inspections, sorted by date descending. Use it to audit completed inspections, review answers, and delete test records.

🔍
Viewing Q&A Detail

Click the Job ID link (blue, underlined) on any submission row to expand a full Q&A panel beneath it. Questions are grouped by section. Answers are colour-coded: Yes / N/A = pass, No = fail (row highlighted red), Not Sure = caution.

Photo thumbnails load at the bottom of the panel. Click any thumbnail to open the full-size image in a new tab. Signed URLs expire after 1 hour.

Click the Job ID again to collapse the panel.

🗑
Deleting a Submission (Reset for Re-test)

The Delete button on a submission row permanently removes that record from the database. After deletion, the field user can re-submit a fresh inspection for the same job and date.

This is the correct way to reset a test submission or allow a crew member to redo an inspection that was submitted in error.

Deletion is permanent. The associated photo files in storage are not automatically removed. Delete storage objects separately via the Supabase Dashboard if needed.
Filtering

Use the toolbar at the top of the Submissions tab to filter by Job ID (partial match), Submitted By email (partial match), or exact Date. Filters apply client-side to the loaded batch of up to 200 records. Click Refresh to reload from the database.


Mobile Inspection Form

The field form at safety-inspection.html is used for Weekly Safety and other inspection templates (Federal, Daily, Closeout). Admins configure questions and schedules; field users complete inspections on their phones.

📱
How to view questions (per user)

Below the progress bar, each user sees a How to view toggle. This is a personal preference — admins do not force one layout for everyone.

ModeBest forBehavior
All questions Long checklists, jumping around, reviewing earlier answers Classic scroll: every visible question on one page. Section headers group related items.
One at a time Focused walk-throughs, shorter surveys, less scrolling on small screens Carousel: one question card at a time with Back and Next. Tapping YES/NO/PASS/FAIL or a 1–5 rating advances automatically when the question is complete (including required photos).

The choice is saved in the browser (localStorage key jrco-inspection-display-mode) and applies to every inspection on that device until the user changes it. Users can switch modes at any time during a draft — answers are preserved.

Conditional questions & validation

Follow-up questions appear when a parent answer triggers them, in both view modes. In carousel mode, the step counter updates when new questions become visible.

Next is blocked until the current question is answered. If a photo is required, the user must attach one before advancing. Review Score still validates the full form and jumps to the first incomplete item.

?
Answer types on mobile
Config typeField UI
yes_no_na / yes_no_na_notsureYES / NO / N/A (and NOT SURE)
pass_fail_naPASS / FAIL / N/A
number1–5 rating buttons (surveys, satisfaction)
textFree-text area
multiselectChip toggles

Question IDs are not shown to field users. Validation messages use question text only.

Direct link: Open any scheduled inspection with safety-inspection.html?jobId=JOB-ID&template=TEMPLATE_SLUG&date=YYYY-MM-DD. Template slug examples: weekly_safety, qc_layer1_followup.

Field Reference

Database Tables

TablePurpose
tbl_safety_question_configQuestion definitions: text, section, answer type, photo settings, scoring, conditional parent links.
tbl_safety_inspectionsSubmitted inspection records: answers (JSONB), scores (JSONB), photo UUIDs, completion flag.
tbl_safety_schedule_configGlobal and per-job schedule thresholds: interval days, deficiency/recovery score limits, crew requirement.
tbl_safety_inspection_scheduleLive schedule state per job: next due date, mode (standard/elevated/snoozed), last score, crew active flag.
tbl_job_log_photosPhoto metadata: storage path, original filename, caption, job ID, log date, uploader email.

Edge Functions

FunctionActions
field-safety-inspectionget_questions, get_inspection, get_schedule, snooze_inspection, submit_inspection
safety-schedule-sweepPOST (no action param) — refreshes crew_active from BT timecards, restores expired snooze modes. Runs nightly via pg_cron.
mobile-upload-job-photoMultipart POST: uploads image to job-log-photos bucket, inserts metadata row, returns signed URL.

Mobile App States (Field Tab Button)

The inspection button on the Field tab is only shown when action is required. It is hidden in all other states to avoid clutter. The Daily Log card on the Project tab always shows the full status regardless.

Weekly Safety (red banner)

StateField Tab ButtonDaily Log CardSnooze?
Due todayVisible — red, “Inspection due today”Due todayYes
Elevated, dueVisible — red, ⚠ “Re-inspection due — score below 80”Re-inspection dueYes
Draft in progressVisible — red, “Draft in progress — tap to continue”Draft savedNo
CompleteHiddenScore% — Complete ✓No
Not due yetHiddenNext due [date]No
SnoozedHiddenSnoozed — due [date]No
No crew activeHiddenNo crew active / Next due [date]No

Job Checklists (blue banners — QC, closeout, surveys)

Same list appears on Field tab and Forms → Job Checklists. Hidden when complete until due again; only today’s in-progress draft counts (not yesterday’s submission).

StateBlue banner
Due todayVisible
Draft todayVisible — “Draft in progress”
Complete, not dueHidden
Template testingHidden
Federal template, job not marked federalHidden (template_blocked)
Why is the button hidden? The button only appears when there is something to act on — due today, draft in progress, or elevated re-inspection required. This keeps the Field tab uncluttered on non-inspection days. The full status is always visible on the Daily Log card in the Project tab.

Forms Tab vs Field Tab

The mobile app has two surfaces for field paperwork. They use different data models and must not be mixed in admin.

SurfaceWhat appearsExamples
Field tabMandated, scored inspections (red = Weekly Safety; blue = QC / closeout / surveys)Weekly Safety, Daily QC, GC Check In, Closeout Final QC
Forms tab → Job ChecklistsSame mandated checklists as Field tab, shown as blue banner tiles when due (mirror for discoverability)Closeout Pre-Final Walk, Closeout Final QC + Warranty
Forms tab → Submit a FormVoluntary safety forms (creates safety queue cases)Incident Report, Safety Violation, Good Catch

Closeout QC (Layer 3) Auto-Offer

Closeout templates (qc_layer3_prefinal, qc_layer3_final) are offered automatically when a job’s % Complete ≥ 95 (from CRM variance). No manual “Deploy to Field” is required for each closeout job, though admin deploy remains a valid override.

Field user guide: Closeout QC & Job Checklists Help