#! /usr/bin/perl

=head1 NAME

myclass - overview of the logged in students class

=head1 SYNOPSIS

 https://server/schulkonsole/myclass

=head1 DESCRIPTION

C<myclass> is the students class page. The HTML template is myclass.tt.

=head2 Template variables

Additionally to the variables of Schulkonsole::Session C<myclass>
provides the following variables:

=over

=cut

use strict;
use utf8;
use lib '/usr/share/schulkonsole';
use Schulkonsole::Session;
use Schulkonsole::Info;
use Schulkonsole::Sophomorix;

my $this_file = 'myclass';


my $sk_session = new Schulkonsole::Session($this_file);
if (not $sk_session->get_password()) {
	my $q = new CGI;
	my $url = $q->url( -full => 1 );

	# we send cookies over secure connections only
	if ($url =~ s/^http:/https:/g) {
		$sk_session->redirect($url);
	} else {
		$sk_session->exit_with_login_page($this_file);
	}
}

my $q = $sk_session->query();


my $classs = Schulkonsole::Info::groups_classes($sk_session->groups());
my $myclass = $sk_session->param('myclass');

if((not $myclass) and $classs){
	my @keys = keys $classs;
	$sk_session->param('myclass',$$classs{$keys[0]});
}

$myclass = $sk_session->param('myclass');

if ($myclass) {

=item C<myclass>

The hash of the users class'

=cut

	$sk_session->set_var('myclass', $myclass);

}

$sk_session->print_page("$this_file.tt", $this_file);


