Try this:
select product_id , string_agg(quiz_id::character varying, ',' order by lastmodified)
from quiz group by product_id;
String_agg function works with String values only ,You are getting the error because quiz_id is integer.
I have converted it to character varying and added group by for grouping the data product ID wise.
SQL Fiddle Example:http://sqlfiddle.com/#!15/9dafe/1