Where are the output files are located?

Re: Where are the output files are located?

by Juan Carlos Rodríguez-del-Pino -
Number of replies: 7
Picture of Particularly helpful Moodlers Picture of Plugin developers
Dear Acqua Alta,
at this moment there is no way to retrieve files created by the code of the students, really you can not get any files from the execution environment.
But if you want to check the existence and content of files created by the student code you can use the features of the test cases to check it.

For example, to check the existence of a file after a given test, you can:
1- Write a script to check the file's existence and its content.
2- Add a test case that runs the script.

The test case after the case that creates the student file.

Case = Checks file content
program to run = check_file.sh
program arguments = student_file.txt correct_file.txt
Fail message = The file created does not exist or does not have the expected content
output = "OK"
The script "check_file.sh" that checks the student's files. Notice: first parameter student file, second correct file.


#!/bin/bash
if [ -f  "$1" ]
then
    diff "$1" "$2" >& /dev/null
    if [ "$?" == "0" ]
    then
	echo "OK"
    else
        echo "Differ"
    fi
else
    echo "The file $1 does not exists"

fi

Note: the script and the correct files must be in the execution files and in "files to keep when running"

Best regards,
Juan Carlos.

Average of ratings: Useful (1)
In reply to Juan Carlos Rodríguez-del-Pino

Re: Where are the output files are located?

by Acqua Alta -
Thanks a lot, Juan, for the detailed answer smile
In reply to Juan Carlos Rodríguez-del-Pino

Re: Where are the output files are located?

by Sean Headrick -

Dear Juan Carlos:

I'm a high school teacher and I teach java.  First I want to let you know that I LOVE 😍 VPL!  This is the best tool for teaching computer science and you have built in so many features to make grading quick and easy.  The students engage so much more when test cases are provided.  This is an AWESOME tool and thank you for providing it free!

I pay for moodle hosting.  VPL writes data files and directories to /repository/moodledata/vpl_data/.  Three times over the past 18 months, directories from vpl_data have gone missing.  The only reason I know this is because I will go back to a previous VPL assignment and find that data is missing:  NO test cases;  NO required files; and NO user files -- all the .java files are gone!  So I contacted the host and they found a server backup.  I replaced the directories and all the VPL assignments worked again.

QUESTION:  Have you heard of this happening to anyone?  Do you think the hosting company system is removing the vpl_data directories?  Do you think it is when the Moodle version is upgraded?  Do you have a suggestion of how to prevent this from happening?

Thank you for any advice or information you have!

In reply to Sean Headrick

Re: Where are the output files are located?

by Sean Headrick -
the filepath above should be /moodledata/vpl_data/ (the directory repository is actually under moodledata
In reply to Sean Headrick

Re: Where are the output files are located?

by Juan Carlos Rodríguez-del-Pino -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Dear Sean,

thank you for your comments about VPL. I hope you enjoy the use of VPL for many years.

Answering your question: I have no received reports with symptoms similar to the annoying problem you describe.

Anyway, due to the severity of the problem, I will study the issue to give you a full response.


Best regards,

Juan Carlos.

In reply to Juan Carlos Rodríguez-del-Pino

Re: Where are the output files are located?

by Edukacija.net mentor -
Dear Juan Carlos,

your above solution seems to be exactly what I have been searching for.

However, when I tried it, it does not work as I expected. I have this:
vpl_evaluate.cases
Case = Checks file content
program to run = ./check_file.sh
program arguments = test.txt
output = "The file DOES exist"
check_file.sh
#!/bin/bash
if [ -f  "$1" ]
then
echo "The file $1 DOES exist"
else
    echo "The file $1 does not exist"
fi
--> for start, just wanted to simplify and check if the file was found.

When I test this with a simple Python program:
a = input()
f = open("test.txt", "w")
f.write(a)
f.close()
f = open("test.txt", "r")
print("Read:")
print(f.read())
or with a simple C program:
#include <stdio.h>
int main()
{
    FILE *fp;
    char buff[255];
    
    fp = fopen("test.txt", "w+");
    fprintf(fp, "blah blah\n");
    fclose(fp);
    fp = fopen("test.txt", "r");
    fgets(buff, 255, fp);
    printf("%s", buff);
    fclose(fp);
    return 0;   
}
The message is "The file test.txt does not exist" although both programs create and read file test.txt well.

What am I missing here?

Thank you!
Sasa Dumic
In reply to Edukacija.net mentor

Re: Where are the output files are located?

by Juan Carlos Rodríguez-del-Pino -
Picture of Particularly helpful Moodlers Picture of Plugin developers

The check_file.sh script must run the student's program and ensure the correct functionality removing the file if exists.

check_file.sh
#!/bin/bash
# Removes $1 file is exists
if [ -f  "$1" ]
then
rm $1
fi
# Runs student's program
./vpl_test $1
# Cheks is file $1 exists
if [ -f  "$1" ]
then
echo "The file $1 DOES exist"
else
  echo "The file $1 does not exist"
fi
Best regards,
Juan Carlos.
Average of ratings: Useful (1)
In reply to Juan Carlos Rodríguez-del-Pino

Re: Where are the output files are located?

by Edukacija.net mentor -
Thank you, Juan.

Yes, in the meantime I've found ./vpl_test - that solves it. Good point for removing the possible existing file first, though.

We've just recently discovered VPL plugin and helping an university in Zagreb to use it. Really, really nice and powerful plugin that is.

Keep up the great work!
Best regards
Sasa Dumic