shivsharma07 / django-survey

Automatically exported from code.google.com/p/django-survey
0 stars 0 forks source link

Related field question type #41

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
For one survey we need to conduct, we need the user to be able to select
from a list of other registered users in the system (managers selecting
employees). Because we have more than 5000 registered users, we would also
need a way to limit the list of users on that picklist some kind of
queryset syntax. 

A question type that could pull rows from other models in the system would
be a realy nice enhancement. 

What version of the product are you using? On what operating system?
96

Original issue reported on code.google.com by scotfhac...@gmail.com on 12 Mar 2009 at 12:42

GoogleCodeExporter commented 8 years ago

Original comment by yann.ma...@gmail.com on 12 Mar 2009 at 2:50

GoogleCodeExporter commented 8 years ago
The attached patch creates a new question type: UserPicklist. It's useful when
teachers need to evaluate students, or for employers to evaluate employees, etc.
Entries in the list are displayed as Lastname, Firstname.

By default this question type will create a select box showing all registered 
users
in the system. However, that's not always appropriate - you may have 5,000 
registered
users but only want to show users who match some criteria (like students from a
particular school year or employees who have completed a workshop). So this 
question
type adds a new Custom Query field in the add/edit question view. Enter a 
dictionary
of the picklist criteria, e.g.:

{'is_staff':True,'last_name__startswith':'A',}

The dictionary will be stored in the db, then applied to the picklist when it's 
rendered.

If you apply this to an existing system you'll need a new field on the question 
table:

ALTER TABLE `survey_question` ADD COLUMN `custom_query` VARCHAR(255) CHARACTER 
SET
latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL  AFTER `choice_num_min`;

Original comment by scotfhac...@gmail.com on 19 Mar 2009 at 12:28

Attachments: