DragonPrime - LoGD Resource Community
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • November 17, 2018, 05:20:39 PM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1] 2   Go Down
  Print  
Author Topic: concerning the spelling bee  (Read 1350 times)
0 Members and 1 Guest are viewing this topic.
Wolfsbanewillow
Captain of the Guard
***
Offline Offline

Posts: 111

I'm not a programmer, writing texts is my hobby.


View Profile
« on: October 02, 2018, 02:31:34 AM »

Hi, I often encounter the spelling bee during gaming. But I found out that the questions become easy to answer if you can remember the order of the answers. I will copy an example:
"Choose

1)insuficient

2)insuficiant

3)insufficient

4)insufficiant


The Spelling Bee
Question One


Choose the correct spelling of the following word:

What is it called when you don't have enough of something?

1)insuficient
2)insuficiant
3)insufficient
4)insufficiant"
In this example, the correct answer is always 3.
I think it would be more challenging if the answers are randomly placed themselves; so you have to pay attention on how the answers are written down and not remember at which place the correct answer is.

I also would suggest to include more words. I personally always have difficulty with sincerely or exercise. It's possible I spelled them incorrectly. In French Exercise also exists and as soon as you see the words both in English and French, the confusion is starting. I suppose there are more difficult words in English.
In the current spelling bee game I easily can win the contest, and yes, it's frustrating to lose. But I like the idea of learning things while gaming.
Just a suggestion to make this sub-game more challenging.

Perhaps this is not possible to programm easily?

Best, WW
Logged

"Always use the proper name for things. Fear of a name increases fear of the thing itself." (cfr. Albus Dumbledore, "Harry Potter and the philosopher Stone", chapter 17).
TGTarheel
Codemeister
****
Offline Offline

Posts: 478


View Profile
« Reply #1 on: October 02, 2018, 08:38:13 AM »

I'd leave that to the original programmer.  Should they ever decide to work on and update this module, I would the use the updated version.
Logged
Wolfsbanewillow
Captain of the Guard
***
Offline Offline

Posts: 111

I'm not a programmer, writing texts is my hobby.


View Profile
« Reply #2 on: October 02, 2018, 08:43:11 AM »

Well, if the coder of the original module is still active over here, please consider this as a request to update this module. If the original coder isn't active over here anymore, I suggest this as a new project? Best, WW
Logged

"Always use the proper name for things. Fear of a name increases fear of the thing itself." (cfr. Albus Dumbledore, "Harry Potter and the philosopher Stone", chapter 17).
Thorpe
Member

Offline Offline

Posts: 2


View Profile
« Reply #3 on: October 17, 2018, 01:34:55 AM »

http://dragonprime.net/index.php?topic=9080

DaveS has retired, but looks like the updates could still be made by someone with available time.  Smiley
Logged
TGTarheel
Codemeister
****
Offline Offline

Posts: 478


View Profile
« Reply #4 on: October 17, 2018, 10:03:26 AM »

http://dragonprime.net/index.php?topic=9080

DaveS has retired, but looks like the updates could still be made by someone with available time.  Smiley

Indeed.  And Dave helped me A LOT in my early days as an Admin and fledgling coder.  He debugged a lot of things for me, and taught me how other things work.

I am still nowhere NEAR that caliber of coder Dave was, but I am okay with that.  My coding is sometimes sloppy, but it DOES WORK...which, to my view, is the most important thing.

That said, I have not a lot of spare time myself at the moment.

But what suggestions have you got in mind for the spelling bee?  Maybe I can find some time or someone else can.

That said, the placement of the navigations...for the correct word...it seems as if that ought to be possible...and the idea is intriguing to me, actually.

Seems like a randomizer could be added to mix up the order of the navigations.

Incidentally, with four choices there are 24 possibilities of the order of 1,2,3 and 4 - I believe.

The thing would be...how to do this with a randomizer that does not involve doing the actual navigations 24 times?  I'd have to work on that.

One could assign a letter, say a thru x to represent 24 possibilities.  But how to do it so that the navigations lines appear only once...that is the trick.
« Last Edit: October 17, 2018, 10:12:50 AM by TGTarheel » Logged
Wolfsbanewillow
Captain of the Guard
***
Offline Offline

Posts: 111

I'm not a programmer, writing texts is my hobby.


View Profile
« Reply #5 on: October 17, 2018, 10:09:22 AM »

I posted the suggestions in the original post at the beginning of this topic: make the answers randomly placed and not in a fixed order, so that the correct one is not always at the same place in the series (see the example I gave above) and add some more difficult words like sincerely, necessary and exercise (it's possible I already misspelled them). Best, WW
Logged

"Always use the proper name for things. Fear of a name increases fear of the thing itself." (cfr. Albus Dumbledore, "Harry Potter and the philosopher Stone", chapter 17).
Anharat
Codemeister
****
Offline Offline

Posts: 275



View Profile
« Reply #6 on: October 19, 2018, 08:07:10 AM »

Assuming you have your answers in an array fetched from the database, just shuffle that array (any amount of answers possible) and pass the selected word in your navigation and check on the next page if the word in your navigation is the correct one. No idea what you were planing with printing all 24 (4!) possibilities.

~
Logged
TGTarheel
Codemeister
****
Offline Offline

Posts: 478


View Profile
« Reply #7 on: October 20, 2018, 11:58:39 AM »

Assuming you have your answers in an array fetched from the database, just shuffle that array (any amount of answers possible) and pass the selected word in your navigation and check on the next page if the word in your navigation is the correct one. No idea what you were planing with printing all 24 (4!) possibilities.

~

No idea since I had not even looked at the module yet.

Update:  Looked at it, and the baues are not stored in any array, they are as I thought they would be... here is a code snip...
Code:
switch(e_rand(1,4)){
case 1:
output("`3What is it when you roam about in search of pleasure?`n`n");
output("`#1)galavanting`n");
output("2)gallavanting`n");
output("3)galivanting`n");
output("4)gallivanting`n"); //correct
addnav("`b`G1)galavanting`b","runmodule.php?module=spellingbee&op=jj68baef");
addnav("`b`G2)gallavanting`b","runmodule.php?module=spellingbee&op=jj84eabf");
addnav("`b`G3)galivanting`b","runmodule.php?module=spellingbee&op=jj68efab");
addnav("`b`G4)gallivanting`b","runmodule.php?module=spellingbee&op=jj64aefb"); //correct!
break;
case 2:
output("`3What is it when you ask for help?`n`n");
output("`#1)assistance`n"); //correct!
output("2)asistance`n");
output("3)assisstance`n");
output("4)asisstance`n");
addnav("`b`G1)assistance`b","runmodule.php?module=spellingbee&op=jj64aefb"); //correct!
addnav("`b`G2)asistance`b","runmodule.php?module=spellingbee&op=jj68baef");
addnav("`b`G3)assisstance`b","runmodule.php?module=spellingbee&op=jj84eabf");
addnav("`b`G4)asisstance`b","runmodule.php?module=spellingbee&op=jj68efab");
break;

SO...the way they have it currently...you'd have to put another randomizer in.  You could assign each word correct and incorrect spellings to a variable, and then depennding on the second random number, have the order different...but without a total re-write of this module, I fail to see how else this could be done?

For example, above you could assign each spelling to a variable, say $word1, $word2, etc.
Then depending on which random number you get, you'd assign the word to that variable

Like this:  $word1, $word2, $word3, $wordcorrect.  The correct word is always the correct word, but you need that to appear randomly, #1 - 4.

So...you still need four sets of navs to make it work....unless you see something I don't...I admit I see no other way to do it.  It doesn't matter where the other ones show up...but the correct word nav must always move.

So...let me think...

Code:
$wordorder = e_rand (1,4);
if ($wordorder == 1) {
addnav $correctword (link)
addnav $word1 (link)
} else {
addnav $word1 (link)
}
///above places either correctword, word1...or else just word1
if ($wordorder == 2) {
addnav $correctword (link)
addnav $word2 (link)
} else {
addnav $word2 (link)
}
///above places either correctword, word2...or else just word2 (word 1 was already placed above)
if ($wordorder == 3) {
addnav $correctword (link)
addnav $word3 (link)
} else {
///above places correctword, word3 (word 2 was already placed above)
addnav $word3 (link)
addnav $correctword (link)
///above places word3, correctword (word 2 was already placed above)
}

That is my best example of how to do it....
If $wordorder = 1 the correct word will be nav1, etc...and if $wordorder =4, then the fourth nav is correct, thus it automatically adds after $word3, so no need for an if statement for $wordorder =4.

Without a total re-write, this is the only way I see of doing this.  If you see something better Anharat, you are welcome to share your wisdom.
« Last Edit: October 20, 2018, 11:15:40 PM by TGTarheel » Logged
TGTarheel
Codemeister
****
Offline Offline

Posts: 478


View Profile
« Reply #8 on: October 20, 2018, 10:37:40 PM »

OK, so I worked something up...and it's an ungodly apocalypse, but it ought to work...I replaced 10 lines of code with 57 lines...and that was just for one word.

There's 12 possible words, just as it is currently programmed, so we would be adding 12 x 47 lines or 564 lines...to make this work.

Without a complete rewrite changing the words to be in a database and fetched with an SQL call, anyway.

I personally am not of a mind to want to completely re-write this in order to have it store the words in database and call for them in an SQL call and put them in an array.

And the one method I could do...as I said, is a basically ungodly beast begging for apocalypse.

Here's the original code for one word, followed by my coding that replaces just the one word, and you'd have to do this 12 times JUST to get where the program is now, let alone adding more possible words.
Code:
case 1:
output("`3What is it called when part of a flower is being fertilized?`n`n");
output("`#1) polinatting`n");
output("2) polinating`n");
output("3) pollinating`n"); //correct!
output("4) pollinatting`n");
addnav("`b`G1) polinatting`b","runmodule.php?module=spellingbee&op=jj68baef");
addnav("`b`G2) polinating`b","runmodule.php?module=spellingbee&op=jj84eabf");
addnav("`b`G3) pollinating`b","runmodule.php?module=spellingbee&op=jj86bfea"); //correct!
addnav("`b`G4) pollinatting`b","runmodule.php?module=spellingbee&op=jj68efab");
break;

Replacement code
Code:
case 1:
output("`3What is it called when part of a flower is being fertilized?`n`n");
$wordorder = e_rand(1,6);
if ($wordorder == 1) {
$word1 = "polinatting";
$word2 = "polinating";
$word3 = "pollinatting";
} else if ($wordorder == 2) {
$word1 = "polinatting";
$word3 = "polinating";
$word2 = "pollinatting";
} else if ($wordorder == 3) {
$word2 = "polinatting";
$word1 = "polinating";
$word3 = "pollinatting";
} else if ($wordorder == 4) {
$word2 = "polinatting";
$word3 = "polinating";
$word1 = "pollinatting";
} else if ($wordorder == 5) {
$word3 = "polinatting";
$word1 = "polinating";
$word2 = "pollinatting";
} else {
$word3 = "polinatting";
$word2 = "polinating";
$word1 = "pollinatting";
}
$correctword = "pollinating"; //correct
$correctpos = e_rand(1,4);
if ($correctpos == 1) {
output ("%s`n",$correctword);
output ("%s`n",$word1);
output ("%s`n",$word2);
output ("%s`n",$word3);
addnav(array("`b`G1)%s`b",$correctword),"runmodule.php?module=spellingbee&op=jj86bfea"); //correct!
addnav(array("`b`G2)%s`b",$word1),"runmodule.php?module=spellingbee&op=jj68baef");
addnav(array("`b`G3)%s`b",$word2),"runmodule.php?module=spellingbee&op=jj84eabf");
addnav(array("`b`G4)%s`b",$word3),"runmodule.php?module=spellingbee&op=jj68efab");
} else if ($correctpos == 2) {
output ("%s`n",$word1);
output ("%s`n",$correctword);
output ("%s`n",$word2);
output ("%s`n",$word3);
addnav(array("`b`G1)%s`b",$word1),"runmodule.php?module=spellingbee&op=jj68baef");
addnav(array("`b`G2)%s`b",$correctword),"runmodule.php?module=spellingbee&op=jj86bfea"); //correct!
addnav(array("`b`G3)%s`b",$word2),"runmodule.php?module=spellingbee&op=jj84eabf");
addnav(array("`b`G4)%s`b",$word3),"runmodule.php?module=spellingbee&op=jj68efab");
} else if ($correctpos == 3) {
output ("%s`n",$word1);
output ("%s`n",$word2);
output ("%s`n",$correctword);
output ("%s`n",$word3);
addnav(array("`b`G1)%s`b",$word1),"runmodule.php?module=spellingbee&op=jj68baef");
addnav(array("`b`G2)%s`b",$word2),"runmodule.php?module=spellingbee&op=jj84eabf");
addnav(array("`b`G3)%s`b",$correctword),"runmodule.php?module=spellingbee&op=jj86bfea"); //correct!
addnav(array("`b`G4)%s`b",$word3),"runmodule.php?module=spellingbee&op=jj68efab");
} else if ($correctpos == 4) {
output ("%s`n",$word1);
output ("%s`n",$word2);
output ("%s`n",$word3);
output ("%s`n",$correctword);
addnav(array("`b`G1)%s`b",$word1),"runmodule.php?module=spellingbee&op=jj68baef");
addnav(array("`b`G2)%s`b",$word2),"runmodule.php?module=spellingbee&op=jj84eabf");
addnav(array("`b`G3)%s`b",$word3),"runmodule.php?module=spellingbee&op=jj68efab");
addnav(array("`b`G4)%s`b",$correctword),"runmodule.php?module=spellingbee&op=jj86bfea"); //correct!
} else {}
break;

See what I mean abut it being an ungodly apocalypse??
Logged
TGTarheel
Codemeister
****
Offline Offline

Posts: 478


View Profile
« Reply #9 on: October 20, 2018, 11:05:56 PM »

The other possibility I could think of...would be to put all the words into prefs.  Including all possible spellings.

This would add 48 lines (for the prefs) and then you'd have a randomizer to pick which order to get and output the four prefs.  And then you'd still need the 57 line thing for each word...but this would allow Admins to use different words, or different spellings.

And if you wanted to add more words, you'd just have more prefs.

Either way, it's an ungodly apocalypse, without completely re-writing the module.

I'm not terribly great with SQL calls, but I could try tinkering with how one would do it, and see how that works out.  Even with SQL calls, you still need to have all the words put into the database, and there is a lot of lines being added.

Unless you want to show us all how it is done, Anharat.  Because I have no answers besides the ones I just worked up.  And any of my solutions are really awful.

The other possibility is to make ONLY the position of the correct word move, and the other three always stay in the same position, 1 2 and 3...but the correct word could go anywhere in between.  This would add fewer lines, but it would not truly randomize the choices, only the correct word would move, thus it is still possible to memorize.
« Last Edit: October 20, 2018, 11:19:22 PM by TGTarheel » Logged
TGTarheel
Codemeister
****
Offline Offline

Posts: 478


View Profile
« Reply #10 on: October 21, 2018, 12:36:17 AM »

Now...thinking in terms of SQL call...if we have a table with all the words, but each word has it's own column...thus you have a table with 12 columns and four rows (this gives twelve words with four possible spellings)

First you need to get them into a table.  I am assuming this happens at install.

You'd do this...

$query = SELECT column FROM table ORDER BY RAND() LIMIT 4;

This returns all 4 items in the column, in random order, yes??

So then, how do you get this into an array so that you can use it?

$array = array();
while($row = mysql_fetch_assoc($query)){
  $array[] = $row;
}

So now I have an array of the four words in random order...right??

This is where I get stuck, because I do NOT know how to get the individual items out of the array and assign each to a different variable.  Is it an implode function or what??

What I want to do here is pick the first word out of the array and assign it as $word1.  Then the second is $word2.

My problem here is,

A - I do not know how to do it.
B - my array also contains the correct word, but since it is in random order, how do I tell the program which one is right...and assign that to a variable $correctword

See...as I said, my coding skills are not exactly stellar...and I am basically in over my head now...and Google doesn't help me...every example I can find is too general, and I can't follow what is happening, so that I can have it happen on my own

Or is there a way to do the SQL call such that it gets a random row, one at a time, and assigns each to a variable, instead of getting an array?

We can make it consistent that the correct spelling will always be the first row, since it is getting the rows in random order...so you tell it that when it fetches row 1...this one gets assigned to variable $correctword

Just not sure how to actually proceed here.  I am not great with SQL, really.

Am thinking array isn't the best way, simply because there isn't a way I can see to then tell it which word is correct.  So I want to fetch all four rows in random order, the first row is always the correct spelling, but could get fetched third or second, or even first.  And somehow tell it when fetching row 1 - to assign that to variable $correctword instead of $word1 or $word2 or $word3.

But how to get there is blowing my mind.  I understand the process I want to use, but how to code that is another matter...help, if anyone is better at this stuff than I am....
« Last Edit: October 21, 2018, 12:45:08 AM by TGTarheel » Logged
Anharat
Codemeister
****
Offline Offline

Posts: 275



View Profile
« Reply #11 on: October 21, 2018, 10:21:47 AM »

Haven't really read your posts, just looked at those snippets. No matter if the array comes from a database or is static, it will be far easier to handle and extend than the way it's currently written in. What I was thinking of is something like this:

I'll only write pseudo like code, so don't just copy&paste

at the beginning of the run function
Code:
$questions = [
  [
    'question' => '`3What is it when you ask for help?`n`n',
    'answers' => [['value' => 'assistance', 'correct' => 1], ['value' => 'assisstance']['value' => 'asisstance'], ['value' => 'asisstance']]
  ],
  ...
];

When asking the question
Code:
$question = $question[$randomKey]; // get random question from array
output($question['question']);
$x = 1;
foreach(shuffle($question['answers']) AS $answer) {
  output("`#$x)".$answer['value']."`n");
  addnav("`b`G$x)".$answer['value']."`b","runmodule.php?module=spellingbee&op=jj68baef&key=$randomKey&word=".$answer['value']);
  $x++;
}

And then just check if the 'correct' index is set for the 'word' and the 'key'.

Code:
$key = httpget('key');
$word = httpget('word');
$q = $questions[$key];
foreach($q['answers'] AS $a) {
  if($a['value'] == $word && isset($a['correct']) {
    output("Yey, you're right!");
  }
}
« Last Edit: October 21, 2018, 10:25:59 AM by Anharat » Logged
TGTarheel
Codemeister
****
Offline Offline

Posts: 478


View Profile
« Reply #12 on: October 22, 2018, 07:00:56 PM »

Haven't really read your posts, just looked at those snippets. No matter if the array comes from a database or is static, it will be far easier to handle and extend than the way it's currently written in. What I was thinking of is something like this:

I'll only write pseudo like code, so don't just copy&paste

at the beginning of the run function
Code:
$questions = [
  [
    'question' => '`3What is it when you ask for help?`n`n',
    'answers' => [['value' => 'assistance', 'correct' => 1], ['value' => 'assisstance']['value' => 'asisstance'], ['value' => 'asisstance']]
  ],
  ...
];

When asking the question
Code:
$question = $question[$randomKey]; // get random question from array
output($question['question']);
$x = 1;
foreach(shuffle($question['answers']) AS $answer) {
  output("`#$x)".$answer['value']."`n");
  addnav("`b`G$x)".$answer['value']."`b","runmodule.php?module=spellingbee&op=jj68baef&key=$randomKey&word=".$answer['value']);
  $x++;
}

And then just check if the 'correct' index is set for the 'word' and the 'key'.

Code:
$key = httpget('key');
$word = httpget('word');
$q = $questions[$key];
foreach($q['answers'] AS $a) {
  if($a['value'] == $word && isset($a['correct']) {
    output("Yey, you're right!");
  }
}
That is very not helpful, it is too advanced for my coding skill level.  And how does this thing actually make sure the possible answers are placed in random order, and it always knows which one is right?

Perhaps if you notated with comments, your code snips as to what each thing is ACTUALLY DOING...it might be helpful, I do not know.

I know the way I did it up above WOULD WORK...but as I said it's an ungodly abomination begging for apocalypse.

As best  can determine...your first segment...is getting a question and possible answers.
Each question and set of possible answers are bracket-wrapped...and then each individual bracket set is bracket-wrapped.  I can see where you separated the correct answer from the wrong answers.

So it would somehow (and I don't know how yet...fetch one bracket set...this would be a question and it's answers...including the correct answer, which it seems to know.

That much I can follow.

The second set of code...apparently tells it which question/answer set to grab, but not sure how the randomization works on that.

Apparently, shuffle is a function that will shuffle the order of the output and the navigations.  But, since each navigation goes to a different OP=....I am not sure how you handle it.  The truth is you could have only two navigations, one for right and one for wrong...obviously the coder (Dave) did not want people to be able to simply hover over the choices and thus be able to tell which was right or wrong...hence four different op= functions, three of which do go to the same place...and coded in a way that you can't tell...uness you are very observant and know the code...which is actually correct...by simply hovering.

But how are the different navs handled here to create this same effect?? I am not seeing that.

Or do you have one navigation for all four answers, and have it check in the resulting op...if you have the correct answer or not?


I think I have the basic concept, if you could confirm that would be helpful.

Now the problem would be putting it all together in a way that makes it work...and that is where I fall down, as the coding is more complex than my proficiency level.
« Last Edit: October 22, 2018, 07:12:10 PM by TGTarheel » Logged
Anharat
Codemeister
****
Offline Offline

Posts: 275



View Profile
« Reply #13 on: October 23, 2018, 12:16:12 AM »

I'm only on my mobile so writing Code is a bit tough right now but I'll try to explain a little more


Code:
// define an array with questions and answers. [ ] is like array( )
// this is placed at top of the run or run event function
// answer is an array of arrays which contain a value and the correct index if it's the correct word
$questions = [
  [
    'question' => '`3What is it when you ask for help?`n`n',
    'answers' => [['value' => 'assistance', 'correct' => 1], ['value' => 'assisstance']['value' => 'asisstance'], ['value' => 'asisstance']]
  ],
  ...
];

When asking the question
Code:
$randomKey = e_rand(0, count($questions)-1);
// get random question from array
$question = $questions[$randomKey];
// print the question
output($question['question']);
$x = 1;
//print and add navs for all answers in a random order
foreach(shuffle($question['answers']) AS $answer) {
  output("`#$x)".$answer['value']."`n");
  // all navs go to the same op
  // add the selected word and the randomkey to the navigation
  addnav("`b`G$x)".$answer['value']."`b","runmodule.php?module=spellingbee&op=check&key=$randomKey&word=".$answer['value']);
  $x++;
}

And then just check if the 'correct' index is set for the 'word' and the 'key'.

Code:
// when op is 'check'
// get randomkey and selected word from navigation
$key = httpget('key');
$word = httpget('word');
// get question from the question array
$q = $questions[$key];
// run through all answers and check if the value is equal to the selected word from the navigation. If the word equals check if the correct index is set
$right = false;
foreach($q['answers'] AS $a) {
  if($a['value'] == $word && isset($a['correct']) {
    output("Yey, you're right!");
    $right = true;
  }
}
// if the wrong value was selected
if(!$right) {
  output("Aww, you're wrong!");
}
Logged
TGTarheel
Codemeister
****
Offline Offline

Posts: 478


View Profile
« Reply #14 on: October 23, 2018, 09:24:11 PM »

OK, I think I am basically following what's happening now, though a few of those are functions I have never used before.  Thanks for explaining how it works.  I mostly had it right looking thru the code you had originally provided.

My coding skills are, at best, intermediate...and I often do things "the long way" because I am better able to see the steps and what they do...and that causes unwieldy cod that is, by most programmers standards, sloppy at best.

I am totally self-taught though...started out reverse-engineering other people's stuff, tweaking it to make it do what I wanted instead of what it originally did.  Coding manuals and the like do not help me learn, they only confuse me more because they all use examples that are too general.

The best way for me to learn is to get in and see code that works and then tweak it around until I am more comfortable with it...I am a hands-on learner.  So thank you for your service today in helping me better grasp this concept.  They need someone like YOU to write the training manuals!

I believe when I get a little time I will try to work this up...and of course will credit you for the help in this, Anharat!  The idea of having the answers come in random order was intriguing to me, so thank for the idea, wolfsbanewillow!
Logged
Pages: [1] 2   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Play LoGD on Dragonprime

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
41 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search