This is probably a longshot, but I'm a teacher working with students on Engineering Design notebooks. One of the main goals/requirements is that each page has a date, and that date shouldn't be editable by students.
I've been looking for scripts that allow me to automate the date in Google Slides, which is where we are building our notebook template.
There are quite a few scripts for updating a date whenever you open a presentation.
does anyone know how to add a script that would update the current date in a text field, only when a new slide is created? EX: Student opens their digital google slides notebook, then they click CTRL+M or right click > New Slide. When the new slide pops up, it autopopulates the date field with the current date, and cannot be edited by the student.
Thanks for any help in pointing me in the right direction.
Yes, you can create a non-editable textbox and later fill it with a timestamp using a script.
The solution below may not meet your whole question, maybe just the first goal, but the idea can be converted into a better script.
A textbox cannot be edited in the slide view if it is placed in a layout in the master view.
To give you the idea, we are going to create a "non-editable" textbox in the main slide layout as an example:
https://docs.google.com/presentation/d/{your slide id}/edit
. Use{your slide id}
to define the constantSLIDE_ID
in your script.View > Master
Date
. We use the text to find the textbox object id with the following Script 1 first. In the image below, it is the red textbox with theDate
text.Script 1:
Run > Debug > openSlide
. After a few seconds from your script editor, go toView > Logs
to see the output for "MATCH". For example, the object id isga66cd6addf_0_17
Output:
openSlide()
function in Script 1 as follows:Modified Script 1:
Run > Debug > openSlide
. After a few seconds, we can see theDate
in the textbox has been changed to a proper timestamp in our Google Slides document as follows:Now, we can use the modified
openSlide()
function as a time-driven trigger (if the script scope is in the Google Slides document) or as an event trigger (if the script scope is in Google Form or Google Sheet) to keep updating the text. The timestamp textbox cannot be modified when we are not in the master view.It is not necessary to create a new slide using a script, but you can refer to https://developers.google.com/slides/how-tos/create-slide.
The important thing is to make sure to edit every layout in the "Layouts" list in the Master view with the above idea. Every time the student creates a new slide from the Google Slides document, the new slide will automatically retrieve the assigned slide layout (most likely it is the third Layout in the Master view) that you have included in the timestamp textbox.
Next idea: the above steps can be turned into a whole script if you want to but I will not cover how it can be done here.
Caveat: Since every new slide uses the assigned default slide layout, we are going to see the same timestamp value for all newly created slides. Maybe it is better to run a script that is executed from a Google Form's
onSubmit()
scope trigger where the student submits his/her attendance for every session, for example. Once submitted, the script will duplicate a Google Slides document for the student from the master/template Google Slides document that has included the "Date" textbox in the layout and timestamps the "Date" textbox in the duplicated document (like the concept of mailmerge/document bookmarks in the Microsoft Word). The script will only act upon the duplicate but not the master/template. The link to this duplicated Google Slides document can be provided from a response email or from a Web redirect. You can include the student's name in this duplicate document as well! So, every student will have his/her own Google Slides document with a different current timestamp each time it is created.See the merge concept in https://developers.google.com/slides/how-tos/merge
Note: we still cannot avoid the students from modifying the layouts in the Master view when we give them the edit permission.