Changeset 996 for trunk/common


Ignore:
Timestamp:
01/22/09 17:03:58 (3 years ago)
Author:
bogdan2412
Message:

Detailed feedback

  • Moved (and renamed) task parameters "tests", "testgroups", "okfiles" and "evaluator" to ia_task (they will be common to every task type anyway). Only memlimit and timelimit remain in ia_parameter_value for tasks.
  • Added 'public_tests' column to ia_task in which you can specify tests for detailed feedback in the same format as a group in 'test_groups'
  • Added "job-view-partial-feedback" permission. Users should only be able to see their own feedback, not that of others.
  • Added UI for job_detail to show results on public tests
  • Made monitor show when detailed feedback is available for a job

Extra

  • Moved score and size hiding in monitor from view to controller
  • Added "job-view-score" permission check to job_view_source controller

Reviewed: http://reviewboard.infoarena.ro/r/46/

Location:
trunk/common
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/common/db/job.php

    r979 r996  
    358358} 
    359359 
     360// Returns an array of public test informations for a job 
     361function job_test_get_public($job_id) { 
     362    $query = sprintf(" 
     363        SELECT `test_count`, `public_tests` FROM `ia_task` 
     364        WHERE `id` = ( 
     365            SELECT `task_id` FROM `ia_job` 
     366            WHERE `id` = %s 
     367        )", db_quote($job_id)); 
     368 
     369    $task = db_fetch($query); 
     370    log_assert(!is_null($task)); 
     371 
     372    $test_ids = task_parse_test_group($task["public_tests"], $task["test_count"]); 
     373    if (!count($test_ids)) { 
     374        return array(); 
     375    } 
     376 
     377    $query = sprintf(" 
     378        SELECT * FROM `ia_job_test` 
     379        WHERE `job_id` = %s AND `test_number` IN (%s) 
     380        ORDER BY `test_number`", 
     381        db_quote($job_id), 
     382        implode(", ", array_map("db_quote", array_values($test_ids)))); 
     383    return db_fetch_all($query); 
     384} 
     385 
    360386?> 
  • trunk/common/parameter.php

    r852 r996  
    99// $value           raw value string stored in database 
    1010function parameter_decode($parameter_id, $value) { 
    11     $booleans = array('unique_output', 'okfiles', 'rating_update'); 
    12     $ints = array('memlimit', 'tests', 'rating_timestamp'); 
     11    $booleans = array('rating_update'); 
     12    $ints = array('memlimit', 'rating_timestamp'); 
    1313    $floats = array('timelimit'); 
    14     $strings = array('evaluator'); 
     14    $strings = array(); 
    1515 
    1616    if (in_array($parameter_id, $booleans)) { 
  • trunk/common/security.php

    r981 r996  
    159159        case 'job-view-source-size': 
    160160        case 'job-view-score': 
     161        case 'job-view-partial-feedback': 
    161162            return $action; 
    162163 
     
    518519                            $can_view_source; 
    519520    $can_view_score = ($job['round_public_eval'] == true) || $is_task_owner || $is_admin; 
     521    $can_view_partial_feedback = $is_owner || $is_admin; 
    520522 
    521523    // Log query response. 
     
    545547            return $can_view_job && $can_view_score; 
    546548 
     549        case 'job-view-partial-feedback': 
     550            return $can_view_job && $can_view_partial_feedback; 
     551 
    547552        default: 
    548553            log_error('Invalid job action: '.$action); 
  • trunk/common/task.php

    r943 r996  
    1515function task_get_parameter_infos() { 
    1616    return array( 
    17             'classic' => array( 
    18                 'timelimit' => array( 
    19                         'description' => "Limita de timp (in secunde)", 
    20                         'default' => 1, 
    21                         'type' => 'float', 
    22                         'name' => 'Limita de timp', 
    23                 ), 
    24                 'memlimit' => array( 
    25                         'description' => "Limita de memorie (in kilobytes)", 
    26                         'default' => 16384, 
    27                         'type' => 'integer', 
    28                         'name' => 'Limita de memorie', 
    29                 ), 
    30                 'tests' => array( 
    31                         'description' => "Numar de teste", 
    32                         'default' => 10, 
    33                         'type' => 'integer', 
    34                         'name' => "Numar de teste", 
    35                 ), 
    36                 'testgroups' => array( 
    37                         'description' => "Descrierea gruparii testelor.", 
    38                         'default' => '1;2;3;4;5;6;7;8;9;10', 
    39                         'type' => 'string', 
    40                         'name' => "Grupare teste", 
    41  
     17        'classic' => array( 
     18            'timelimit' => array( 
     19                    'description' => "Limita de timp (in secunde)", 
     20                    'default' => 1, 
     21                    'type' => 'float', 
     22                    'name' => 'Limita de timp', 
    4223            ), 
    43             'okfiles' => array( 
    44                     'description' => "Daca evaluator-ul foloseste fisiere .ok", 
    45                     'default' => '0', 
    46                     'type' => 'bool', 
    47                     'name' => "Foloseste .ok", 
     24            'memlimit' => array( 
     25                    'description' => "Limita de memorie (in kilobytes)", 
     26                    'default' => 16384, 
     27                    'type' => 'integer', 
     28                    'name' => 'Limita de memorie', 
    4829            ), 
    49             'evaluator' => array( 
    50                     'description' => "Sursa evaluatorului. Poate fi omis pentru evaluare cu diff", 
    51                     'default' => 'eval.c', 
    52                     'type' => 'string', 
    53                     'name' => "Evaluator", 
    54             ), 
    55     ), 
    56     'output-only' => array( 
    57             'tests' => array( 
    58                     'description' => "Numar de teste", 
    59                     'default' => 10, 
    60                     'type' => 'integer', 
    61                     'name' => "Numar de teste", 
    62             ), 
    63             'testgroups' => array( 
    64                     'description' => "Descrierea gruparii testelor.", 
    65                     'default' => '1;2;3;4;5;6;7;8;9;10', 
    66                     'type' => 'string', 
    67                     'name' => "Grupare teste", 
    68             ), 
    69             'okfiles' => array( 
    70                     'description' => "Daca evaluator-ul foloseste fisiere .ok", 
    71                     'default' => '0', 
    72                     'type' => 'bool', 
    73                     'name' => "Foloseste .ok", 
    74             ), 
    75             'evaluator' => array( 
    76                     'description' => "Sursa evaluatorului. Poate fi omis pentru evaluare cu diff", 
    77                     'default' => 'eval.c', 
    78                     'type' => 'string', 
    79                     'name' => "Evaluator", 
    80             ), 
    81     ), 
    82 ); 
     30        ), 
     31        'output-only' => array( 
     32        ), 
     33    ); 
    8334} 
    8435 
     
    9445            'open_source' => 0, 
    9546            'open_tests' => 0, 
     47            'test_count' => 10, 
     48            'test_groups' => NULL, 
     49            'public_tests' => NULL, 
     50            'evaluator' => NULL, 
     51            'use_ok_files' => 1, 
    9652    ); 
    9753 
     
    153109    } 
    154110 
     111    if (!is_whole_number($task['test_count'])) { 
     112        $errors['test_count'] = "Numarul de teste trebuie sa fie un numar."; 
     113    } else if ($task['test_count'] < 1) { 
     114        $errors['test_count'] = "Minim 1 test."; 
     115    } else if ($task['test_count'] > 100) { 
     116        $errors['test_count'] = "Maxim 100 de teste."; 
     117    } 
     118 
     119    if ($task['use_ok_files'] != '0' && $task['use_ok_files'] != '1') { 
     120        $errors['use_ok_files'] = "0/1 only"; 
     121    } 
     122 
     123    if ($task['evaluator'] == "") { 
     124        if (!$task['use_ok_files']) { 
     125            $errors['evaluator'] = "Pentru evaluare cu diff e nevoie e fisiere .ok"; 
     126        } 
     127    } else { 
     128        if (!is_attachment_name($task['evaluator'])) { 
     129            $errors['evaluator'] = "Nume de fisier invalid."; 
     130        } 
     131    } 
     132 
     133    if (task_get_testgroups($task) === false) { 
     134        $errors['test_groups'] = "Eroare de sintaxa in expresie."; 
     135    } 
     136 
     137    if (task_parse_test_group($task["public_tests"], $task["test_count"]) === false) { 
     138        $errors['public_tests'] = "Eroare de sintaxa in expresie."; 
     139    } 
     140 
    155141    return $errors; 
    156142} 
    157143 
    158 // Parse test grouping expression from task parameters and returns groups as an array 
     144// Parse test grouping expression from task and returns groups as an array 
    159145// If there is no grouping parameter defined it returns a group for each test by default 
    160146// If the expression string contains errors the function returns false 
    161147// Expression syntax: 
    162 // item: number | number-number  
     148// item: number | number-number 
    163149// group: item | item,group 
    164150// groups: group | group;groups 
    165 function task_get_testgroups($parameters) { 
    166     $test_count = $parameters['tests']; 
     151function task_parse_test_group($string, $test_count) { 
     152    if (strlen($string) == 0) 
     153        return array(); 
     154 
     155    $current_group = array(); 
     156    $items = explode(',', $string); 
     157    $used_count = array(); 
     158    for ($test = 1; $test <= $test_count; $test++) { 
     159        $used_count[$test]  = 0; 
     160    } 
     161 
     162    foreach ($items as &$item) { 
     163        $tests = explode('-', $item); 
     164        if (count($tests) < 1 || count($tests) > 2) { 
     165            return false; 
     166        } 
     167        foreach ($tests as &$test) { 
     168            $test = trim($test); 
     169            if (!is_whole_number($test)) { 
     170                return false; 
     171            } 
     172        } 
     173        if (count($tests) == 1) { 
     174            if ($tests[0] < 1 || $tests[0] > $test_count) { 
     175                return false; 
     176            } 
     177            $current_group[] = $tests[0]; 
     178            $used_count[$tests[0]] = 1; 
     179        } else { 
     180            $left = (int) $tests[0]; 
     181            $right = (int) $tests[1]; 
     182            if ($left < 1 || $right < 1 || $left > $test_count || $right > $test_count) { 
     183                return false; 
     184            } 
     185            for ($test = min($left, $right); $test <= max($left, $right); $test++) { 
     186                $current_group[] = $test; 
     187                $used_count[$test]++; 
     188            } 
     189        } 
     190    } 
     191 
     192    for ($test = 1; $test <= $test_count; $test++) { 
     193        if ($used_count[$test] > 1) { 
     194            return false; 
     195        } 
     196    } 
     197 
     198    return $current_group; 
     199} 
     200 
     201function task_get_testgroups($task) { 
     202    $test_count = $task['test_count']; 
    167203    if (!is_whole_number($test_count)) { 
    168204        return false; 
    169205    } 
    170     if (is_null(getattr($parameters, 'testgroups'))) { 
     206    if (!getattr($task, 'test_groups')) { 
    171207        $testgroups = array(); 
    172208        for ($test = 1; $test <= $test_count; $test++) { 
     
    182218    } 
    183219    $testgroups = array(); 
    184     $groups = explode(';', $parameters['testgroups']); 
     220    $groups = explode(';', $task['test_groups']); 
    185221    foreach ($groups as &$group) { 
    186         $current_group = array(); 
    187         $items = explode(',', $group); 
    188         foreach ($items as &$item) { 
    189             $tests = explode('-', $item); 
    190             if (count($tests) < 1 || count($tests) > 2) { 
    191                 return false; 
    192             } 
    193             foreach ($tests as &$test) { 
    194                 $test = trim($test); 
    195                 if (!is_whole_number($test)) { 
    196                     return false; 
    197                 } 
    198             } 
    199             if (count($tests) == 1) { 
    200                 if ($tests[0] < 1 || $tests[0] > $test_count) { 
    201                     return false; 
    202                 } 
    203                 $current_group[] = $tests[0]; 
    204                 $used_count[$tests[0]]++; 
    205             } 
    206             else { 
    207                 $left = (int) $tests[0]; 
    208                 $right = (int) $tests[1]; 
    209                 if ($left < 1 || $right < 1 || $left > $test_count || $right > $test_count) { 
    210                     return false; 
    211                 } 
    212                 for ($test = min($left, $right); $test <= max($left, $right); $test++) { 
    213                     $current_group[] = $test; 
    214                     $used_count[$test]++; 
    215                 } 
    216             } 
     222        $current_group = task_parse_test_group($group, $test_count); 
     223        if (!$current_group) { 
     224            return false; 
     225        } 
     226        foreach ($current_group as $test) { 
     227            $used_count[$test]++; 
    217228        } 
    218229        $testgroups[] = $current_group; 
     
    247258            $errors['memlimit'] = "Maxim 128 megabytes."; 
    248259        } 
    249  
    250         if (!is_whole_number($parameters['tests'])) { 
    251             $errors['tests'] = "Numarul de teste trebuie sa fie un numar."; 
    252         } else if ($parameters['tests'] < 1) { 
    253             $errors['tests'] = "Minim 1 test."; 
    254         } else if ($parameters['tests'] > 100) { 
    255  
    256             $errors['tests'] = "Maxim 100 de teste."; 
    257         } 
    258  
    259         if ($parameters['okfiles'] != '0' && $parameters['okfiles'] != '1') { 
    260             $errors['okfiles'] = "0/1 only"; 
    261         } 
    262  
    263         if ($parameters['evaluator'] == "") { 
    264             if (!$parameters['okfiles']) { 
    265                 $errors['evaluator'] = "Pentru evaluare cu diff e nevoie e fisiere .ok"; 
    266             } 
    267         } else { 
    268             if (!is_attachment_name($parameters['evaluator'])) { 
    269                 $errors['evaluator'] = "Nume de fisier invalid."; 
    270             } 
    271         } 
    272  
    273         if (task_get_testgroups($parameters) === false) { 
    274             $errors['testgroups'] = "Eroare de sintaxa in expresie."; 
    275         } 
    276  
    277260    } else if ($task_type == 'output-only') { 
    278         if ($parameters['okfiles'] != '0' && $parameters['okfiles'] != '1') { 
    279             $errors['okfiles'] = "0/1 only"; 
    280         } 
    281  
    282         if (!is_whole_number($parameters['tests'])) { 
    283             $errors['tests'] = "Numarul de teste trebuie sa fie un numar."; 
    284         } else if ($parameters['tests'] < 1) { 
    285             $errors['tests'] = "Minim 1 test."; 
    286         } else if ($parameters['tests'] > 100) { 
    287             $errors['tests'] = "Maxim 100 de teste."; 
    288         } 
    289  
    290         if ($parameters['evaluator'] == "") { 
    291             if (!$parameters['okfiles']) { 
    292                 $errors['evaluator'] = "Pentru evaluare cu diff e nevoie e fisiere .ok"; 
    293             } 
    294         } else { 
    295             if (!is_attachment_name($parameters['evaluator'])) { 
    296                 $errors['evaluator'] = "Nume de fisier invalid."; 
    297             } 
    298         } 
    299  
    300         if (task_get_testgroups($parameters) === false) { 
    301             $errors['testgroups'] = "Eroare de sintaxa in expresie."; 
    302         } 
     261        // Nothing to validate 
    303262    } else { 
    304263        log_error("Bad task_type"); 
Note: See TracChangeset for help on using the changeset viewer.