Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions classes/local/table/remaining_courses_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ class remaining_courses_table extends \table_sql {

private evasys_category $evasyscategory;

private bool $showbuttons;

/**
* Constructor for course_manager_table.
*/
public function __construct($categoryids, $semester, evasys_category $evasyscategory, $coursefullname = null) {
public function __construct($categoryids, $semester, evasys_category $evasyscategory, $coursefullname = null, bool $showbuttons = true) {
parent::__construct('block_evasys_sync-course_manager_table');
global $DB, $PAGE, $OUTPUT;

$this->evasyscategory = $evasyscategory;
$this->showbuttons = $showbuttons;

$fields = 'c.id as courseid, c.fullname as coursename, cfd.intvalue as semester';

Expand Down Expand Up @@ -134,7 +137,7 @@ public function col_teacher($row) {
*/
public function col_tools($row) {
global $PAGE, $OUTPUT;
if (!$this->evasyscategory->default_period_set()) {
if (!$this->evasyscategory->default_period_set() || !$this->showbuttons) {
return '';
}
return $OUTPUT->render(new \single_button(new moodle_url($PAGE->url, ['action' => 'seteval', 'ids[]' => $row->courseid]),
Expand All @@ -155,7 +158,7 @@ public function wrap_html_finish() {
parent::wrap_html_finish();
echo "<br>";

if (!$this->evasyscategory->default_period_set()) {
if (!$this->evasyscategory->default_period_set() || !$this->showbuttons) {
return;
}

Expand Down
2 changes: 2 additions & 0 deletions lang/de/block_evasys_sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,5 @@
$string['missing_course_id'] = 'Fehlende Kurs-ID! Bitte wenden Sie sich an den Learnweb Support mit einem Link zu der Veranstaltung im HIS LSF, die evaluiert werden soll.';
$string['no_evasys_course_found'] = 'Kein passender EvaSys-Kurs gefunden! Bitte wenden Sie sich an Ihren Evaluationskoordinator.';
$string['not_inside_evaluation_category'] = 'Dieser Kurs ist in keiner Evaluationskategorie! Bitte wenden Sie sich an den Learnweb Support.';

$string['previous_process_still_active'] = 'Diese Kurskategorie wird derzeit bereits bearbeitet. Bitte versuchen Sie es in Kürze erneut!';
2 changes: 2 additions & 0 deletions lang/en/block_evasys_sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,5 @@
$string['missing_course_id'] = 'Missing course id! Please contact the Learnweb support with a link to the course in HIS LSF which should be evaluated.';
$string['no_evasys_course_found'] = 'No matching EvaSys-Course found! Please contact your evaluation coordinator.';
$string['not_inside_evaluation_category'] = 'This course isn\'t inside any evaluation category! Please contact the Learnweb support.';

$string['previous_process_still_active'] = 'This course category is already being processed. Please try again shortly!';
19 changes: 18 additions & 1 deletion managecategory_remaining.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,18 @@

$data = $cache->get($cachekey);

$lockname = 'block_evasys_sync_process_category';
$resource = 'evasyscat:' . $evasyscategory->get('id');
$lockfactory = \core\lock\lock_config::get_lock_factory($lockname);
$lock = $lockfactory->get_lock($resource, 0);

$action = optional_param('action', null, PARAM_ALPHAEXT);
if ($action === 'seteval') {
if (!$lock) {
throw new coding_exception(get_string('previous_process_still_active', 'block_evasys_sync'));
}
require_sesskey();
core_php_time_limit::raise();
$courses = required_param_array('ids', PARAM_INT);
$errors = \block_evasys_sync\evaluation_manager::set_default_evaluation_for($courses, $evasyscategory);
if ($errors) {
Expand All @@ -58,9 +67,16 @@
}
\core\notification::error($erroroutput);
}
$lock->release();
redirect($PAGE->url);
}

if ($lock) {
$lock->release();
} else{
\core\notification::warning(get_string('previous_process_still_active', 'block_evasys_sync'));
}

$field = $DB->get_record('customfield_field', array('shortname' => 'semester', 'type' => 'semester'), '*', MUST_EXIST);
$fieldcontroller = \core_customfield\field_controller::create($field->id);
$datacontroller = \core_customfield\data_controller::create(0, null, $fieldcontroller);
Expand All @@ -72,7 +88,8 @@

$catids = array_merge($category->get_all_children_ids(), [$category->id]);

$table = new remaining_courses_table($catids, $data->semester ?? null, $evasyscategory, $data->coursename ?? null);
$table = new remaining_courses_table($catids, $data->semester ?? null, $evasyscategory,
$data->coursename ?? null, (bool) $lock);
$table->define_baseurl($PAGE->url);

$PAGE->navigation->add('EvaSys', new moodle_url('/blocks/evasys_sync/manageroverview.php'))
Expand Down