How to submit your programming projects
Your projects for this course will be submitted and automatically tested via the web. You will use the online submission system at https://csi-info.baylor.edu/upload/.
Using the system the first time
Please do the following as soon as possible. The system uses a username/password system so you can log in to submit and test your code. The username is your Bear ID (such as "John_Doe"), and your password is initially "baylor" (without quotes). The first time you log in you should use this password, and the system should immediately ask you to choose a new password. Once you have changed your password, you will be sent back to the login page, where you can log in with your Bear ID and your new password. Note that the login mechanism is case-sensitive (even for your Bear ID).
Submitting your code
When you log in, find the project which you want to submit. There will be submission fields for each file you should submit for that project. You should use the "Browse" button to locate each file you want to submit, and then click "Upload" for each file to send that file to the server. After you have submitted all of your files, you can click "Test Program" to compile and test your program on the server. Of course, if you change your code on your computer, you will need to upload the code again to the server for the server to notice the change.
You may submit and test as many times as you like; there is no penalty for multiple submisisons. Only the last submission you make will be graded. When you submit your solution (clicking "Test"), the submission system will test it on hidden test cases. You will receive a response about whether your program's output matched the correct output on the test inputs. If your program does not produce identical output to the correct solution on the test cases (character for character), or if you do not follow the style guidelines, or your project has some flaw that was not discovered by the testing system, then your project does not yet pass or receive credit.
In addition, your program should not leak any memory. The upload site will test your code for leaks using valgrind.
For each project, you should accomplish two high-level goals:
- Submit a program which successfully compiles, runs, and gives the correct output for hidden test cases. When you pass this part, you will receive a message from the judging robot which says "YES. Your code passes the tests, and will be considered for style and implementation."
- Your code should comply with the style guidelines. After you have gotten a YES from the upload site, you will recieve an email from me (or the TA) telling you that your code does pass the style check (in which case you are done), or does not pass (in which case you must re-submit to the judging robot).
Your code could fail to pass the judging robot for several reasons. If your code doesn't pass, the system will tell you "NO" and give you a reason why. The reasons are:
- You have not submitted all the necessary files.
- Your code does not compile.
- Your output does not match my output on the same input.
- Your program crashed on an assert during execution (you will be given the assert information).
- Your program crashed during execution.
- Your program leaked too much memory during execution.
- Your program wrote to or read from memory it did not own.
- Your program required too much time to execute.
Note that there is a column on your test screen named "SOLUTION OUTPUT:", but it will always be empty. You can ignore this column.
Testing your program
First of all, you should be testing your program on YOUR OWN COMPUTER. You should not using the upload website as a testing/debugging/development platform. The upload website is for GRADING your program, but you should TEST your program on your own computer. For each project you will be provided a sample executable (which is the professor's compiled solution) which you can use to run on your own computer.
In order to verify that your output is exactly the same as the professor's output, you should use a diff utility. Sometimes files look exactly the same to the naked eye, but they are different because of spaces and newlines (or some other hidden characters). Diff utilities will catch these differences you can't see.
- Open the Options control panel (Edit -> Options)
- Set the options to be "Compare whitespace" and set "Sensitive to EOL" to be true.
Setting these options will make sure that WinMerge catches every difference.
Metrowerks CodeWarrior also allows you to compare two files (see menu Search, option "Compare Files"). However, CodeWarrior will (by default) ignore differences in newlines, so that is a problem.
Here are some important tips to make sure you are comparing files correctly:
- Do not use copy and paste for input or output. This is a common problem students have. Copy and paste can introduce extra newlines, and perhaps other characters, that aren't part of the original file you are copying from.
- Download files. Instead of copy/paste, to get input/output files that have been provided for you off the web properly, download them directly to your computer. That is, right-click on the link and use "Save target as..." (for Internet Explorer) or "Save link as..." (for Mozilla). This will make sure the file that is on the website is exactly the file that is on your hard drive.
- Use file redirection to provide input to your program.
To get input to your program directly from the file, use file input
redirection. In DOS and UNIX (Linux), you can redirect a file to be the
standard input to your program (instead of from the keyboard). The syntax is
c:\my_folder> my_program.exe < input_fileThis will take the data in input_file and redirect it so that the program will read it in on standard input. The key here is the "<" and the file name.
- Use file redirection to capture the output of your
program. Similar to input redirection, use output redirection to
save your program's output to a file, exactly as it comes out of
your program. Here we use ">" and a file name:
c:\my_folder> my_program.exe > my_outputThis will send all the standard output from your program to the file named my_output.
- Putting it all together, we would use input and output
redirection at the same time:
c:\my_folder> my_program.exe < input_file > my_outputAfter this, we can use a diff utility to compare my_output with the output sample you expect. Again, don't use copy and paste to compare output, and don't compare what you see on the screen -- use a diff utility.
Other than comparing your output with the professor's output, you should use your debugging
skills to find problems in your programs. Use print statements, and check them
for behavior that you expect. Use
assert() (see below). Use your
Don't use exceptions
You should never use exception handling in projects for this class. Exception handling is a poor substitute for correct logic in a program, and it doesn't work the same on all computers and all compilers.
Exception handling is a mechanism for error handling, not normal program function. Don't use it for this class.
The C/C++ function
assert() allows you to tell the program
"make sure this is true, and if it isn't, crash the program and tell me
about it". To use this in C++, just
Assert can give you very useful feedback about where your program is going wrong. You pass to assert a condition that should evaluate to true or false. If it is true, then nothing happens. If it's false, then assert crashes your program and prints an informative error about where the program crashed.
Here is an example:
char *my_string = new char; assert(my_string != NULL);If this memory allocation fails, then the pointer my_string will be NULL, and the program will crash when it gets into the assert. It will print something like this:
example.cpp:7: failed assertion `my_string != NULL'
If you use an assert() in your code, and your program stops on an assert() during the upload site evaluation, the upload site will give you the information about that assert. That includes the file name and line number of the assert() that failed, similar to the above example. This can be very useful for debugging.
If you use them wisely, asserts can be very useful for tracking down bugs in your code.
After you get a YES
If your code passes the online tests, then you are almost done. Make sure that your code follows the style guidelines, and that you are using the data structures in a correct manner for the project. You must have proper style to pass the project. So, for example, if your code passes but is not well-formatted, you should re-submit the code when you have it formatted properly.
If the submission system is not working properly, it could be due to several reasons.
- You get a message like: "The submission system for this project is not yet ready (code 1)". In this case, the system is not ready to grade that project. Generally, your professor will know about this, and you don't need to worry.
- You get a message like: "NO. You have not submitted all the necessary files.". In this case, the system thinks you have not submitted each file you need to submit, and it will not test your project until you do.
- Make sure that you allow cookies from the webserver.
- If something else is wrong (you can't log in, the system doesn't respond, etc.) please write me an email explaining carefully what the problem is and any output that the system is giving you.
- If there are any news or updates on problems with the submission system for a particular project they will be posted on Blackboard.
Many thanks to Bill Booth for providing the uploading system.