0

I am an English teacher and I created an exercise, using Hotpotatoes, to demonstrate to my student how to make sentences from different words. The words are in alphabetical order so I can easily find the word I want to use.

But there is a code in the script that shuffles them every time I start or restart the HTML file. I have no experience in coding. I have been trying to change the two shuffle functions to make them stop from shuffling. Deleting them did not work, the whole exercise disappeared. By the way, the file is not a test; it's just me demonstrating to the kids over the Internet how to make sentences by dragging the words and putting them together.

The file was too big for here. Here are the two codes that I believe are doing the shuffling:

function Shuffle(InArray){
    var Num;
    var Temp = new Array();
    var Len = InArray.length;

    var j = Len;

    for (var i=0; i<Len; i++){
        Temp[i] = InArray[i];
    }

    for (i=0; i<Len; i++){
        Num = Math.floor(j  *  Math.random() *1);
        InArray[i] = Temp[Num];

        for (var k=Num; k < (j-1); k++) {
            Temp[k] = Temp[k+1];
        }
        j--;
    }
    return InArray;
}

Segments = Shuffle(Segments);
Peter O.
  • 32,158
  • 14
  • 82
  • 96
  • It does seem like deleting the code that you have here will simply stop `Segments` from being shuffled. – Nick Dec 28 '20 at 18:33
  • Yes, it does but they are not arranged in alphabetical order as I pasted the words in Hot Potatoes v.7 JMix. When I delete the segments = Shuffle and I run the html file, they stay the same every time I restarted but they are not in alphabetical order. – Peace is Mirage Dec 28 '20 at 19:45
  • 1
    What if you delete all this code and just do Segments.sort() – Nick Dec 28 '20 at 19:52
  • Here is a link to the file if someone is interested to see it. https://drive.google.com/file/d/1x776P3nBV6pvPh2NWbtxU8tYKnfp_F7E/view?usp=sharing – Peace is Mirage Dec 28 '20 at 19:56
  • I am no programmer. Here is a link if you are interested in seeing the file https://drive.google.com/file/d/1x776P3nBV6pvPh2NWbtxU8tYKnfp_F7E/view?usp=sharing – Peace is Mirage Dec 28 '20 at 19:58
  • Does this answer your question? [Seeding the random number generator in Javascript](https://stackoverflow.com/questions/521295/seeding-the-random-number-generator-in-javascript) – Peter O. Dec 28 '20 at 20:24
  • Code is Greek to me. – Peace is Mirage Dec 28 '20 at 20:36
  • I know you have told that you have no experience in coding but your question is just too broad as it is not possible to just guess what is the code. Your google drive file on the comments is protected. You should: 1) Try to be more specific showing some parts of code more meaningful for the question or 2) Try to learn at least some basics of programming before asking – Iogui Dec 28 '20 at 23:19
  • Sorry about that. The link is available now. If everyone can learn programming, we'll have no problem. Programming is for really smart people especially in math and science. I am not one of those people. Tried to learn but it seems abstract ideas are not my subject. – Peace is Mirage Dec 29 '20 at 06:26

0 Answers0