Skip to content

CourseCopy

William Stein edited this page Oct 13, 2017 · 2 revisions

Copying Assignments to Students: what exactly happens?

When you assign an assignment to your students, it is copied from your project to your students' projects. Behind the scenes, this copy is done with the command

rsync -zaxs --update --backup [...] source/  dest/

There are two important options here:

--update: do not copy over a file if a NEWER file (by timestamp) 
          exists in the destination

and

--backup: if the source file `foo` (say) is NEWER than the destination file 
          `foo` (e.g., you edit your homework assignment after students have worked 
          on it),  then `dest/foo` is moved to `dest/foo~` and `foo` is copied 
          to the destination.

In particular, if the source files have an old timestamp and you've already assigned the assignment (and students may have worked on it), then nothing at all will happen on copy (due to the --update option). If a source file(s) has a newer timestamp that a file in the target directory, then the target file is copied to a backup and the source is copied over.

If you just want to add a new file to an assignment, you could ensure that all the other files are very old, e.g., by using the touch command. E.g.,

touch -d 'Jan 1' *

would make it so that everything appears to be from January 1.

Alternatively, you could just remove the files from the assignment folder, then move them back later. Assigning an assignment never deletes missing files in the target.

Some tests below illustrate how rsync works:

$ mkdir tmp2
~$ cd tmp2
~/tmp2$ mkdir a b
~/tmp2$ echo "0" > a/x
~/tmp2$ rsync -zaxs --update --backup a/ b/
~/tmp2$ ls a
x
~/tmp2$ ls b
x
~/tmp2$ rsync -zaxs --update --backup a/ b/
~/tmp2$ vi b/x
~/tmp2$ rsync -zaxs --update --backup a/ b/
~/tmp2$ ls -lht b
total 1.5K
-rw------- 1 user user 4 Oct 13 16:27 x
~/tmp2$ more b/x
0
1
~/tmp2$ touch a/x
~/tmp2$ rsync -zaxs --update --backup a/ b/
~/tmp2$ ls b
x  x~
~/tmp2$  

NOTE: We would like to add a new 3-way merge option, which would be more clever and instead of making a backup file of students modified work, would merge your changes into their file. This is not done yet.

Clone this wiki locally