SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Quiz . Survey, other templates?

    Hey,

    Much as I wish I had hours to teach myself more programming, I fear the best I can do is hope to configure someone elses work without screwing it up toooo much. (Allyson Abromowitcz, my CS101 TA would be appalled!)

    So, I'm looking for code I can use: perhaps like Phorm (phorm.com) or just templates.

    Today's project is a 7 question, multiple choice quiz for teens. The best I know how to do is have each result emailed to me; a database to collect statistics seems a better approach.

    Ideas? Thanks!!!

    ed

  2. #2
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you using Rails?

    Create these models:

    question: has_many :answers
    answer: belongs_to :user, :question
    user: has_many :answers

    I think it's really easy to do. I could help you if you give a little more information: are the users logged in, or anonymous. Are all questions on one page? Should there be an admin panel where you can add questions? Etc.

  3. #3
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Fenrir2
    Are you using Rails? ...I think it's really easy to do.
    Yes, easy for the non-dense!

    I have Rails all installed and had made it partway through the tutorials. It looks really cool.

    The idea is to make this one anonymous - it captures teen attitudes on sex. But, registering the i.p. would also help us to identify any tampering from repeats.

    Thanks!!

    e

  4. #4
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could use this migration to start with:

    Code:
    class Init < ActiveRecord::Migration
      def self.up
        create_table :questions do |t|
          t.column :text, :string
        end
        
        create_table :choices do |t|
          t.column :question_id, :integer
          t.column :text, :string
        end
        
        create_table :answers do |t|
          t.column :user_id, :integer
          t.column :choice_id, :integer
        end
        
        create_table :users do |t|
          t.column :ip, :string
        end
      end
    
      def self.down
        drop_table :questions
        drop_table :choices
        drop_table :answers
        drop_table :users
      end
    end

  5. #5
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks again!

    Well, I must first admit that I have to look up what a migration is and what to do with it... So I've printed a couple cheat sheets.

    But this looks like exactly the sort of thing that will help create something much better than an HTML form!

    But first, another fire calls...

    e


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •