I
I
iceman21122014-12-23 17:12:10
PHP
iceman2112, 2014-12-23 17:12:10

How to make such a site, following the example, a site for programming olympiads?

There is such a site
acmp.ru/index.asp?main=tasks
My task is very similar, to write a web resource for university students to test their programs on computational methods.
Well, i.e. there is a set of tasks on computational methods that students write at our university in the C ++ language, you need to do so that the student sends his cpp file, it is compiled on the server, and tests are run for this program (for example, SLAU is input data is 2 matrices, and the output 1 matrix is ​​the SLAE solution), which would tell if the program is working correctly.
At this stage, I don’t even have an idea in which direction to dig, i.e. Well, yes, I understand that there is a compiler somehow sideways. Can anyone advise what to read, and in which direction to move?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
H
haiku, 2014-12-23
@haiku

Web and non-web languages ​​have functions like Runtime.exec (Java) or some system('some cmd') that can fire something from the shell.
The compiler there is a completely ordinary C ++ shny any to taste, which just twitches from a web application.
string cmd = "/C copy /b Image1.jpg + arara.rar Image2.jpg";
System.Diagnostics.Process.Start("CMD.exe",cmd); // .NET, C#

Z
Zelimkhan Beltoev, 2014-12-23
@Beltoev

Well, if a compiler is installed on the server and PHP is used (by the way, characteristics/parameters were not specified), then the exec() function can be used .
The procedure will be short:
1. Compile the file with the above function (in the parameters we indicate that it is forbidden to use / connect to avoid malicious code)
2.1. If compiled:
Run the compiled program (here you need to decide on the output to analyze the results: redirect the output stream to PHP, or output to a file. Most often, the task condition requires output to the file out.txt, and input - from in.txt. Then there are no special problems)
2.2 If it did not compile:
We issue compiler errors to the user (here it will be necessary to redirect the output of compiler errors to PHP or to a file in the 1st paragraph)
It seems that I didn’t miss anything
UPD: the exec () function can return output results ( php.net/manual/ru/function.exec .php ). Take this into account, the task is simplified =)

I
iceman2112, 2014-12-23
@iceman2112

In, thanks, now the visibility has appeared, but I could not put my mind to it.
But the answer was only in one function - it's exec() php, which I didn't know about))
In general, how else would ready-made libraries be connected, well, supposedly for working with matrices and so on, but I think Beltoev 's train of thought is does not affect.
Thanks)))

V
Vitaly Peretyatko, 2014-12-23
@viperet

The main thing is not to forget about the security of your server, otherwise they are students ... =) Compiling, and even more so running third-party applications, must be done under an unprivileged user, and even better in a chroot environment.

B
bromzh, 2014-12-23
@bromzh

https://ejudge.ru/wiki/index.php/%D0%A1%D0%B8%D1%8...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question