Number Guessing Game - Tasks mark/unmark randomly

Hi fcc forum,

Today i’m kindly asking for your help as i’ve been stuck for a while trying to complete Number Guessing Game challenge from Relational Database Certification

I don’t understand why when i click Run button to check if my solution is correct, some of the tasks are marked as correct and some others don’t. Then if i click Run button again some of the tasks that were marked as correct are unmarked and this happens randomly if i click Run button again

So far best i could get is the following output:

I’ve tried different solutions but this one has got the most completed tasks and i can’t make it pass even though the solution does what the user stories ask for (or that is what i think )

That is why i’m asking for help because i don’t know what else to do

Here my bash script and my sql dump in case you want to try them, maybe i’m going blind of frustration and i can’t see what’s already in there

Output for a new user

image

Then after guessing

image

Output for existing user

image

Then after guessing

image

Thanks for reading i really hope someone can give me a hint in here

Carlos

1 Like

I’ve been spamming run button, still no clue why it behaves like that

Could you share the results of the CodeRoad tests please?

Click on the OUTPUT tab shown below and select the option I’ve highlighted. Then hit Run on the tests.

I just opened up this course afresh so you can see the tests are failing because I haven’t actually done anything yet. (I finished the course previously and then deleted it).

Hi, igorgetmeabrain

I entered to get the logs of the CodeRoad (Tests) but it seems that my progress is gone for the moment (sigh). Trying to launch CodeRoad does not seem to be available at the command palette either.

I remember a line with something about codeally not found, in a previous post i made, only the first part of the post is relevant

I know this can be misleading but i can’t access CodeRoad (Tests) at the moment.

I’m going to delete the previous vm and start again on a new one

Hi again igorgetmeabrain,

Here i uploaded code road tests log sorry but i had to start over to run my project again.

Hope this can point us in the right direction

Thanks for your help

Unfortunately it looks like these are issues beyond our control, as the project environment seems unstable and the tests are failing due to connection issues more than anything else at the moment.

Previously, when the connection was holding but was just running very slowly, it was generally possible to get the tests to pass by tinkering with timeouts etc.

If you get everything running again and you start to see CodeRoad test failure messages which are not directly related to ‘fatal’ connection errors, please share them!

Hi, igorgetmeabrain

The project is running again or i think so because i created a new vm to gather code road tests log. So vm and project should still be there ready to run.

I understand what you say and i’m going to keep trying until either tests pass or error messages are different from ‘fatal’ connection errors in such case i’ll share them asap.

Thanks for your reply.

Carlos.

Hi, i’m still getting the same error messages in the Code Road (Tests) Logs, no change at all in CodeRoad Tests Behaviour, each execution shows different tasks marked as completed :confused: and the same PLSQL error saying codeally does not exist.

Random execution

Random execution

Do you guys know any other way to submit my solution so it can be graded in any other way or at least get some help like asking for support in an email ?

Sorry for all the troubles @cleall, I took a look at your code - the role "codeally" does not exist error seems to be coming from the PSQL variable at the top. Change that to what it suggests in the instructions and that error should go away.

I think the tests are having problems with how the script is running. You are calling the PLAY function from within the PLAY function - and it’s getting confused. I’m not sure exactly what it’s doing, but I think it’s opening a bunch of subshells or subprocesses and the tests can’t finish or something. I suggest rewriting your script so that PLAY function is only called once or so that the file just runs from top to bottom and uses the built-in loops.

Let us know if that works.

Hello moT01 thanks for replying:

The psql variable for the user is the same as suggested in the instructions i just loaded it from a .env file the same goes for the db_name in my case the name is number_guess.

.env file contents

After testing again the only thing I do not understand is why the task that says: If that username has been used before, it should print … Now is not marked as correct. Have I done something wrong ? In my eyes the message has the requested elements :confused: .

Or seen from the terminal

Thank you again for your reply it really helped me a lot.

Carlos.

Can you share your updated script and dbdump @cleall? I’ll take a look.

Yes here they are:

Thank you for your help.

Carlos.

I ran your code, it did pass all the tests from time to time - but mostly it failed one or more of the tests. So you could just try running the tests a bunch and hopefully it will pass once. I made a small change to the tests that made it pass consistently - but in order for that change to get added to your project, you would need to delete you container and start a new one. Learn how here.

Let us know if either of those work. Hopefully the change in the test improves this issue for everyone.

Hi moT01 :

I created a new container so I started from scratch again. After everything was set up I simply spent 30 mins spamming the Run button to validate the Tasks to see if after running the tests it could pass with no success.

I also noticed that one or two tasks that were previously marked as correct were unmarked in between Executions.

I am sorry that this did not work for me I had high expectations to finally be able to complete this challenge. I have to ask how much time did you spend running the tests ? because even though I created a new container and ran the tests several times I am still unable to make it pass all the tests I just do not understand :confused: .

Thanks again for your help.

Carlos.

They all passed on one of the first tries for me - but usually it would fail one or more. I’ll open your project and give it one more try. If it doesn’t work, I’ll try and find a different way to get this to pass for you.

Hello m0T01:

It must be bad luck for me not being able to make it work. On Sunday I investigated how to create a clicker using python so after setting it up I left it “pressing” the Run button for me every four seconds but as you can imagine I had the same result.

I sincerely appreciate your help, thank you for your efforts, time and patience.

Carlos.

Hey @cleall, I don’t know if you’ve resolved this yet, but I got your code to pass.

I commented out the code which reads the environment variables and declared the PSQL variable explicitly as:
PSQL="psql --username=freecodecamp --dbname=number_guess -t --no-align -c"

I did this because the test logs were showing a fatal connection error every time I ran the tests, so obviously couldn’t connect to your database.

Also, because I’ve found it a sticking point with this project in the past, I removed the multiple incidences of ((GUESS_COUNTER++)) and inserted this only once at the top of your while loop (immediately after do).

Your code then passed all tests immediately for me.

Hi igorgetmeabrain:

I tried testing again and found out first:

  • I did not notice that a -X parameter was inside of PSQL declaration (this is totally my fault)

Then moving on to the PSQL parameters --username and --dbname:

  • For some reason reading variables from .env file does not seem to work when tests are executed (Pressing Run button). The only thing I do not understand is how values from the database are retrieved when you execute the script (manually ./number_guess.sh) and then you complete the game, play again and querying the database seems to be ok using the .env file variables.

Finally:

Following moT01 recommendations were the way to go I just completely forgot about declaring again the PSQL variable (not using .env) thanks to what you just mentioned I realized I completely missed declaring PSQL variable again pff.

Thank you very much moT01 and igorgetmeabrain for lending me a hand on this finally with your help all tests passed this time.