Changeset 1115 for trunk/common


Ignore:
Timestamp:
03/20/10 16:49:35 (2 years ago)
Author:
victorsb
Message:

Wrote a script to add a \n to all grader test files that
currently don't end with one and modified the attachment
code to auto-check for \n at upload time.

REVIEW URL http://reviewboard.infoarena.ro/r/139/

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/common/attachment.php

    r1018 r1115  
    118118} 
    119119 
     120function is_grader_testfile($file_name) { 
     121    $pattern = '/^grader_test(\d)*\.(ok|in)$/'; 
     122    if (preg_match($pattern, $file_name) == false) { 
     123        return false; 
     124    } else { 
     125        return true; 
     126    } 
     127} 
     128 
     129function is_problem_page($page_name) { 
     130    $pattern = '/^problema\/' . IA_RE_TASK_ID . '$/'; 
     131    if (preg_match($pattern, $page_name) == false) { 
     132        return false; 
     133    } else { 
     134        return true; 
     135    } 
     136} 
     137 
     138function add_ending_newline($file_path) { 
     139    $content = file_get_contents($file_path); 
     140    if ($content[strlen($content) - 1] != "\n") { 
     141        $content .= "\n"; 
     142        file_put_contents($file_path, $content); 
     143        return true; 
     144    } 
     145    return false; 
     146} 
     147 
    120148?> 
Note: See TracChangeset for help on using the changeset viewer.