Skip to content

Commit

Permalink
Enabled unique and valid question code enforcement for updates and im…
Browse files Browse the repository at this point in the history
…port.
  • Loading branch information
SamMousa committed Nov 29, 2013
1 parent de20493 commit 4ded98e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion application/helpers/admin/import_helper.php
Expand Up @@ -3682,7 +3682,7 @@ function XMLImportSurvey($sFullFilepath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDe
}
if ($insertdata)
XSSFilterArray($insertdata);
$question = new Question();
$question = new Question('import');
$question->setAttributes($insertdata, false);
$attempts = 0;
while (!$question->validate(array('title')))
Expand Down
2 changes: 1 addition & 1 deletion application/models/Question.php
Expand Up @@ -94,7 +94,7 @@ public function rules()
)
),
'message' => 'Question codes must be unique.'),
//array('title', 'match', 'pattern' => '/[a-z,A-Z][[:alnum:]]+/', 'message' => 'Question codes must start with a letter and may only contain alphanumeric characters.'),
array('title', 'match', 'pattern' => '/[a-z,A-Z][[:alnum:]]+/', 'message' => 'Question codes must start with a letter and may only contain alphanumeric characters.', 'on' => 'update, import'),
array('other', 'in','range'=>array('Y','N'), 'allowEmpty'=>true),
array('mandatory', 'in','range'=>array('Y','N'), 'allowEmpty'=>true),
array('question_order','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
Expand Down

2 comments on commit 4ded98e

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wee need better error system in database now because we have error and 2 message : last one with success.

AND
Able to create bad question code.
This don't have to be 'on' => 'update, insert' ?

Edit: fix the double message (only THIS one):
49ac245

Edit2:
TODO : add pattern in HTML

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need accept _ (underscore) too

[a-zA-Z][[:alnum:]_]+

Please sign in to comment.