Index: openacs-4/packages/proctoring-support/lib/proctoring-upload.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/proctoring-support/lib/proctoring-upload.tcl,v diff -u -r1.1.2.5 -r1.1.2.6 --- openacs-4/packages/proctoring-support/lib/proctoring-upload.tcl 6 Apr 2021 14:10:55 -0000 1.1.2.5 +++ openacs-4/packages/proctoring-support/lib/proctoring-upload.tcl 8 Apr 2021 11:26:36 -0000 1.1.2.6 @@ -54,9 +54,9 @@ } # A client-side timeout might still end up being processed by the -# server. Here we make sure we do not process pictures twice for a +# server. Here we make sure we do not process files twice for a # specific user. -if {[::proctoring::picture_already_received_p \ +if {[::proctoring::file_already_received_p \ -object_id $object_id \ -user_id $user_id \ -file ${file.tmpfile}]} { Index: openacs-4/packages/proctoring-support/tcl/proctoring-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/proctoring-support/tcl/proctoring-procs.tcl,v diff -u -r1.1.2.9 -r1.1.2.10 --- openacs-4/packages/proctoring-support/tcl/proctoring-procs.tcl 6 Apr 2021 14:10:55 -0000 1.1.2.9 +++ openacs-4/packages/proctoring-support/tcl/proctoring-procs.tcl 8 Apr 2021 11:26:36 -0000 1.1.2.10 @@ -181,12 +181,12 @@ }] } -ad_proc -private ::proctoring::picture_already_received_p { +ad_proc ::proctoring::file_already_received_p { -object_id:required -user_id:required -file:required } { - Returns if the picture is the same the users sent the last time + Returns if the file is the same the users sent the last time they uploaded a proctoring file. @param object_id id of the proctored object Index: openacs-4/packages/proctoring-support/tcl/test/proctoring-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/proctoring-support/tcl/test/proctoring-test-procs.tcl,v diff -u -r1.1.2.9 -r1.1.2.10 --- openacs-4/packages/proctoring-support/tcl/test/proctoring-test-procs.tcl 16 Mar 2021 17:12:44 -0000 1.1.2.9 +++ openacs-4/packages/proctoring-support/tcl/test/proctoring-test-procs.tcl 8 Apr 2021 11:26:36 -0000 1.1.2.10 @@ -144,6 +144,63 @@ } } +aa_register_case \ + -cats {api smoke} \ + -procs { + ::proctoring::file_already_received_p + } \ + proctoring_file_already_received_test { + Test that the server side check for duplicated uploads works + as expected. + } { + set user1 1 + set object1 1 + set file1 [ad_tmpnam] + set wfd [open $file1 w] + puts $wfd abcd + close $wfd + + set user2 2 + set object2 2 + set file2 [ad_tmpnam] + set wfd [open $file2 w] + puts $wfd efgh + close $wfd + + try { + for {set o 1} {$o <= 2} {incr o} { + for {set u 1} {$u <= 2} {incr u} { + set user [set user${u}] + set object [set object${o}] + aa_false "'$file1' for user '$user' and object '$object' IS NOT duplicated" \ + [::proctoring::file_already_received_p \ + -object_id $object \ + -user_id $user \ + -file $file1] + + aa_true "'$file1' for user '$user' and object '$object' IS duplicated" \ + [::proctoring::file_already_received_p \ + -object_id $object \ + -user_id $user \ + -file $file1] + + aa_false "'$file2' for user '$user' and object '$object' IS NOT duplicated" \ + [::proctoring::file_already_received_p \ + -object_id $object \ + -user_id $user \ + -file $file2] + + aa_false "'$file1' for user '$user' and object '$object' IS AGAIN NOT duplicated" \ + [::proctoring::file_already_received_p \ + -object_id $object \ + -user_id $user \ + -file $file1] + } + } + } finally { + file delete -- $file1 $file2 + } + } # Local variables: # mode: tcl # tcl-indent-level: 4