Multiple iPads, Backing Up Code, Restoring Code

Hi,

so I have come across a need for the following and was hoping someone could give me some advice.

I have multiple iPads (let us say 10) which are used by 20 (or 30 or whatever number > 10) different people.

So people in group A use the iPads and Codea and create projects (1 or 2 or more).

I want to backup the work they have created, clear out Codea, and then restore group B’s work so that they may now use the iPads and create their projects etc.

Then I want to back up group B’s work, clear out Codea, etc.

Does anyone have any suggestions on how I might achieve this?

Regards,
DS.David

@fly.ing.fox - that’s an interesting problem, a school class I assume

Working this through…

You need to store the projects off the device because they won’t get the same iPads each time

They can be stored as a text file in a common Dropbox folder, but each iPad will need to be synchronized manually to update it, each time it is used, and there is the risk of students downloading and messing with each other’s work.

Codea projects can only be deleted manually off an iPad, which is a pain.

The best might be to use http to store and retrieve them from a central database, which could use an ID and password to validate identity, too. I don’t think that is too hard to set up, but if you don’t have this capability in your network it might not be practical.

It could be possible to write a special Codea project which can be added as an external reference to a user’s project. It would add the ability to back up automatically using a user ID and project name, and the ability to clean out the user’s work, leaving only a new project template of a few lines, ready for the next user. So the same project would be used for all students, with the special code loading in previous work, backing up current work, and erasing it at the end of a session, all within a single project. This would remove the need for most manual effort (in fact, all of the manual effort, if the projects are stored in a central database).

But others may have better ideas, or be better equipped to carry them through…

@Ignatz - I can guarantee the same iPad goes to the same user in a Group. Thus iPad #001 will got to student A001, B001, C001 etc.

Thus a solution that moves the code around “in situ” would be okay as long as I can hide the code from the other #001’s.

@fly.ing.fox - yes, but I helped a school briefly with Codea, and what struck me was that every week, a couple of iPads would be broken, so you can’t guarantee they will all work every time, so it’s better to be more flexible if possible.

@Ignatz - true, however if they break one of my iPads!!! No More Student!

So problem solved :slight_smile:

I got in contact with the Working Copy guys (since it works with Codea) and there is a work around using that lovely app.

I have yet to test out the workflow I have in mind, however it looks like it will work. The workflow is hampered by the Apple file system thing, however there is still a work around.

@yojimbo2000 may be able to help, he knows a lot about Working Copy

@Ignatz - I will be using the Codea code that @yojimbo2000 was testing/involved with.

@fly.ing.fox I have a small program, 56 lines, that might work for you. You key in a project name and then select save or restore. The Dropbox folder is used to save the project. I haven’t use this on the scale you would, so it needs testing. I don’t know how Working Copy works, so the choice is yours.

So here’s the steps you might take.

  1. Load my program on each of your iPads.
  2. Give an iPad to a student.
  3. The student creates a project using their last name + a number if needed or whatever projects name they want.
  4. The student writes/updates their code.
  5. The student hands you the iPad when they’re done.
  6. You run my program keying in the students project name and select save.
  7. The project and all it’s tabs are saved to the Dropbox folder.
  8. The students code is removed but their empty project name remains on the iPad.
  9. The next day, you run my program and key in the students project name and
    select restore.
  10. The students project and all the tabs are restored.
  11. Give the iPad to the student.
  12. Repeat starting with step 4.

The same student will have to get the same iPad because his project will only be on that iPad. A student will be able to see another students code only if the knows how to look for and read a Dropbox text file and he has the same iPad of the student he wants to see.

EDIT: The Dropbox folder could be syncd with the Dropbox apps folder.

@dave1707 - your solution sounds interesting … just a couple of questions

  1. when you mention “empty project” I am assuming that if a malicious student wanted to, they could delete that “empty project” and thus create issues with the restoring?
  2. your program is a LUA/CODEA script - thus I would have to install/delete it every time I wanted to use it to ensure that the students do not open that project and mess around.

Otherwise, sounds good.

Wow, iOS really needs to have multiple user accounts.

@yojimbo2000 - it would make life so much easier for a lot of things :slight_smile:

However it follows the concept of an iDevice per person.

I am just trying to save money by reusing devices.

One of my earliest ideas was to backup each device and restore each device from the previous weeks backup.

Which would work, but keep track of all those backups rather than keeping track of some code was going to be a nightmare.

It would be so much easier if Apple would allowing either pulling repositories out of Working Copy or allow Codea the full drag/drop directories it used to have.

@fly.ing.fox

  1. If a student deleted the empty project, all you would have to do is create a new project with that name. You wouldn’t even have to clear the default code created in that project before restoring the code.
  2. That’s true. They could get at that project.

I have questions about:

clear out Codea

Why? Is this so that students don’t copy one another’s code? Can’t you just trust them not to delete/ copy/ mess with the other group’s files? TBH, in this day and age where a solution is usually a google away, and the best software is open-sourced and stands on the shoulders of others, I don’t really see the point of trying to enforce conventional notions of plagiarism.

Do you mean deleting and reinstalling Codea? Or just deleting any projects that are inside it? If it’s the latter, then you can have persisting user data, which I guess all the solutions above depend upon.

I guess whatever workflow you arrive at needs to be simple enough for you to do it 10 times per lesson without it driving you nuts, but not so simple that the students can work out how to do it.

TBH if I was teaching a class of kids to code, I think I’d only use an online playground-type service like codepen.io . The cloud would completely remove the need for the workflow you’re describing here. iPads, which are completely designed to be personal, one-user devices, must be a pain to use in the classroom.

@yojimbo2000 - when working with children I have always found that, in general, they are great.

However there is always that one child that thinks that they know everything and they start “playing around” with things.

Thus if I left student code in an accessible format on the iPad, it is possible that it might get changed, even broken.

It is easier to have a workflow in place that ensures each child has a sandbox to themselves than to waste 10 minutes fixing something that another child may have caused.

In addition, the reason I want to use iPads and not the cloud is so this can be done with minimal resources, in a location that may or may not have internet access.

Both Codea and Working Copy have a “local” storage until they are synced to the cloud which handles this quite nicely.

Here’s a link to my socket-based method for transferring code to and from iPads, and can also work with a local computer as a central receiver/sender.

You need a local network, but if you have a mac you can set up a local “hotspot” for the iPads to connect to. Then the mac can download all the code from the iPads.

@fly.ing.fox

Ok, here’s the solution which I think will be simplest. Each student sets up a project, makes this a dependency. It’ll load and save to the Dropbox, keeping the files hidden from the asset picker, making them harder to discover/ delete. There’s a “save & clear” option which will return the project to a blank slate after each session.


--# DropboxBackup
-- Dropbox Backup
local dropboxPath = os.getenv("HOME").."/Documents/Dropbox.assets/"
local student_name = readProjectData("student_name", "Barbara Button")
local defaultProject = [[
-- Use this function to perform your initial setup
function setup()
    print("Hello World!")
end

-- This function gets called once every frame
function draw()
    -- This sets a dark background color 
    background(40, 40, 50)

    -- This sets the line thickness
    strokeWidth(5)

    -- Do your drawing here
end

function touched(touch)
    -- Check for touches here
end
]]

local function loadWorkspace()
    local data
    local path = dropboxPath..student_name..".lua"
    local file, err = io.open(path, "r")        
    if file then
        data=file:read("*all")
        file:close()
    else
        alert(err)
        return
    end
    data = data.."\
--# "
    for name, tab in data:gmatch"(%w-)\
(.-)\
%-%-# " do
        saveProjectTab(name, tab)
        print("Loading ", name)
    end
    local tabNames = listProjectTabs()
    for i,name in ipairs(tabNames) do
        load(readProjectTab(name))()
    end
    setup()
end

local function saveWorkspace()
    local tabCon = {}
    local tabNames = listProjectTabs()
    for i,name in ipairs(tabNames) do
        tabCon[#tabCon+1] = "--# "..name
        tabCon[#tabCon+1] = readProjectTab(name)
        print("Saving ", name)
    end
    local data = table.concat(tabCon, "\
")
    local file, err = io.open(dropboxPath..student_name..".lua", "w")
    if file then
        file:write(data)
        file:close()
    end
end

local function clearTabs()
    saveWorkspace()
    local tabNames = listProjectTabs()
    for i,name in ipairs(tabNames) do
        if name == "Main" then
            saveProjectTab(name, defaultProject)
        else
            saveProjectTab(name, nil)
        end
    end
end

local function saveStudentName(name)
    saveProjectData("student_name", name)
end

parameter.text("student_name", student_name, saveStudentName)

parameter.action("Load & Run", loadWorkspace)

parameter.action("Save", saveWorkspace)

parameter.action("Save & Clear", clearTabs)
--# Main
-- Dropbox Backup

parameter.clear()

print([[
INSTRUCTIONS
1. set this project as a dependency of projects you want to backup
2. run your code
3. enter your name in the box
4. press "save" to save the project to the Dropbox as NAME.lua, or "save & clear" to save and then wipe all tabs
5. because it has a .lua extension the file won't be visible in the asset picker, so should be harder to discover/ delete
6. press "load" to load NAME.lua into the tabs and run it
7. remember to sync dropbox in the asset picker if you want an offline backup
]])

The above code takes advantage of the fact that when you make code a dependency of something else, all of the storage functions (readProjectData, readProjectTabs etc) apply only to the host project, not the dependency code. Just to be clear, the code is only meant to be run as a dependency of the projects that you want to backup, restore etc.

@fly.ing.fox - I notice there’s no warning if a file with that name already exists, and the program doesn’t check that the project was saved correctly before wiping it. I can’t think why it wouldn’t save without throwing an error, but it’s just as well to guard against it.

You might, for example, save a second copy to the iPad disk using saveText, which can be retrieved if all else fails.

@yojimbo2000 Interesting code. One thing I noticed is anyone can run anyone else’s code. Just start Codea and run any project. The students name stays in the box.

EDIT: It’s also possible to save the default code instead of the real code.

@fly.ing.fox, you enjoy work with children? I am 13. Work with me maybe?