From c9e7079af719e324a1ea983c2bf842f13b1b4d98 Mon Sep 17 00:00:00 2001 From: anoack <noack@data-quest.de> Date: Thu, 24 Aug 2023 16:26:05 +0200 Subject: [PATCH] user core function getStartWeeks --- controllers/copy.php | 5 ++-- views/copy/semester_start_und_ende.php | 36 ++++++++++++-------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/controllers/copy.php b/controllers/copy.php index c8fdac2..dd966a7 100755 --- a/controllers/copy.php +++ b/controllers/copy.php @@ -25,7 +25,7 @@ class CopyController extends PluginController } if (count(Request::getArray("c")) == 1) { $this->single_course = Course::find(current(Request::getArray("c"))); - $this->single_course_name = $course->name; + $this->single_course_name = $this->single_course; } } else { throw new Trails_Exception(400); @@ -223,6 +223,7 @@ class CopyController extends PluginController if (Request::get("cycles")) { + $last_week = count($semester->getStartWeeks()) - 1; foreach ($oldcourse->cycles as $cycledate) { $statement = DBManager::get()->prepare(" @@ -244,7 +245,7 @@ class CopyController extends PluginController $newcycle->setId($newcycle->getNewId()); $newcycle['seminar_id'] = $newcourse->getId(); $newcycle['week_offset'] = Request::int("week_offset"); - $newcycle['end_offset'] = Request::int("end_offset"); + $newcycle['end_offset'] = Request::get('end_offset') == 'last' ? $last_week : Request::int("end_offset"); $newcycle['mkdate'] = time(); $newcycle['chdate'] = time(); $newcycle->store(); diff --git a/views/copy/semester_start_und_ende.php b/views/copy/semester_start_und_ende.php index 1044aaf..22a78a7 100755 --- a/views/copy/semester_start_und_ende.php +++ b/views/copy/semester_start_und_ende.php @@ -1,33 +1,31 @@ +<?php +$start_weeks = $semester->getStartWeeks(); +$last_week = count($start_weeks) - 1; +?> <label> <?= _("Startwoche") ?> <select name="week_offset"> - <? $i = 0 ?> - <? while ($semester['vorles_beginn'] + 43200 + 86400 * 7 * $i < $semester['vorles_ende']) : ?> + <? foreach ($start_weeks as $i => $text) : ?> <option value="<?= $i ?>"<?= UserConfig::get($GLOBALS['user']->id)->COURSECOPY_SETTINGS_WEEK_OFFSET == $i ? " checked" : "" ?>> - <? - $timestamp = $semester['vorles_beginn'] + 43200 + 86400 * 7 * $i; - $timestamp = $timestamp - ((date("w", $timestamp) - 1) % 7) * 86400; - ?> - <?= sprintf(_("%s. Semesterwoche (ab %s)"), $i + 1, date("d.m.Y", $timestamp)) ?> + <?= $text?> </option> - <? $i++ ?> - <? endwhile ?> + <? endforeach; ?> </select> </label> <label> <?= _("Endwoche") ?> <select name="end_offset"> - <? $i = floor(($semester['vorles_ende'] - $semester['vorles_beginn']) / (86400 * 7)) - 1 ?> - <? while ($i >= 0) : ?> - <option value="<?= $i ?>"<?= UserConfig::get($GLOBALS['user']->id)->COURSECOPY_SETTINGS_END_OFFSET == $i ? " checked" : "" ?>> - <? - $timestamp = $semester['vorles_beginn'] + 43200 + 86400 * 7 * $i; - $timestamp = $timestamp - ((date("w", $timestamp) - 1) % 7) * 86400; - ?> - <?= sprintf(_("%s. Semesterwoche (ab %s)"), $i + 1, date("d.m.Y", $timestamp)) ?> + <? foreach (array_reverse($start_weeks, true) as $i => $text) : ?> + <? if ($i == $last_week) : ?> + <option value="last"> + <?= _('Semesterende: ') . $text?> </option> - <? $i-- ?> - <? endwhile ?> + <? else : ?> + <option value="<?= $i ?>"<?= UserConfig::get($GLOBALS['user']->id)->COURSECOPY_SETTINGS_END_OFFSET == $i ? " checked" : "" ?>> + <?= $text?> + </option> + <? endif ?> + <? endforeach ?> </select> </label> -- GitLab