简体   繁体   English

钩住编译器/钩住方法的输出(C#-C ++)

[英]Hook on compiler / Hook on the output of a method (C# - c++)

Well to start ill tell u what i have to do. 好吧,请告诉我我该怎么办。

I have to make a program so students can upload some C++ code from an exercise. 我必须编写一个程序,以便学生可以从练习中上传一些C ++代码。 And this uploaded code needs to get compared with the "best code" from that exercise. 并且需要将此上传的代码与该练习中的“最佳代码”进行比较。 And from those comparisation the server gives back some feedback if the student uploaded good or bad code. 然后,如果学生上传了正确或错误的代码,服务器会从这些比较中返回一些反馈。 EG: the Exercise is to make an arraylist from 1 to 10 and so the student can upload his code. EG:练习是从1到10创建一个数组列表,以便学生可以上载他的代码。 The server then compares it with some other code and gives feedback. 然后,服务器将其与其他一些代码进行比较并给出反馈。

This is easyer said then done, because it can't be just a file comparer because of the different variables a user can code. 说起来容易做起来容易,因为由于用户可以编码的变量不同,它不能只是文件比较器。 Thats why i was tinking of using external compilers to get some output and compare this output with the output of the "best code". 这就是为什么我想使用外部编译器来获取一些输出并将此输出与“最佳代码”的输出进行比较的原因。 Or more detailed to get a hook within the compiler so i can check every method and every variable. 或更详细的说明,可以在编译器中获取一个钩子,这样我就可以检查每个方法和每个变量。

Or any other idea how i can check this or compare? 或任何其他想法,我怎么可以检查或比较? Or is there already a program that exist? 还是已经存在一个程序?

Very thanks, Michael 非常感谢,迈克尔

There are systems that assess the output of the whole program (like ejudge , it is used as a contest system), and, in my opinion, it's easier to use them, because specifying conditions on the program code is itself not a trivial task (if your students are writing non-trivial programs). 有一些系统可以评估整个程序的输出(例如ejudge ,它被用作竞赛系统),在我看来,使用它们更容易,因为在程序代码上指定条件本身并不是一件容易的事(如果您的学生正在编写非平凡的程序)。 You can use formal specification languages like ACSL to set input and output conditions and prove that the program works correctly. 您可以使用诸如ACSL之类的正式规范语言来设置输入和输出条件,并证明程序可以正常运行。

It might be more practical to evaluate the code by testing the behaviour against some automated tests, like a boundary test suite (or even a mutant test if you want things to get exciting), and then to look for odd implementations or interesting architectures look at code metrics like number of functions, lines of code, compile size, etc. . 这可能是更实际的测试行为对一些自动化测试,如边界测试套件来评估代码(甚至突变试验,如果你想要的东西来获得令人兴奋的),然后寻找奇怪的实现或有趣的架构看代码指标,例如功能数量,代码行,编译大小等。

This approach would be a lot more scalable, and there is a lot of free tools, especially for c++ and java that would be easy to set up an automated test system. 这种方法将具有更大的可扩展性,并且有很多免费工具,尤其是对于c ++和java来说,它们很容易设置自动化测试系统。

Comparing code to determine correctness is not necessarily a correct approach, depending on how it is done, and would be very difficult to scale up. 比较代码以确定正确性并不一定是正确的方法,这取决于如何完成,并且很难扩展。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM