WIP Gesamtnoteneingabe Notenberechnung endpoint

This commit is contained in:
Johann Hoffmann
2025-05-12 12:50:56 +02:00
parent 7030d5b822
commit 5bbf05ac8a
15 changed files with 1134 additions and 3 deletions
@@ -31,10 +31,15 @@ class Lehre extends FHCAPI_Controller
'lvStudentenMail' => self::PERM_LOGGED,
'LV' => self::PERM_LOGGED,
'Pruefungen' => self::PERM_LOGGED,
'getLvViewData' => self::PERM_LOGGED,
'getZugewieseneLv' => self::PERM_LOGGED
]);
// Loads phrases system
$this->loadPhrases([
'global'
]);
}
//------------------------------------------------------------------------------------------------------------------
@@ -94,6 +99,36 @@ class Lehre extends FHCAPI_Controller
$this->terminateWithSuccess($result);
}
/**
* fetches all assigned lehrveranstaltungen of a mitarbeiter for a given semester
* @param mixed $uid
* @param mixed $sem_kurzbz
* @return void
*/
public function getZugewieseneLv() {
$uid = $this->input->get("uid",TRUE);
$sem_kurzbz = $this->input->get("sem_kurzbz",TRUE);
if(!isset($sem_kurzbz) || isEmptyString($sem_kurzbz))
$this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general');
if (!isset($uid) || isEmptyString($uid))
$uid = getAuthUID();
// querying other ma_uids data requires admin permission
if($uid !== getAuthUID()) {
$this->load->library('PermissionLib');
$isAdmin = $this->permissionlib->isBerechtigt('admin');
if(!$isAdmin) $this->terminateWithError($this->p->t('ui', 'keineBerechtigung'), 'general');
}
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
$result = $this->LehrveranstaltungModel->getLvForLektorInSemester($sem_kurzbz, $uid);
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
@@ -0,0 +1,94 @@
<?php
/**
* Copyright (C) 2024 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
require_once(__DIR__.'/../../../../../include/lehreinheit.class.php');
require_once(__DIR__.'/../../../../../include/legesamtnote.class.php');
class Noten extends FHCAPI_Controller
{
/**
* Object initialization
*/
public function __construct()
{
parent::__construct([
'getStudentenNoten' => self::PERM_LOGGED, // todo: berechtigung
'getNoten' => self::PERM_LOGGED,
'saveStudentenNoten' => self::PERM_LOGGED // todo: berechtigungen!
]);
$this->load->library('AuthLib', null, 'AuthLib');
// Loads phrases system
$this->loadPhrases([
'global'
]);
}
public function getStudentenNoten() {
$lv_id = $this->input->get("lv_id",TRUE);
$sem_kurzbz = $this->input->get("sem_kurzbz",TRUE);
$active = true; // todo: check this param
if (!isset($lv_id) || isEmptyString($lv_id)
|| !isset($sem_kurzbz) || isEmptyString($sem_kurzbz))
$this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general');
// todo: check various other berechtigungen if its mitarbeiter/lektor/zugeteilterLektor?
$this->load->model('education/Pruefung_model', 'PruefungModel');
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
// get studenten for lva & sem with zeugnisnote if available
$studenten = $this->LehrveranstaltungModel->getStudentsByLv($sem_kurzbz, $lv_id, $active);
$studentenData = $this->getDataOrTerminateWithError($studenten);
// get all prüfungen with noten held in that semester in that lva
$pruefungen = $this->PruefungModel->getPruefungenByLvStudiensemester($lv_id, $sem_kurzbz);
$pruefungenData = $this->getDataOrTerminateWithError($pruefungen);
$this->terminateWithSuccess(array($studentenData, $pruefungenData, DOMAIN));
}
public function getNoten() {
$this->load->model('education/Note_model', 'NoteModel');
$result = $this->NoteModel->getAll();
$noten = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($noten);
}
public function saveStudentenNoten() {
$result = $this->getPostJSON();
if(!property_exists($result, 'password')) {
$this->terminateWithError($this->p->t('global', 'missingParameters'), 'general');
}
// TODO: send & save noten
$this.$this->terminateWithSuccess($this->AuthLib->checkUserAuthByUsernamePassword(getAuthUID(), $result->password));
}
}
@@ -0,0 +1,67 @@
<?php
/**
* Copyright (C) 2024 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
class Studiensemester extends FHCAPI_Controller
{
private $_ci;
/**
* Object initialization
*/
public function __construct()
{
parent::__construct([
'getStudiensemester'=> self::PERM_LOGGED,
]);
$this->_ci =& get_instance();
$this->_ci->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* GET METHOD
* returns List of all studiensemester as well as current one
*/
public function getStudiensemester()
{
$this->_ci->StudiensemesterModel->addOrder("start", "DESC");
$result = $this->_ci->StudiensemesterModel->load();
$studiensemester = getData($result);
$result = $this->_ci->StudiensemesterModel->getAkt();
$aktuell = getData($result);
$this->terminateWithSuccess(array($studiensemester, $aktuell));
}
//------------------------------------------------------------------------------------------------------------------
// Private methods
}