www.webdeveloper.com
Results 1 to 4 of 4

Thread: Creating a random story based on input

  1. #1
    Join Date
    Aug 2006
    Posts
    3

    Creating a random story based on input

    Hello all,

    I am a school teacher in Ontario, Canada. This year, I am helping quite a number of students at my school who are having trouble with reading. I would like to create a random paragraph generator based on their reading level and I thought I'd check here to see if it is even possible.

    My idea is to have 6 categories that correspond to the reading skills being addressed. For each category, there would be 4 sets of sentences available, each set corresponding to the reading level.

    For example, if Billy is at a level 2 in decoding digraphs, level 1 at decoding short vowel sounds, etc. I would put these levels in the corresponding boxes and click 'Submit'. The generator would then use the scores to look at the lists under each of the six categories (digraphs, short vowels, etc.) and randomly select a sentence from the corresponding levels. It would then return a paragraph including all six sentences.

    It would be even better if there was a way to personalize the sentences with the kids names and pronouns . . . (doesn't hurt to ask ;-)

    Any input would be greatly appreciated. Thanks!

  2. #2
    Join Date
    Feb 2012
    Location
    Tallahassee, FL
    Posts
    280
    Yes, it is possible...but I would use more then just Javascript. Look into some server site scripting. I can help you with more detail if you would like, just PM me.

  3. #3
    Join Date
    Aug 2006
    Posts
    3
    I am not quite sure how to PM you . . . I tried creating a new message but I get some sort of error stating it cannot display the page. Can you PM me? Maybe I'll be able to reply to your message.

  4. #4
    Join Date
    Jun 2004
    Location
    Portsmouth UK
    Posts
    2,674
    in principle

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    </head>
    
    <body>
     <div id="catagory1" >
      catagory 1<br />
      <select onchange="zxcRandomSentence.Select('catagory1',this.value);">
       <option >Select Level</option>
       <option value="0" >Level 1</option>
       <option value="1" >Level 2</option>
       <option value="2" >Level 3</option>
      </select>
      <div></div>
     </div>
     <div id="catagory2" >
      catagory 2<br />
      <input type="radio" name="c2" value="0" onclick="zxcRandomSentence.Select('catagory2',this.value);"/>
      <input type="radio" name="c2" value="1" onclick="zxcRandomSentence.Select('catagory2',this.value);"/>
      <input type="radio" name="c2" value="2" onclick="zxcRandomSentence.Select('catagory2',this.value);"/>
      <div></div>
     </div>
    
    <script type="text/javascript">
    /*<![CDATA[*/
    
    var zxcRandomSentence={
    
     Select:function(id,n){
      var o=this['zxc'+id];
      if (o&&o.a[n]){
       o.d.innerHTML=o.a[n][Math.floor(Math.random()*o.a[n].length)]
      }
     },
    
     init:function(o){
      var id=o.ParentID,a=o.SentenceArray,p=document.getElementById(id),d=p?p.getElementsByTagName('DIV')[0]:null;
      if (d&&a instanceof Array){
       o.d=d;
       o.a=a;
       this['zxc'+id]=o;
      }
     }
    
    }
    
    zxcRandomSentence.init({
      ParentID:'catagory1',
      SentenceArray:[
       [
        'catagory 1 level 1 sentence 1',
        'catagory 1 level 1 sentence 2',
        'catagory 1 level 1 sentence 3',
        'catagory 1 level 1 sentence 4'
       ],
       [
        'catagory 1 level 2 sentence 1',
        'catagory 1 level 2 sentence 2',
        'catagory 1 level 2 sentence 3',
        'catagory 1 level 2 sentence 4'
       ],
       [
        'catagory 1 level 3 sentence 1',
        'catagory 1 level 3 sentence 2',
        'catagory 1 level 3 sentence 3',
        'catagory 1 level 3 sentence 4'
       ]
      ]
    });
    
    zxcRandomSentence.init({
      ParentID:'catagory2',
      SentenceArray:[
       [
        'catagory 2 level 1 sentence 1',
        'catagory 2 level 1 sentence 2',
        'catagory 2 level 1 sentence 3',
        'catagory 2 level 1 sentence 4'
       ],
       [
        'catagory 2 level 2 sentence 1',
        'catagory 2 level 2 sentence 2',
        'catagory 2 level 2 sentence 3',
        'catagory 2 level 2 sentence 4'
       ],
       [
        'catagory 2 level 3 sentence 1',
        'catagory 2 level 3 sentence 2',
        'catagory 2 level 3 sentence 3',
        'catagory 2 level 3 sentence 4'
       ]
      ]
    });
    
    
    /*]]>*/
    </script>
    </body>
    
    </html>
    Vic

    God loves you and will never love you less.

    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles