Archived
1
0
Fork 0

Add grades tag

This commit is contained in:
Mercier Pierre-Olivier 2013-09-21 15:59:46 +02:00
parent b34f3db750
commit f4ce8c79e0

View file

@ -211,7 +211,93 @@ sub tag_document
sub tag_grades
{
my $creation = shift;
# From here, we have:
# 1: "defense"
# 2: $version
# 3: $id
# 4: $year
my $version = $_[2] // 1;
my $project_id = repository_name();
if ($_[3]) {
$project_id .= "-" . $_[3];
}
$project_id = lc $project_id;
$project_id =~ s/[^a-z0-9-_]/_/g;
my $year;
if ($_[4]) {
# Check on year
if ($_[4] !~ /^\d+$/) {
log ERROR, "project:*:* second argument is the year. Tag format: project:id:year";
}
$year = $_[4];
}
else {
$year = LDAP::get_year;
}
# Determine full tag
my $long_tag;
{
my $proj_id = $_[3] // "";
$long_tag = "grades,$version,$proj_id,$year";
}
if ($creation)
{
my $newref = $ARGV[2];
# Check file exists
my $content = qx(git show $newref:grades/grades.xml);
if ($?) {
log ERROR, "Impossible de trouver le fichier de notation.";
}
# Check DTD validity
if (check_xml(\$content, "http://acu.epita.fr/dtd/grading.dtd")) {
log ERROR, "Corrigez les erreurs du fichier grades.xml avant de lancer la génération des notes.";
}
# TODO: check user permissions
# Send data to intradata
log INFO, "Attente d'un processus de publication...";
if (my $err = Process::Client::launch("intradata_get", { action => "generate", type => "grades", id => $project_id, "year" => $year, "version" => $version }, { "grading.xml" => $content }))
{
if (${ $err } ne "Ok") {
log ERROR, "Erreur durant le processus de publication : " . ${ $err };
}
}
if ($long_tag)
{
qx(git tag -f $long_tag);
if (! $?) {
log INFO, "Tag long créé : $long_tag.";
}
}
}
else
{
# Is the long tag existing
qx(git tag | egrep "^$long_tag\$");
if ($?) {
log ERROR, "Tag long correspondant introuvable : $long_tag.";
}
if ($long_tag)
{
qx(git tag -d $long_tag);
if (! $?) {
log INFO, "Tag long supprimé : $long_tag.";
}
}
}
}
sub tag_project