- my @schedule = get_schedule(@_);
- open(STDOUT, ">>" . $file) if(defined($file) && (! -d $file));
- open(STDOUT, ">/dev/null") if(defined($file) && (-d $file));
- print "BEGIN:VCALENDAR\r\nVERSION:1.0\r\n";
- foreach my $row (@schedule) {
- map { s/\n/-/g; $_} %$row;
- $row->{'instructor'} =~ s/^([^,]*), ([^,]*)/$2 $1/;
- $row->{'days'} =~ s/([MTWRFS])/ $days{$1}/g;
- $row->{'days'} =~ s/^ //;
- #$row->{'duration'} =~ s/(\d\d)-(\d\d)-(\d\d)/20$3$1$2/g;
- my @day = (off_for_holidays(%$row),off_for_exams(%$row));
- my $day = "";
- if(exists($day[0])) {
- $day = join(";", @day);
- $day =~ s/\b(\d{8})\b/$1T000000/g;
- }
- my ($starttime, $stoptime)=($row->{'begin'}, $row->{'end'});
- my ($startdate, $stopdate)=split(/-/, $row->{'duration'});
- $starttime =~ s/://;
- $stoptime =~ s/://;
- if(defined($file) && (-d $file)) {
- open FH, ">$file/" . $row->{'id'} . ".vcs" or die "$!";
- select FH;
- print "BEGIN:VCALENDAR\r\nVERSION:1.0\r\n";
- }
- print "BEGIN:VEVENT\r\n";
- print "SUMMARY:", $row->{'title'}, "\r\n";
- print "DESCRIPTION:", $row->{'id'}, "\r\n";
- print "LOCATION:", $row->{'location'}, "\r\n";
- print "CATEGORIES:Education\r\n";
- print "DTSTART:", $startdate."T".$starttime, "00\r\n";
- print "DTEND:", $startdate."T".$stoptime, "00\r\n";
- print "RRULE:W1 ", $row->{'days'} . " $stopdate", "T000000\r\n";
- print("EXDATE:$day\r\n") if($day);
- print "ATTENDEE;ROLE=OWNER;STATUS=CONFIRMED:", $opts{'name'}, "\r\n" if(defined($opts{'name'}));
- print "ATTENDEE;ROLE=ORGANIZER;STATUS=CONFIRMED:", $row->{'instructor'}, " <" . (get_faculty_email($row->{'instructor'}) || "fake\@ddress"), ">\r\n";
- print "END:VEVENT\r\n";
- if(defined($file) && (-d $file)) {
- print "END:VCALENDAR\r\n";
- close FH;
- select STDOUT;
- }
- }
- print "END:VCALENDAR\r\n";
-}
-
-sub do_html_schedule {
- my @showheaders = ("Section ID/Title", "Instructor", "Days", "Time", "Duration", "Location");
- my $shade = "dark";
- my @schedule = get_schedule(@_);
- print '<table id="schedule" cellpadding="3" cellspacing="0">'."\n<tr><th>";
- print join("</th><th>",@showheaders);
- print "</th></tr>\n";
- foreach my $row (@schedule) {
- map { s/\n/<br \/>/g; $_} %$row;
- $row->{'time'} =~ s/-/-<wbr \/>/;
- $row->{'duration'} =~ s/\d\d(\d\d)(\d\d)(\d\d)/$2-$3-$1/g;
- print '<tr class="'.$shade.'">';
- $shade = ($shade eq "dark"?"light":"dark");
- print '<td class="idtitle">';
- print '<span class="sectionid">' .$row->{'id'}. '</span><br />';
- print '<span class="coursetitle">' .$row->{'title'}. '</span></td>';
- my $instructor = $row->{'instructor'};
- $instructor =~ s/^([^,]*), ([^,]*)(.*)/$2 $1$3/;
- my $email = get_faculty_email($instructor);
- #if($email) {
- #print '<td><a href="mailto:' . $email . '">'
- #. $row->{'instructor'} . "</a></td>";
- # } else {
- print "<td>" . $row->{'instructor'} . "</td>";
- #}
- print "<td>" . $row->{'days'} . "</td>";
- print "<td>" . $row->{'time'} . "</td>";
- print "<td>" . $row->{'duration'} . "</td>";
- print "<td>" . $row->{'location'} . "</td>";
- print "</tr>\n";
- }
- print "</table>\n";
-}
-
-sub do_html_grades {
- my @readheaders = ("Section ID", "Course Title", "Grade", "Earned Hours", "Quality Hours", "Quality Points", "GPA");
- @readheaders = ("Section", "Course Title", "FinalGrade", "Earned Hours", "Quality Hours", "Quality Points", "GPA") if($opts{'school'} eq 'tamuk');
- my @showheaders = ("Section ID", "Course Title", "Grade", "Earned<br />Hours", "Quality<br />Hours", "Quality<br />Points");
- my ($row, $lastrow);
- my $shade = "dark";
- my $te = new HTML::TableExtract( headers => [ @readheaders ] );
- my $response = $ua->get("$url&tserve_tip_write=||WID|SID|PIN|Term&tserve_trans_config=rgrdterm.cfg"); # Valid grading terms
- die $response->status_line unless $response->is_success;
- #my @terms = reverse grep {s/^<option value="([^"]*)">.*/$1/} (split( /\r\n/, $response->content));
- my @terms = ();
- my $year = Date::Calc->localtime->year;
- for(my $y=$year-4;$y<=$year;$y++) { push @terms, ($y.2,$y."F",$y.3,$y.4,$y.1,$y."S"); }
- foreach(@_ ? @_ : @terms) {
- $response = $ua->get("$url&tserve_tip_write=||WID|SID|PIN|Term&tserve_trans_config=rgrades.cfg&Term=".($_) );
- die $response->status_line unless $response->is_success;
- $te->parse($response->content);
- }
- print '<table id="grades" cellpadding="3" cellspacing="0">'."\n<tr>";
- print '<th align="left" class="sectionid">', $showheaders[0];
- print '</th><th align="left" class="coursetitle">', $showheaders[1];
- print '</th><th align="center" class="grade">';
- print join('</th><th align="center" class="right-number">',@showheaders[2 .. 5]);
- print "</th></tr>\n";
- foreach my $ts ($te->table_states) {
- foreach my $row ($ts->rows) {
- map { s/^\s+//; s/\xa0|\r//g; s/\n/<br \/>/g; $_} @$row;
- $row->[1] = capitalize($row->[1]);
- $row->[1] =~ s/&/&/g;
- $row->[0] =~ s/Cumulative through/Cumulative: through/;
- $row->[0] =~ s/Cumulative:(.*) (\d{4}) (.*)/Cumulative:$1 $3 $2/;
- $lastrow=$row;
- next if $row->[0] =~ /:|Current Term/;
- print '<tr class="'.$shade.'">';
- $shade = ($shade eq "dark"?"light":"dark");
- print '<td align="left" class="sectionid">', $$row[0], '</td>';
- print '<td align="left" class="coursetitle">', $$row[1], '</td>';
- print '<td align="center" class="grade">';
- #print join('</td><td>', @$row[0 .. 1]);
- print join('</td><td align="right" class="right-number">', @$row[2 .. 5]);
- print "</td></tr>\n";
- }