adding an pre-filled field to survey

adding an pre-filled field to survey

by Cheryl Ayres -
Number of replies: 5

I want to include the teachers name to the excel spreadsheet export.  I've looked at various ways to do this an think this might be the best way to start.

Create a new item type that would be pre-filled with the resulting string from a query

SELECT mdl_user.firstname, mdl_user.lastname
FROM mdl_role_assignments, mdl_user, mdl_context, mdl_course
WHERE mdl_role_assignments.userid =  mdl_user.id AND mdl_role_assignments.roleid =  '4' AND mdl_role_assignments.contextid =  mdl_context.id AND mdl_context.instanceid =  mdl_course.id AND mdl_course.shortname =  $courseid

Does this sound correct?

Average of ratings: -
In reply to Cheryl Ayres

Re: adding an pre-filled field to survey

by Cheryl Ayres -
Sorry - forgot to add Moodle details  version 1.8.4
In reply to Cheryl Ayres

Re: adding an pre-filled field to survey

by Andreas Grabs -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Translators
Hi Cheryl,

I think it would be better to use the moodle-function "get_role_users()" defined in "lib/accesslib.php".
So you can create an item that supports the teacher-role and other roles too.

Andreas
In reply to Andreas Grabs

Re: adding an pre-filled field to survey

by Cheryl Ayres -
Thanks Andreas - I'll look that up!
In reply to Cheryl Ayres

Re: adding an pre-filled field to survey

by Cheryl Ayres -
OK - Im not getting anywhere - I must be on the wrong train of thought - Andreas - is there any documentation that shows how to use this ...
In reply to Cheryl Ayres

Re: adding an pre-filled field to survey

by Andreas Grabs -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Translators
Hi Cheryl,

there is no documentation at this time except the inline-comments.
You can copy an simple item like "textfield". Rename all words "textfield" to the new name.
On the function "check_value()"
you only return true.

On the function "create_value()"
you have to return the name of the teacher

In addition you have to eleminate all shown textboxes. Put a hidden field instead this.

I would say that's all.

Andreas