39 return 'Submission Integrity Test';
52 return 'A test to check the integrity of submissions';
66 public static function test(&$messages, &$errors)
70 $submission_assetids = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAssetIds(
'form_submission', TRUE);
71 foreach ($submission_assetids as $assetid) {
72 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
75 $attributes = $asset->attr(
'attributes');
76 $answers = array_get_index($attributes,
'answers', Array());
77 foreach ($answers as $id => $details) {
78 $valid_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($id,
'', TRUE);
79 if (is_null($valid_asset)) {
82 $errors[] =
'Submission #'.$assetid.
' has an answer to a question (#'.$id.
') that does not exist';
84 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($valid_asset, TRUE);
89 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset, TRUE);
92 if (!$status && !empty($count)) {
93 $messages[] =
'There are '.$count.
' submissions found with problems';