Index: openacs-4/packages/proctoring-support/tcl/proctoring-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/proctoring-support/tcl/Attic/proctoring-procs.tcl,v diff -u -N -r1.1.2.8 -r1.1.2.9 --- openacs-4/packages/proctoring-support/tcl/proctoring-procs.tcl 16 Mar 2021 17:11:22 -0000 1.1.2.8 +++ openacs-4/packages/proctoring-support/tcl/proctoring-procs.tcl 6 Apr 2021 14:10:55 -0000 1.1.2.9 @@ -180,3 +180,36 @@ and (end_time is null or end_time >= cast(current_timestamp as time)) }] } + +ad_proc -private ::proctoring::picture_already_received_p { + -object_id:required + -user_id:required + -file:required +} { + Returns if the picture is the same the users sent the last time + they uploaded a proctoring file. + + @param object_id id of the proctored object + @param user_id id of the proctored user + @param file an absolute path to a file in the filesystem + + @return boolean +} { + set cache_name proctoring_checksums_cache + + # Make sure the checksum of current file is not the same as the + # one we have in the cache. + set checksum [ns_md file -digest sha1 $file] + set already_received_p false + if {[ns_cache_get $cache_name ${object_id}_${user_id} cached_checksum]} { + if {$checksum eq $cached_checksum} { + set already_received_p true + } + } + + # Update in any case the cache to renew the expiration + ns_cache_eval -force -- $cache_name ${object_id}_${user_id} set v $checksum + + return $already_received_p +} +