feat(assessment): keep real attempts in fullscreen and protect the task text
This commit is contained in:
1 parent
56dcf32f8c
commit
efa41d5967
46 files changed
+1940
-72
No files matched your search
@@ -12,9 +12,14 @@ import (
|
||||
)
|
||||
|
||||
// CurrentSignalNoticeVersion is the version of the notice text that lists the
|
||||
// collected assessment signals. Change it together with the client text so that
|
||||
// every candidate acknowledges the new wording.
|
||||
const CurrentSignalNoticeVersion int32 = 1
|
||||
// collected assessment signals and the measures the page applies during an
|
||||
// attempt (fullscreen, hiding the task when the candidate leaves, copy, print,
|
||||
// and paste restrictions). Change it together with the client text so that
|
||||
// every candidate acknowledges the new wording. Acknowledgements are stored per
|
||||
// version, so one given for an earlier version never counts for this one.
|
||||
//
|
||||
// Version 2 added the attempt measures to the text; version 1 listed signals only.
|
||||
const CurrentSignalNoticeVersion int32 = 2
|
||||
|
||||
// ErrSignalNoticeVersionMismatch reports an acknowledgement for a notice
|
||||
// version other than the one the server requires.
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package assessment
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func TestAcknowledgeSignalNoticeRefusesEveryVersionButTheCurrentOne(t *testing.T) {
|
||||
// A refused version returns before the service touches storage, so an
|
||||
// acknowledgement of an earlier notice text can never count for this one.
|
||||
service := &SignalService{}
|
||||
for _, version := range []int32{CurrentSignalNoticeVersion - 1, CurrentSignalNoticeVersion + 1} {
|
||||
_, err := service.AcknowledgeSignalNotice(context.Background(), uuid.New(), version)
|
||||
if !errors.Is(err, ErrSignalNoticeVersionMismatch) {
|
||||
t.Fatalf("AcknowledgeSignalNotice(version %d) error = %v, want %v", version, err, ErrSignalNoticeVersionMismatch)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user