Archived
1
0

Fix grading generation from defenses

This commit is contained in:
Mercier Pierre-Olivier 2013-09-22 15:10:32 +02:00
parent 39758b9e4b
commit 59aff8677a
5 changed files with 36 additions and 28 deletions

View File

@ -79,7 +79,7 @@ sub add_grades($;$)
); );
$data{year} = $_ if (shift); $data{year} = $_ if (shift);
my $res = API::Base::get('ResultHandler', "projects/groups/generate.xml"); my $res = API::Base::send('ResultHandler', "projects/notes/add.xml", \%data);
if ($res->{result} ne '0') { if ($res->{result} ne '0') {
croak "Erreur durant l'ajout : " . $res->{message}; croak "Erreur durant l'ajout : " . $res->{message};

View File

@ -116,12 +116,12 @@ sub getIds ($)
for my $answer (@{ $question->{answers} }) for my $answer (@{ $question->{answers} })
{ {
$ids{ $answer->{id} } = $answer->{value} if ($answer->{id}); $ids{ $answer->{id} } = $answer->{value} // 0 if ($answer->{id});
} }
} }
} }
return %ids; return \%ids;
} }
sub genIds ($) sub genIds ($)
@ -216,9 +216,12 @@ sub parseQuestions($@)
for my $question (@_) for my $question (@_)
{ {
my $expl;
$expl = @{ $question->getElementsByTagName("explanation") }[0]->textContent if $question->getElementsByTagName("explanation");
my $q = Defense::Question->new( my $q = Defense::Question->new(
@{ $question->getElementsByTagName("ask") }[0]->textContent, @{ $question->getElementsByTagName("ask") }[0]->textContent,
@{ $question->getElementsByTagName("explanation") }[0]->textContent // "", $expl // "",
$question->getAttribute("id"), $question->getAttribute("id"),
$question->getAttribute("title"), $question->getAttribute("title"),
$question->getAttribute("type"), $question->getAttribute("type"),

View File

@ -44,9 +44,11 @@ sub create_from_trace ($$)
my $g = Grade->new($trace_id, $trace_name); my $g = Grade->new($trace_id, $trace_name);
for my $id (sort( keys %{ $trace->{ids} } )) my $ids = $trace->getIds();
for my $id (sort( keys %{ $ids } ))
{ {
my $p = Point->new($trace->{ids}{$id}, $id, 0, 0); my $p = Point->new($ids->{$id}, $id, 0, 0);
push @{ $g->{tree} }, $p; push @{ $g->{tree} }, $p;
} }
@ -117,7 +119,7 @@ sub fill ($$)
} }
} }
sub to_string ($) sub toString ($)
{ {
my $self = shift; my $self = shift;
@ -133,7 +135,7 @@ sub to_string ($)
} }
for my $grade (@{ $self->{tree} }) { for my $grade (@{ $self->{tree} }) {
$grade->to_string($doc, $root, $root); $grade->toString($doc, $root, $root);
} }
$doc->setDocumentElement( $root ); $doc->setDocumentElement( $root );
@ -195,7 +197,7 @@ sub new ($$$;$$)
return bless $self; return bless $self;
} }
sub to_string ($$$) sub toString ($$$)
{ {
my $self = shift; my $self = shift;
my $doc = shift; my $doc = shift;
@ -209,7 +211,7 @@ sub to_string ($$$)
$parent->appendChild($grade); $parent->appendChild($grade);
for my $item (@{ $self->{tree} }) { for my $item (@{ $self->{tree} }) {
$item->to_string($doc, $grade); $item->toString($doc, $grade);
} }
} }
@ -296,7 +298,7 @@ sub new ($$$$$)
return bless $self; return bless $self;
} }
sub to_string ($$$) sub toString ($$$)
{ {
my $self = shift; my $self = shift;
my $doc = shift; my $doc = shift;

View File

@ -41,8 +41,11 @@ do {
open $xml, "<", $file or die $!; open $xml, "<", $file or die $!;
binmode $xml; binmode $xml;
my $str;
$str .= $_ while (<$xml>);
eval { eval {
$trace = Defense->new($xml); $trace = Defense->new($str);
}; };
if ($@) { if ($@) {
log ERROR, "Unknown file type: $file"; log ERROR, "Unknown file type: $file";
@ -55,4 +58,4 @@ do {
} while ($#ARGV >= 0); } while ($#ARGV >= 0);
print $grade->to_string(); print $grade->toString();

View File

@ -1401,7 +1401,7 @@ sub cmd_ssh_keys_without_passphrase_warn(@)
print $entry->get_value("uid")."\n"; print $entry->get_value("uid")."\n";
# create the message # create the message
use Mail::Internet; #use Mail::Internet;
my $body = "Bonjour ".$entry->get_value("cn").", my $body = "Bonjour ".$entry->get_value("cn").",
@ -1429,13 +1429,13 @@ PS: Ce message est g
-- --
Les roots ACU"; Les roots ACU";
my $email = Mail::Internet->new(); #my $email = Mail::Internet->new();
$email->body($body); #$email->body($body);
$email->add( "To", $entry->get_value("mailAlias") ); #$email->add( "To", $entry->get_value("mailAlias") );
$email->add( "Cc", "<root\@acu.epita.fr>" ); #$email->add( "Cc", "<root\@acu.epita.fr>" );
$email->add( "From", "Roots assistants <admin\@acu.epita.fr>" ); #$email->add( "From", "Roots assistants <admin\@acu.epita.fr>" );
$email->add( "Subject", "[LAB][SSH-PASSPHRASE] Clef SSH non protégée" ); #$email->add( "Subject", "[LAB][SSH-PASSPHRASE] Clef SSH non protégée" );
$email->send(); #$email->send();
}; };
cmd_ssh_keys_without_passphrase_generic(\&$process); cmd_ssh_keys_without_passphrase_generic(\&$process);
@ -1485,13 +1485,13 @@ PS: Ce message est g
-- --
Les roots ACU"; Les roots ACU";
my $email = Mail::Internet->new(); #my $email = Mail::Internet->new();
$email->body($body); #$email->body($body);
$email->add( "To", $entry->get_value("mailAlias") ); #$email->add( "To", $entry->get_value("mailAlias") );
$email->add( "Cc", "<root\@acu.epita.fr>" ); #$email->add( "Cc", "<root\@acu.epita.fr>" );
$email->add( "From", "Roots assistants <admin\@acu.epita.fr>" ); #$email->add( "From", "Roots assistants <admin\@acu.epita.fr>" );
$email->add( "Subject", "[LAB][SSH-PASSPHRASE] Clef SSH non protégée supprimée" ); #$email->add( "Subject", "[LAB][SSH-PASSPHRASE] Clef SSH non protégée supprimée" );
$email->send(); #$email->send();
}; };
cmd_ssh_keys_without_passphrase_generic(\&$process); cmd_ssh_keys_without_passphrase_generic(\&$process);