Archived
1
0

Can add grades to project

This commit is contained in:
Mercier Pierre-Olivier 2013-09-08 20:00:12 +02:00
parent 706c10a2bb
commit 2b5d936c8e
2 changed files with 110 additions and 0 deletions

86
ACU/API/Projects.pm Normal file
View File

@ -0,0 +1,86 @@
#! /usr/bin/env perl
package API::Projects;
use v5.10.1;
use strict;
use warnings;
use ACU::API::Base;
sub add($)
{
my $project_name = shift;
my $res = API::Base::send('ResultHandler', "projects/projects/add.xml", [ project_name => $project_name ]);
if ($res->{result} eq '0') {
say "Projet ajouté correctement";
}
else {
say "Ajout non ok: ".$res->{message};
}
}
sub get($;$)
{
my $project_name = shift;
my $year = shift;
my $res = API::Base::get('ProjectMemberHandler', "projects/projects/get/$project_name.xml");
if ($res->{result} && $res->{result} eq '0') {
say "Projet ajouté correctement";
}
else {
say "Ajout non ok: ".$res->{message};
}
return $res;
}
sub get_users($;$)
{
my $project_name = shift;
my $year = shift;
my $url;
if ($year) {
$url = "projects/projects/users/$project_name/$year.xml";
}
else {
$url = "projects/projects/users/$project_name.xml";
}
my $res = API::Base::get('ProjectMemberHandler', $url);
if ($res->{result} && $res->{result} eq '0') {
say "Projet ajouté correctement";
}
else {
say "Ajout non ok: ".$res->{message};
}
return $res;
}
sub add_grades($;$)
{
my %data;
$data{project_name} = $project_name if (my $project_name = shift);
$data{year} = $year if (my $year = shift);
my $res = API::Base::send('ResultHandler', "projects/notes/add.xml", \%data);
if ($res->{result} && $res->{result} eq '0') {
say "Ajout de notes effectué.";
}
else {
say "Ajout non ok: ".$res->{message};
}
return $res;
}
1;

View File

@ -0,0 +1,24 @@
#! /usr/bin/env perl
use v5.10.1;
use strict;
use warnings;
use lib "../";
use ACU::API::Base;
use ACU::API::Projects;
if ($#ARGV == 0)
{
API::Projects::add_grades($ARGV[0]);
}
elsif ($#ARGV == 1)
{
API::Projects::add_grades($ARGV[0], $ARGV[1]);
}
else
{
say "$0 <project_id> [project_year]";
}