Problem with test cases

Problem with test cases

by Edizon Zacarias -
Number of replies: 6

Hola a todos,

Necesito de su ayuda, por eso recurro a este foro.

Instale VPL jail server en ubuntu 18.04 de 65 bits, y he probado los casos de uso y han fallado cuando, cuando de introduce datos desde consola.

Mi caso de uso:

case = test

input = 5

5

output = 10.0


Mi programa en python es el siguiente.

Escriba un programa que solicite al usuario 2 números y cuyo resultado de 10.0.

Los casos de uso funcionan cuando los datos del programa son estáticos por ejemplo.

a = 5.0

b = 5.0

sum = a + b

print(sum)


Fallan los casos de uso cuando se solicitan datos al usuario:

a = float(input("n1>"))

b = float(input("n2>"))

c = float(input("n3>"))

sum = a + b + c

print(sum)

Ejecuto el programa, introduzco los numeros ejemplo 5 y 5 y pasa el caso de uso, pero ojo si introduzco un numero mayor ejemplo 6 y 7 sumados daria 13 y tambien se evalua como correcto cuando es totalmente erroneo.


Quiero saber si estoy haciendo algo mal, si es configuración del servidor, o si estoy usando la versión incorrecta del plugin.


Ojala alguien pueda ayudarme, básicamente el problema se origina cuando se utiliza la sentencia input() de python.




Average of ratings: -
In reply to Edizon Zacarias

Re: New Virtual Programming Lab (VPL) module

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

Dear Edizon,
The output of the tests may be check in different ways: numbers, text, exact text, and regular expressions (see down for more details).
If you want to allow answers that mix text and numbers it may be better to use a regular expression. e.g.

output = /\s*10.0\s*$/

This expression will accept all programs that its output ends with 10.0, allowing spaces, tabs and nl around.

Types of tests checks

Numbers: only numbers are written. Only numbers are checked out, the rest of the text is ignored. The real numbers are checked with tolerance
example:

output = 4
5 6.8


Text: Only words are checked, the comparison is case-insensitive and the other characters are ignored.
example:

output = lemon orange
apple


Exact text: The text is enclosed in double-quotes.
example:

output = "lemon orange
apple"


Regular Expressions: It begins with / and ends with / and optionally one or several modifiers. The format is similar to JavaScript literal, but POSIX regex is used.
example:

output = /lemon|orange|apple/i


Best regards,
Juan Carlos.

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

Re: New Virtual Programming Lab (VPL) module

by Edizon Zacarias -
Dear Juan Carlos,

I have testing this tool and is great,I have a problem that I can't to solve , I Will try to explain it more clear posible.

The documentación says that a case test can do the following:
evaluate inputs and output trought a test case.

Consider the next example of a phyton program that gets two int numbers from console and sum both values and the result is 10

a = int(input("n1:"))
b = int(input("n1:"))
sum = a + b
print(sum)

I put my test case.

case = test1
input = 5
5
output = 10

Here begin my headache.

I supposed if the user input 5 and 5 the result is 10 and was not successfull.
I put the result in a image in this url.


I aprecciate your help for this.


Thanks in advance.
In reply to Edizon Zacarias

Re: New Virtual Programming Lab (VPL) module

by Juan Carlos Rodríguez-del-Pino -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Dear Edizon,
It seems that you missed the answer to your previous question.

The output of the programs to test can be checked in different ways: numbers, text, exact text, and regular expressions.
Notice that the output of your program is "n1:n2:10" and that the terminal mix the output of the program and the chars you write. The checker for output of type numbers thinks that your program want to output the number 1, 2 and 10.
If you want to allow answers that mix text and numbers, it may be better to use a regular expression. e.g.

output = /\s*10.0\s*$/

This expression will accept all programs that its output ends with 10.0, allowing spaces, tabs, and newlines around.

See my previous answer here.

Best regards,
Juan Carlos.
In reply to Juan Carlos Rodríguez-del-Pino

Re: New Virtual Programming Lab (VPL) module

by Edizon Zacarias -

I appreciate your help.

It works, now can I do the test cases correctly.

Thank you so much.

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

Odp: Re: New Virtual Programming Lab (VPL) module

by Tomasz Kargul -

How do I modify the expression /\s*10.0\s*$/ to search for two or more exact numeric values ​​in the text?
For example, the answer to the analysis is:
"The quadratic equation has two roots: x1 = -8.0 and x2 = 0, and the delta is greater than zero"
What should the regular expression look like so that only -8 and 0 are in the answer
Thanks for the hint, I don't know regular expressions and I'm just getting started.


In reply to Tomasz Kargul

Re: Odp: Re: New Virtual Programming Lab (VPL) module

by Juan Carlos Rodríguez-del-Pino -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Dear Tomasz,
I think that instead of trying to learn Regular Expressions for testing a wide range of outputs, it will be better for you to ask the students to use a strict output format. Then you can use a simpler format to check the output. e.g. exact text. You also can use multiple outputs to relax the accepted outputs. e.g.
output = "x1 = -8.0 and x2 = 0
"
output = "x1 = 0 and x2 = -8.0
"
Noice that regular expression allows us to check the existence of a pattern in the output but not the unexistence of patterns.

Best regards,
Juan Carlos.