mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-25 16:09:28 +00:00
Basic Structure Automatic Tagging
- new library libTag - new Job TagJob - new entries for automatic tags in config stv.php - automatic tagging of wiederholer and prewiederholer
This commit is contained in:
@@ -139,7 +139,34 @@ $config['stv_prestudent_tags'] = [
|
||||
'hinweis_kf' => ['readonly' => true],
|
||||
'hinweis_lehrende' => ['readonly' => false],
|
||||
'hinweis_stg_kf' => ['readonly' => true],
|
||||
'finished_stg' => ['readonly' => true],
|
||||
'finished_kf' => ['readonly' => true],
|
||||
'inwork_kf' => ['readonly' => true],
|
||||
'finished_stg' => ['readonly' => false],
|
||||
'finished_kf' => ['readonly' => false],
|
||||
'inwork_kf' => ['readonly' => false],
|
||||
'dd_auto' => ['readonly' => false],
|
||||
'wh_auto' => ['readonly' => false],
|
||||
'prewh_auto' => ['readonly' => false],
|
||||
'out_auto' => ['readonly' => false],
|
||||
'zgv_auto' => ['readonly' => false],
|
||||
'wiedereinstieg_auto' => ['readonly' => false],
|
||||
'stbtr_erh_auto' => ['readonly' => false],
|
||||
'beitr_befr_auto' => ['readonly' => false],
|
||||
'jgv_auto' => ['readonly' => false],
|
||||
'nachteilausgl_auto' => ['readonly' => false],
|
||||
];
|
||||
|
||||
//TODO(manu) check ob das besser als param für job übergeben werden soll
|
||||
$config['stv_automatic_tags'] = [
|
||||
'dd_auto',
|
||||
'wh_auto',
|
||||
'out_auto',
|
||||
'prewh_auto',
|
||||
'zgv_auto',
|
||||
'wiedereinstieg_auto',
|
||||
'stbtr_erh_auto',
|
||||
'beitr_befr_auto',
|
||||
'jgv_auto',
|
||||
'nachteilausgl_auto'
|
||||
];
|
||||
|
||||
$config['stv_stgs_to_tag'] = ['254'];
|
||||
|
||||
|
||||
@@ -0,0 +1,236 @@
|
||||
<?php
|
||||
|
||||
if (!defined("BASEPATH")) exit("No direct script access allowed");
|
||||
|
||||
use \DateTime as DateTime;
|
||||
|
||||
class TagJob extends JOB_Controller
|
||||
{
|
||||
|
||||
const BATCHUSER = 'sftest';
|
||||
|
||||
/**
|
||||
* API constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Configs
|
||||
$this->load->config('stv');
|
||||
|
||||
// Library
|
||||
$this->load->library('TagLib');
|
||||
|
||||
// Tag-Helper
|
||||
|
||||
// Load Models
|
||||
$this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
|
||||
|
||||
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
$this->load->model('system/Notiztyp_model', 'NotiztypModel');
|
||||
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
|
||||
|
||||
$this->loadPhrases([
|
||||
'lehre'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test createTags
|
||||
*/
|
||||
public function createAutomatedTagsForPrestudents(...$prestudentIds)
|
||||
{
|
||||
print_r( PHP_EOL . "Start Job create Automated Tags" . PHP_EOL);
|
||||
|
||||
$tag_typ_kurzbz = "wh_auto";
|
||||
$notiz = "TEST AUTOMATED TAG";
|
||||
$zuordnung_typ = "prestudent_id";
|
||||
$count = 0;
|
||||
|
||||
$values = ($prestudentIds != null) ? $prestudentIds : [ 125239, 167955];
|
||||
|
||||
$checkZuordnungType = $this->NotizzuordnungModel->isValidType($zuordnung_typ);
|
||||
if (!isSuccess($checkZuordnungType))
|
||||
return error('Error occurred');
|
||||
|
||||
$values = array_unique($values);
|
||||
|
||||
foreach ($values as $value)
|
||||
{
|
||||
//TODO(uid)
|
||||
$resultInsertNotiz = $this->NotizModel->insert(array(
|
||||
'titel' => 'TAG',
|
||||
'text' => $notiz,
|
||||
'verfasser_uid' => self::BATCHUSER,
|
||||
'erledigt' => false,
|
||||
'insertamum' => date('Y-m-d H:i:s'),
|
||||
'insertvon' => self::BATCHUSER,
|
||||
'typ' => $tag_typ_kurzbz
|
||||
));
|
||||
|
||||
if (isError($resultInsertNotiz))
|
||||
return error ('Error occurred insert Result ' . $value);
|
||||
|
||||
$resultInsertZuordnung = $this->NotizzuordnungModel->insert(array(
|
||||
'notiz_id' => $resultInsertNotiz->retval,
|
||||
$zuordnung_typ => $value
|
||||
));
|
||||
|
||||
print_r( PHP_EOL . "Tag vom Typ " . $tag_typ_kurzbz . " für " . $zuordnung_typ . " " . $value . " erstellt");
|
||||
|
||||
if (isError($resultInsertZuordnung))
|
||||
return error ('Error occurred insert Zuordnung' . $value);
|
||||
|
||||
$count++;
|
||||
}
|
||||
|
||||
print_r( PHP_EOL . "Automatically created Tags: " . $count . PHP_EOL);
|
||||
print_r( PHP_EOL . "End Job create Automated Tags" . PHP_EOL);
|
||||
|
||||
}
|
||||
|
||||
public function createAutomatedTags()
|
||||
{
|
||||
print_r( PHP_EOL . "Start Job create Automated Tags: " . PHP_EOL);
|
||||
|
||||
$automaticTags = $this->config->item('stv_automatic_tags');
|
||||
print_r( implode( ", ", $automaticTags) . PHP_EOL);
|
||||
|
||||
if(in_array('wh_auto', $automaticTags))
|
||||
{
|
||||
print_r(PHP_EOL . "create Tags wiederholer " . PHP_EOL);
|
||||
$result = $this->PrestudentstatusModel-> loadWhere(array(
|
||||
'statusgrund_id' => 16,
|
||||
'studiensemester_kurzbz' => 'SS2026'
|
||||
));
|
||||
$data = $result->retval;
|
||||
$ids = array_map(function($item) {
|
||||
return $item->prestudent_id;
|
||||
}, $data);
|
||||
|
||||
$result = $this->taglib->getAutomatedTags('wh_auto', $ids);
|
||||
if (isError($result))
|
||||
return error ('Error occurred getAutomatedTags');
|
||||
|
||||
$data = $result->retval;
|
||||
|
||||
print_r( PHP_EOL . "Automatically created Tags of Type WIEDERHOLER: " . $data[0] . PHP_EOL);
|
||||
print_r( "prestudents: " . implode( ", ", $data[1]) . PHP_EOL);
|
||||
}
|
||||
|
||||
if(in_array('prewh_auto', $automaticTags))
|
||||
{
|
||||
print_r(PHP_EOL . "create Tags pre-wiederholer " . PHP_EOL);
|
||||
|
||||
$result = $this->PrestudentstatusModel-> loadWhere(array(
|
||||
'statusgrund_id' => 15,
|
||||
'studiensemester_kurzbz' => 'SS2026'
|
||||
));
|
||||
$data = $result->retval;
|
||||
$ids = array_map(function($item) {
|
||||
return $item->prestudent_id;
|
||||
}, $data);
|
||||
|
||||
$result = $this->taglib->getAutomatedTags('prewh_auto', $ids);
|
||||
if (isError($result))
|
||||
return error ('Error occurred getAutomatedTags');
|
||||
|
||||
$data = $result->retval;
|
||||
|
||||
print_r( PHP_EOL . "Automatically created Tags of Type PRE-WIEDERHOLER: " . $data[0] . PHP_EOL);
|
||||
print_r( "prestudents: " . implode( ", ", $data[1]) . PHP_EOL);
|
||||
}
|
||||
|
||||
if(in_array('dd_auto', $automaticTags))
|
||||
{
|
||||
print_r(PHP_EOL . "create Tags double degree" . PHP_EOL);
|
||||
|
||||
|
||||
print_r( PHP_EOL . "Automatically created Tags of Type DOUBLE DEGREE: " . $data[0] . PHP_EOL);
|
||||
print_r( "prestudents: " . implode( ", ", $data[1]) . PHP_EOL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* $tag_typ_kurzbz = "wh_auto";
|
||||
$notiz = "TEST AUTOMATED TAG";
|
||||
$zuordnung_typ = "prestudent_id";
|
||||
$count = 0;
|
||||
|
||||
$values = ($arrayToTag != null) ? $arrayToTag : [ 125239, 167955];
|
||||
|
||||
$checkZuordnungType = $this->NotizzuordnungModel->isValidType($zuordnung_typ);
|
||||
if (!isSuccess($checkZuordnungType))
|
||||
return error('Error occurred');
|
||||
|
||||
$values = array_unique($values);
|
||||
|
||||
foreach ($values as $value)
|
||||
{
|
||||
//TODO(uid)
|
||||
$resultInsertNotiz = $this->NotizModel->insert(array(
|
||||
'titel' => 'TAG',
|
||||
'text' => $notiz,
|
||||
'verfasser_uid' => self::BATCHUSER,
|
||||
'erledigt' => false,
|
||||
'insertamum' => date('Y-m-d H:i:s'),
|
||||
'insertvon' => self::BATCHUSER,
|
||||
'typ' => $tag_typ_kurzbz
|
||||
));
|
||||
|
||||
if (isError($resultInsertNotiz))
|
||||
return error ('Error occurred insert Result ' . $value);
|
||||
|
||||
$resultInsertZuordnung = $this->NotizzuordnungModel->insert(array(
|
||||
'notiz_id' => $resultInsertNotiz->retval,
|
||||
$zuordnung_typ => $value
|
||||
));
|
||||
|
||||
print_r( PHP_EOL . "Tag vom Typ " . $tag_typ_kurzbz . " für " . $zuordnung_typ . " " . $value . " erstellt");
|
||||
|
||||
if (isError($resultInsertZuordnung))
|
||||
return error ('Error occurred insert Zuordnung' . $value);
|
||||
|
||||
$count++;
|
||||
}
|
||||
|
||||
print_r( PHP_EOL . "Automatically created Tags: " . $count . PHP_EOL);*/
|
||||
print_r( PHP_EOL . "End Job create Automated Tags" . PHP_EOL);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* delete All Automatic Tags
|
||||
*/
|
||||
public function deleteAllAutomatedTags()
|
||||
{
|
||||
print_r( PHP_EOL . "Start Job delete ALL Automated Tags" . PHP_EOL);
|
||||
// $this->NotizModel->select('notiz_id');
|
||||
$resultToDelete = $this->NotizModel->loadWhere(array('insertvon' => self::BATCHUSER));
|
||||
|
||||
$data = $resultToDelete->retval;
|
||||
$notiz_ids = array_map(function($item) {
|
||||
return $item->notiz_id;
|
||||
}, $data);
|
||||
|
||||
print_r($notiz_ids);
|
||||
|
||||
foreach ($notiz_ids as $notiz_id)
|
||||
{
|
||||
$result = $this->NotizzuordnungModel->delete([
|
||||
'notiz_id' => $notiz_id
|
||||
]);
|
||||
if (isError($result))
|
||||
return error ('Error occurred delete Notizzuordnung' . $notiz_id);
|
||||
|
||||
$result = $this->NotizModel->delete([
|
||||
'notiz_id' => $notiz_id
|
||||
]);
|
||||
if (isError($result))
|
||||
return error ('Error occurred delete Notiz' . $notiz_id);
|
||||
}
|
||||
print_r( PHP_EOL . "End Job delete Automated Tags" . PHP_EOL);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* FH-Complete
|
||||
*
|
||||
* @package FHC-Helper
|
||||
* @author FHC-Team
|
||||
* @copyright Copyright (c) 2026 fhcomplete.net
|
||||
* @license GPLv3
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DateTime as DateTime;
|
||||
use \stdClass as stdClass;
|
||||
|
||||
class TagLib
|
||||
{
|
||||
const BATCHUSER = 'sftest';
|
||||
const TYP_ZUORDNUNG = 'prestudent_id';
|
||||
/**
|
||||
* Object initialization
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
// Configs
|
||||
$this->_ci->load->config('stv');
|
||||
|
||||
// Models
|
||||
$this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
$this->_ci->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
$this->_ci->load->model('person/Person_model', 'PersonModel');
|
||||
$this->_ci->load->model('person/Notiz_model', 'NotizModel');
|
||||
$this->_ci->load->model('system/Notiztyp_model', 'NotiztypModel');
|
||||
$this->_ci->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
|
||||
|
||||
// Tag-Helper
|
||||
|
||||
|
||||
// Libraries
|
||||
$this->_ci->load->library('PermissionLib');
|
||||
$this->_ci->load->library('PrestudentLib');
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getAutomatedTags($tag, $prestudentIds)
|
||||
{
|
||||
$prestudentIds = array_unique($prestudentIds);
|
||||
$count = 0;
|
||||
$tagged = [];
|
||||
foreach ($prestudentIds as $value)
|
||||
{
|
||||
$resultInsertNotiz = $this->_ci->NotizModel->insert(array(
|
||||
'titel' => 'TAG',
|
||||
'text' => 'AUTOMATED TAG',
|
||||
'verfasser_uid' => self::BATCHUSER,
|
||||
'erledigt' => false,
|
||||
'insertamum' => date('Y-m-d H:i:s'),
|
||||
'insertvon' => self::BATCHUSER,
|
||||
'typ' => $tag
|
||||
));
|
||||
|
||||
if (isError($resultInsertNotiz))
|
||||
return error ('Error occurred insert Result ' . $value);
|
||||
|
||||
$resultInsertZuordnung = $this->_ci->NotizzuordnungModel->insert(array(
|
||||
'notiz_id' => $resultInsertNotiz->retval,
|
||||
self::TYP_ZUORDNUNG => $value
|
||||
));
|
||||
|
||||
if (isError($resultInsertZuordnung))
|
||||
return error ('Error occurred insert Zuordnung' . $value);
|
||||
|
||||
$count++;
|
||||
$tagged[] = $value;
|
||||
}
|
||||
return success([$count, $tagged]);
|
||||
|
||||
}
|
||||
|
||||
public function getAutomatedTagsStudiengang($studiengang_Kzs= null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -75,6 +75,10 @@
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.tag_auto {
|
||||
border: 2px solid #8BCF8A;
|
||||
}
|
||||
|
||||
.display_all {
|
||||
background-color: darkgrey !important;
|
||||
border: none;
|
||||
|
||||
@@ -38,6 +38,9 @@ export function tagFormatter(cell, tagComponent)
|
||||
tagElement.className = "tag " + tag.style;
|
||||
if (tag.done) tagElement.className += " tag_done";
|
||||
|
||||
//TODO automated styling
|
||||
if (tag.automatisiert) tagElement.className += " tag_done";
|
||||
|
||||
tagElement.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user