# HG changeset patch # User jittat # Date 2008-01-18 14:23:38 # Node ID 7176b8668fee8c8e4cb8a03fe83978ff98d57578 # Parent 8595e5379ca67d9ea7f203ad0ebe5d8c080549a8 git-svn-id: http://theory.cpe.ku.ac.th/grader/cli/trunk/scripts@23 6386c4cd-e34a-4fa8-8920-d93eb39b512e diff --git a/std-script/check b/std-script/check --- a/std-script/check +++ b/std-script/check @@ -48,6 +48,9 @@ puts "YOU HAVE TO EDIT THE CHECKING CODE HERE: #{__FILE__}" exit(127) +# below are codes for checking integer and text + +########### THIS IS FOR CHECKING INTEGER ########## num_pattern = /^[0-9]*/ if (output_file_content =~ num_pattern) == nil report_wrong.call @@ -61,3 +64,21 @@ else report_wrong.call end + +########### THIS IS FOR CHECKING TEXT ########## + +# check visible text + +out_items = output_file_content.split +ans_items = answer_file_content.split + +if out_items.length != ans_items.length + report_wrong.call +else + out_items.length.times do |i| + if out_items[i]!=ans_items[i] + report_wrong.call + end + end + report_correct.call +end