<commit_before><?php
// -*- web -*-
require '../common.php';

use DsvSu\Daisy;
use DsvSu\Daisy\Semester;

$en = (isset($_GET['lang']) && $_GET['lang'] === 'en');
$lang = $en ? 'en' : 'sv';
$conf = parse_ini_file('../semesters.conf');

$start = Semester::parse($conf['start']);
$end = Semester::parse($conf['end']);
$semester = Semester::parse($conf['current']);

if (isset($_GET['term'])) {
    try {
        $semester = Semester::parse($_GET['term']);
    } catch (DomainException $e) {
        // keep default value
    }
}

$csis = Daisy\CourseSegmentInstance::find([
    'department' => 4,
    'semester' => $semester
]);
$c = new Collator('sv_SE');

usort($csis, function ($a, $b) use ($c) {
    return $c->compare($a->getName(), $b->getName());
});

$schedule_icon = getCurrentUrlDir() . '/img/date-time.png';

function semesters($start, $end)
{
    for ($s = $start; $s != $end; $s = $s->getNext()) {
        yield $s;
    }
    yield $end;
}
?>
<form class="csi-term-chooser">
  <p>
    <label>
      <?= $en ? 'Term:' : 'Termin:' ?>
      <select name="term" onchange="$(this.form).submit()">
        <?php foreach (semesters($start, $end) as $s): ?>
          <option value="<?=$semester?>"
                  <?= $s == $semester ? ' selected' : ''?>
                  ><?=$s?></option>
        <?php endforeach; ?>
      </select>
    </label>
  </p>
</form>
<table class="course_units_table">
  <col class="cut_name">
  <col class="cut_timetable"><commit_msg>don't use current semester as value<commit_after><?php
// -*- web -*-
require '../common.php';

use DsvSu\Daisy;
use DsvSu\Daisy\Semester;

$en = (isset($_GET['lang']) && $_GET['lang'] === 'en');
$lang = $en ? 'en' : 'sv';
$conf = parse_ini_file('../semesters.conf');

$start = Semester::parse($conf['start']);
$end = Semester::parse($conf['end']);
$semester = Semester::parse($conf['current']);

if (isset($_GET['term'])) {
    try {
        $semester = Semester::parse($_GET['term']);
    } catch (DomainException $e) {
        // keep default value
    }
}

$csis = Daisy\CourseSegmentInstance::find([
    'department' => 4,
    'semester' => $semester
]);
$c = new Collator('sv_SE');

usort($csis, function ($a, $b) use ($c) {
    return $c->compare($a->getName(), $b->getName());
});

$schedule_icon = getCurrentUrlDir() . '/img/date-time.png';

function semesters($start, $end)
{
    for ($s = $start; $s != $end; $s = $s->getNext()) {
        yield $s;
    }
    yield $end;
}
?>
<form class="csi-term-chooser">
  <p>
    <label>
      <?= $en ? 'Term:' : 'Termin:' ?>
      <select name="term" onchange="$(this.form).submit()">
        <?php foreach (semesters($start, $end) as $s): ?>
          <option value="<?=$s?>"
                  <?= $s == $semester ? ' selected' : ''?>
                  ><?=$s?></option>
        <?php endforeach; ?>
      </select>
    </label>
  </p>
</form>
<table class="course_units_table">
  <col class="cut_name">
  <col class="cut_timetable">
{'fraction_non_alphanumeric': 0.24534686971235195, 'fraction_numerical': 0.0006768189509306261, 'mean_word_length': 3.1284916201117317, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1750976', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1058, 'n_words': 212}