You suggested that ID be a unique identifier for a survey, well it is,
it just isn't the only unique identifier. As you have noticed, name is
also a unique identifier. This design allows people to reference
surveys by name, which I believe is preferable to numbers.
For example:
http://www.example.com/phpESP/public/survey.php?name=alpha
vs
http://www.example.com/phpESP/public/survey.php?sid=23561
(not that this is allowed anyway)
I would like for ID's to be only for internal use (they aren't at the
moment), and names to be the exported identifier. I don't really think
we can remove the UNIQUE constraint from the name field, it would break
too many things.
As for keeping deleted surveys ... This comes from the original design
for phpESP back before it became open source. The ability for someone
to delete an entire survey, with all the collected data, through one or
two clicks was to big a risk. It was decided that "deleted" surveys
would simply be marked as such, and removed from view. A (hidden) purge
page was later added to allow the deliberate destruction of a survey,
data included. You can access this feature with:
http://www.example.com/phpESP/admin/manage.php?where=purge
Hopefully purging the deleted surveys from your database will solve your
problem. If not, perhaps you could modify phpESP to prepend the user or
group name to survey names, which should decrease the number of conflicts.
-James
Paul R. Jackson wrote:
> Using latest CVS version.
>
> PROBLEM:
>
> I'm not really sure if other people will see this as a problem or rather as
> a feature! But here goes:
>
> If you create a survey of name say 'test' and then cancel it remains in the
> database with a status of 4 (i.e. DELETED).
>
> Now try to create a new survey with the same name 'test' it gives the error:
>
> [ Sorry, name already in use. Pick a new name. [ 1062: Duplicate
> entry 'test' for key 2 ] ]
>
> This is because when it checks the name it doesn't check status as well. See
> line 52 of 'survey_update.inc'. Although it would still fail anyway because
> the database requires a unique title.
>
> Likewise if you create another new survey give it another name and then try
> to change it to 'test' you get the following error:
>
> [ Sorry, that name is already in use. ]
>
> See line 83 in 'survey_update.inc' for source of problem.
>
> SOLUTION:
> The solution is not really a no brainer in this case. It raises some
> fundamental issues with the operation of the survey package. I am not sure
> if this has been discussed before but I personally think its pretty
> brain-dead to keep surveys which have been marked as deleted in the
> database. It just ends up cluttering the database with completed and half
> implemented surveys. I can see a case for wanting to keep them though and as
> such I would propose that they get moved to different tables, i.e. results
> and all if they exist. But this sort of thing would get very messy and be
> problematic to implement. I also don't really think having unique survey
> names is practical when you have many users (as I do). I believe the only
> way to uniquely identify the survey should be the id NOT the title.
>
> An easy solution is just to modify the database structure so that 'name' in
> the 'surveys' table is not required to be unique. Then any code that adds or
> updates surveys would do the unique checking itself taking into account the
> status of the survey. Likewise any code that expects a unique name would
> also have to take into account the status. This method would possibly break
> things all over the place, I haven't actually tried it. Additionally this
> still wouldn't allow 2 active surveys with the same name but I guess its
> arguable whether this is desirable.
>
> Or an easier solution is to just leave it as is.
>
> Paul
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Paul R. Jackson
> Experimental Programmer
>
> School of Psychology
> University of Queensland
> E:pa...@ps...
> P:3365-6713
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
|