Substitute.diff

Jérôme O., 12/02/2018 01:06 pm

Download (2.2 kB)

 
Substitute.pm 2017-09-28 23:14:17.151404727 +0200
22 22

  
23 23
use AMC::Basic;
24 24

  
25
use utf8;
26

  
25 27
sub new {
26 28
    my (%o)=@_;
27 29
    my $self={'names'=>'',
......
48 50
  return($mark);
49 51
}
50 52

  
53
# Affiche le niveau acquis pour chaque compétence entrée comme groupe
54
# <30%: non maîtrisé - <70%: maîtrise incomplète - <100%: maîtrise satisfaisante - =100%: maîtrise experte
55
sub format_skills {
56
  my ($self,$student,$copy)=@_;
57
  my $sth = $self->{scoring}->statement('studentSkillLevel');
58
  $sth->execute($student, $copy);
59
  my $stext = "\t\t\t\t\t\t\t\t\t";
60
  while(my @row=$sth->fetchrow_array) { # retrieve one row
61
    if (scalar(split '',$stext) > 6) {$stext = $stext . "\n\t";}
62
    $stext = $stext . @row[0] . " : ";
63
    if (@row[1]>0.9) {
64
      $stext = $stext . "maîtrise experte 😄";
65
    } elsif (@row[1]>0.5) {
66
      $stext = $stext . "maîtrise satisfaisante 😊";
67
    } elsif (@row[1]>0) {
68
      $stext = $stext . "maîtrise incomplète 😕";
69
    } else {
70
      $stext = $stext . "non maîtrisé 😟";
71
    }
72
  }
73
  return($stext);
74
}
75

  
76
# Affiche les pourcentages de réussite par groupe, arrondi à l'entier, le minimum étant fixé à zéro
77
sub format_knowledge {
78
  my ($self,$student,$copy)=@_;
79
  my $sth = $self->{scoring}->statement('studentSkillLevel');
80
  $sth->execute($student, $copy);
81
  my $stext = "\n";
82
  while(my @row=$sth->fetchrow_array) { # retrieve one row
83
    if (scalar(split '',$stext) > 6) {$stext = $stext . "  —  ";}
84
    my $knowledge=int(@row[1]*100+.5);
85
    $stext = $stext . @row[0] . " : " . (0, $knowledge)[$knowledge>0] . " %";
86
  }
87
  return($stext);
88
}
89

  
51 90
sub substitute {
52 91
  my ($self,$text,$student,$copy)=@_;
53 92

  
......
59 98
      $text =~ s/\%[M]/$self->format_note($student_mark->{'max'})/ge;
60 99
      $text =~ s/\%[s]/$self->format_note($student_mark->{'mark'})/ge;
61 100
      $text =~ s/\%[m]/$self->format_note($self->{'scoring'}->variable('mark_max'))/ge;
101
      $text =~ s/\%[C]/$self->format_skills($student, $copy)/ge;
102
      $text =~ s/\%[c]/$self->format_knowledge($student, $copy)/ge;
62 103
    } else {
63 104
      debug "No marks found ! Copy=".studentids_string($student,$copy);
64 105
    }