| … | |
… | |
| 111 | $self->assignProblemToUser($user, $problemRecord); |
111 | $self->assignProblemToUser($user, $problemRecord); |
| 112 | } |
112 | } |
| 113 | } |
113 | } |
| 114 | } |
114 | } |
| 115 | |
115 | |
|
|
116 | sub read_dir { # read a directory |
|
|
117 | my $self = shift; |
|
|
118 | my $directory = shift; |
|
|
119 | my $pattern = shift; |
|
|
120 | my @files = grep /$pattern/, WeBWorK::Utils::readDirectory($directory); |
|
|
121 | return sort @files; |
|
|
122 | } |
|
|
123 | |
|
|
124 | sub read_scoring_file { # used in SendMail and ....? |
|
|
125 | my $self = shift; |
|
|
126 | my $fileName = shift; |
|
|
127 | my $delimiter = shift; |
|
|
128 | $delimiter = ',' unless defined($delimiter); |
|
|
129 | my $scoringDirectory= $self->{ce}->{courseDirs}->{scoring}; |
|
|
130 | my $filePath = "$scoringDirectory/$fileName"; |
|
|
131 | # Takes a delimited file as a parameter and returns an |
|
|
132 | # associative array with the first field as the key. |
|
|
133 | # Blank lines are skipped. White space is removed |
|
|
134 | my(@dbArray,$key,$dbString); |
|
|
135 | my %assocArray = (); |
|
|
136 | local(*FILE); |
|
|
137 | if ($fileName eq 'None') { |
|
|
138 | # do nothing |
|
|
139 | } elsif ( open(FILE, "$filePath") ) { |
|
|
140 | my $index=0; |
|
|
141 | while (<FILE>){ |
|
|
142 | unless ($_ =~ /\S/) {next;} ## skip blank lines |
|
|
143 | chomp; |
|
|
144 | @{$dbArray[$index]} =$self->getRecord($_,$delimiter); |
|
|
145 | $key =$dbArray[$index][0]; |
|
|
146 | $assocArray{$key}=$dbArray[$index]; |
|
|
147 | $index++; |
|
|
148 | } |
|
|
149 | close(FILE); |
|
|
150 | } else { |
|
|
151 | warn "Couldn't read file $filePath"; |
|
|
152 | } |
|
|
153 | return \%assocArray; |
|
|
154 | } |
| 116 | ## Template Escapes ## |
155 | ## Template Escapes ## |
| 117 | |
156 | |
| 118 | sub links { |
157 | sub links { |
| 119 | my $self = shift; |
158 | my $self = shift; |
| 120 | # FIXME these links are being placed in ContentGenerator.pm |
159 | # FIXME these links are being placed in ContentGenerator.pm |