NAME

Gruntmaster::Data - Gruntmaster 6000 Online Judge -- database interface and tools

SYNOPSIS

for my $problem (problems) {
  say "Problem name: " . problem_name $problem;
  say "Problem level: " . problem_level $problem;
  ...
}

DESCRIPTION

Gruntmaster::Data is the Redis interface used by the Gruntmaster 6000 Online Judge. It exports many functions for talking to the database. All functions are exported by default.

The current contest is selected by setting the $Gruntmaster::Data::contest variable.

local $Gruntmaster::Data::contest = 'mycontest';
say 'There are' . jobcard . ' jobs in my contest';

FUNCTIONS

Redis

Gruntmaster::Data exports some functions for talking directly to the Redis server. These functions should not normally be used, except for MULTI, EXEC, PUBLISH, SUBSCRIBE and WAIT_FOR_MESSAGES.

These functions correspond to Redis commands. The current list is: MULTI EXEC SMEMBERS GET HGET HGETALL HDEL HSET SADD SREM INCR HMSET HSETNX DEL PUBLISH SUBSCRIBE WAIT_FOR_MESSAGES.

Problems

problems

Returns a list of problems in the current contest.

problem_meta $problem

Returns a problem's meta.

set_problem_meta $problem, $meta

Sets a problem's meta.

problem_name $problem

Returns a problem's name.

set_problem_name $problem, $name

Sets a problem's name.

problem_level $problem

Returns a problem's level. The levels are beginner, easy, medium, hard.

set_problem_level $problem, $level

Sets a problem's level. The levels are beginner, easy, medium, hard.

problem_difficulty $problem

Returns a problem's difficulty.

set_problem_difficulty $problem, $name

Sets a problem's difficulty.

problem_statement $problem

Returns a problem's statement.

set_problem_statement $problem, $statement

Sets a problem's statement.

problem_owner $problem

Returns a problem's owner.

set_problem_owner $problem, $owner

Sets a problem's owner.

problem_author $problem

Returns a problem's author.

set_problem_author $problem, $author

Sets a problem's author.

problem_private $problem

Returns a problem's private flag (true if the problem is private, false otherwise).

set_problem_private $problem, $private

Sets a problem's private flag.

problem_generator $problem

Returns a problem's generator. The generators are File, Run and Undef. More might be added in the future.

set_problem_generator $problem, $generator

Sets a problem's generator.

problem_runner $problem

Returns a problem's runner. The runners are File, Verifier and Interactive. More might be added in the future.

set_problem_runner $problem, $runner

Sets a problem's runner.

problem_judge $problem

Returns a problem's judge. The judges are Absolute and Points. More might be added in the future.

set_problem_judge $problem, $judge

Sets a problem's judge.

problem_testcnt $problem

Returns a problem's test count.

set_problem_testcnt $problem, $testcnt

Sets a problem's test count.

problem_timeout $problem

Returns a problem's time limit, in seconds.

set_problem_timeout $problem, $timeout

Sets a problem's time limit, in seconds.

problem_olimit $problem

Returns a problem's output limit, in bytes.

set_problem_olimit $problem, $olimit

Sets a problem's output limit, in bytes.

get_open $problem, $user

Returns the time when $user opened $problem.

mark_open $problem, $user

Sets the time when $user opened $problem to the current time. Does nothing if $user has already opened $problem.

insert_problem $id, $key => $value, ...

Inserts a problem with id $id and the given initial configuration. Does nothing if a problem with id $id already exists. Returns true if the problem was added, false otherwise.

edit_problem $id, $key => $value, ...

Updates the configuration of a problem. The values of the given keys are updated. All other keys/values are left intact.

remove_problem $id

Removes a problem.

Contests

WARNING: these functions only work correctly when $Gruntmaster::Data::contest is undef

contests

Returns a list of contests.

contest_start $contest

Returns a contest's start time.

set_contest_start $contest, $start

Sets a contest's start time.

contest_end $contest

Returns a contest's end time.

set_contest_end $contest, $end

Sets a contest's end time.

contest_name $contest

Returns a contest's name.

set_contest_name $contest, $name

Sets a contest's name.

contest_owner $contest

Returns a contest's owner.

set_contest_owner $contest, $owner

Sets a contest's owner.

insert_contest $id, $key => $value, ...

Inserts a contest with id $id and the given initial configuration. Does nothing if a contest with id $id already exists. Returns true if the contest was added, false otherwise.

edit_contest $id, $key => $value, ...

Updates the configuration of a contest. The values of the given keys are updated. All other keys/values are left intact.

remove_contest $id

Removes a contest.

Jobs

jobcard

Returns the number of jobs in the database.

job_results $job

Returns an array of job results. Each element corresponds to a test and is a hashref with keys id (test number), result (result code, see Gruntmaster::Daemon::Constants), result_text (result description) and time (time taken).

set_job_results $job, $results

Sets a job's results.

job_inmeta $job

Returns a job's meta.

set_job_inmeta $job, $meta

Sets a job's meta.

job_daemon $job

Returns the hostname:pid of the daemon which ran this job.

set_job_daemon $job, $hostname_and_pid

If the job has no associated daemon, it sets the daemon and returns true. Otherwise it returns false without setting the daemon.

job_date $job

Returns a job's submit date.

set_job_date $job, $date

Sets a job's submit date.

job_errors $job

Returns a job's compile errors.

set_job_errors $job, $errors

Sets a job's compile errors.

job_extension $job

Returns a job's file name extension (e.g. "cpp", "pl", "java").

set_job_extension $job, $extension

Sets a job's file name extension.

job_filesize $job

Returns a job's source file size, in bytes.

set_job_filesize $job, $filesize

Sets a job's source file size, in bytes.

job_private $job

Returns the value of a job's private flag.

set_job_private $job, $private

Sets the value of a job's private flag.

job_problem $job

Returns a job's problem.

set_job_problem $job, $problem

Sets a job's problem.

job_result $job

Returns a job's result code. Possible result codes are described in Gruntmaster::Daemon::Constants

set_job_result $job, $result

Sets a job's result code.

job_result_text $job

Returns a job's result text.

set_job_result_text $job, $result_text

Sets a job's result text.

job_user $job

Returns the user who submitted a job.

set_job_user $job, $user

Sets the suer who submitted a job.

clean_job $job

Removes a job's daemon, result code, result text and result array.

push_job $key => $value, ...

Inserts a job with a given initial configuration. Returns the id of the newly-added job.

edit_job $id, $key => $value, ...

Updates the configuration of a job. The values of the given keys are updated. All other keys/values are left intact.

remove_job $id

Removes a job.

Users

WARNING: these functions only work correctly when $Gruntmaster::Data::contest is undef

users

Returns a list of users.

user_name $user

Returns a user's full name.

set_user_name $user, $name

Sets a user's full name.

user_email $user

Returns a user's email address.

set_user_email $user, $email

Sets a user's email address.

user_lastjob $user

Returns the time (seconds since epoch) when the user last submitted a solution.

set_user_lastjob $user, $lastjob

Sets the time (seconds since epoch) when the user last submitted a solution.

user_town $user

Returns a user's town.

set_user_town $user, $town

Sets a user's town.

user_university $user

Returns a user's university/highschool/place of work/etc.

set_user_university $user, $university

Sets a user's university, highschool/place of work/etc.

user_level $user

Returns a user's current level of study. One of 'Highschool', 'Undergraduate', 'Master', 'Doctorate' or 'Other'.

set_user_level $user, $level

Sets a user's current level of study.

insert_user $id, $key => $value, ...

Inserts a user with id $id and the given initial configuration. Does nothing if a user with id $id already exists. Returns true if the user was added, false otherwise.

edit_user $id, $key => $value, ...

Updates the configuration of a user. The values of the given keys are updated. All other keys/values are left intact.

remove_user $id

Removes a user.

AUTHOR

Marius Gavrilescu <marius@ieval.ro>

COPYRIGHT AND LICENSE

Copyright (C) 2014 by Marius Gavrilescu

This library is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.