# Student Data Merger 1.5.0 — install one file

No add-on, deployment, separate HTML files, or manifest editing is needed for a standard new installation. Your organization must permit Apps Script.

## Install into an existing spreadsheet

1. Open your master spreadsheet and choose **Extensions → Apps Script**.
2. If Code.gs is empty except for the default `myFunction`, replace that default code with the entire contents of **StudentDataMerger.gs**. Otherwise, click **+ → Script**, name the new file **StudentDataMerger**, and paste the entire supplied file there. Do not replace unrelated code.
3. Check whether another file in the project already defines `function onOpen`. If it does, remove just this line from the newly pasted merger file:

   ```js
   function onOpen(e) { sdmOnOpen(); }
   ```

   Add this line inside the existing `onOpen` function, keeping its existing code:

   ```js
   sdmOnOpen();
   ```

   There should be only one `onOpen` function in the project. All other merger functions use an `sdm` prefix to reduce name conflicts.
4. Save, then reload the spreadsheet.
5. Choose **Student Data → Merge Data** or **Manage Backups**. Complete Google authorization if prompted and allowed by your organization.

If the project already uses an explicit OAuth scope list, retain its other permissions and ensure it includes `https://www.googleapis.com/auth/spreadsheets.currentonly` and `https://www.googleapis.com/auth/script.container.ui`. A default project detects the scopes automatically. The included `@OnlyCurrentDoc` annotation limits the merger's spreadsheet access to its current document; it does not remove permissions required by other scripts in the same project.

## Upgrade your current multi-file test installation

1. Save a copy of your existing script source locally before replacing it.
2. If Code.gs contains only this merger's previous code, replace all of it with **StudentDataMerger.gs**. If it contains unrelated scripts too, replace only the merger's old functions and follow the `onOpen` coexistence step above.
3. The old **Merger.html** and **Backups.html** files are no longer used. You may leave them in place or delete those two HTML files after confirming the new installation works.
4. Keep your current manifest. Save and reload the spreadsheet; close any dialogs opened by the older version.

Do not keep a second active copy of the old merger's Code.gs alongside the new package. No student tabs or data need to be moved or deleted for this upgrade.

## Future updates and transfer

Replace the contents of the same script file with the complete new release. If you integrated the menu into an existing `onOpen`, omit the supplied wrapper again. Only the script is transferred; rosters, backups, and incoming reports stay in their spreadsheet.

## Validation

The single-file package passes syntax and mocked regression checks for the same merge and backup behaviors as the multi-file sources. Dialog HTML and server calls are embedded with matching namespaced handlers. Installation, authorization, and visual appearance still require a Google Sheets trial with fictional data. No local browser testing was performed.
