Skip to content

Commit

Permalink
Improvement: Add debug messages, so we can investigate broken downloa…
Browse files Browse the repository at this point in the history
…d (Wunderbyte-GmbH/Wunderbyte-GmbH#283).
  • Loading branch information
ibernhardf committed Dec 17, 2024
1 parent 8c0177f commit 6f70880
Showing 1 changed file with 227 additions and 2 deletions.
229 changes: 227 additions & 2 deletions classes/table/bookingoptions_wbtable.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ class bookingoptions_wbtable extends wunderbyte_table {
*/
public function col_invisibleoption($values) {

// If $values->id is missing, we show the values object in debug mode, so we can investigate what happens.
if (empty($values->id)) {
$debugmessage = "bookingoptions_wbtable function col_invisibleoption: ";
$debugmessage .= "id (optionid) is missing from values object - values: ";
$debugmessage .= json_encode($values);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

$settings = singleton_service::get_instance_of_booking_option_settings($values->id, $values);

if (!empty($settings->invisible)) {
Expand All @@ -90,6 +99,15 @@ public function col_invisibleoption($values) {
*/
public function col_image($values) {

// If $values->id is missing, we show the values object in debug mode, so we can investigate what happens.
if (empty($values->id)) {
$debugmessage = "bookingoptions_wbtable function col_image: ";
$debugmessage .= "id (optionid) is missing from values object - values: ";
$debugmessage .= json_encode($values);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

$settings = singleton_service::get_instance_of_booking_option_settings($values->id, $values);

if (empty($settings->imageurl)) {
Expand All @@ -108,6 +126,16 @@ public function col_image($values) {
* @throws dml_exception
*/
public function col_teacher($values) {

// If $values->id is missing, we show the values object in debug mode, so we can investigate what happens.
if (empty($values->id)) {
$debugmessage = "bookingoptions_wbtable function col_teacher: ";
$debugmessage .= "id (optionid) is missing from values object - values: ";
$debugmessage .= json_encode($values);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

$settings = singleton_service::get_instance_of_booking_option_settings($values->id);
$ret = '';

Expand Down Expand Up @@ -138,6 +166,16 @@ public function col_teacher($values) {
* @throws dml_exception
*/
public function col_responsiblecontact($values) {

// If $values->id is missing, we show the values object in debug mode, so we can investigate what happens.
if (empty($values->id)) {
$debugmessage = "bookingoptions_wbtable function col_responsiblecontact: ";
$debugmessage .= "id (optionid) is missing from values object - values: ";
$debugmessage .= json_encode($values);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

$settings = singleton_service::get_instance_of_booking_option_settings($values->id);
$ret = '';
if (empty($settings->responsiblecontact)) {
Expand Down Expand Up @@ -167,7 +205,14 @@ public function col_responsiblecontact($values) {
*/
public function col_booknow($values) {

global $USER;
// If $values->id is missing, we show the values object in debug mode, so we can investigate what happens.
if (empty($values->id)) {
$debugmessage = "bookingoptions_wbtable function col_booknow: ";
$debugmessage .= "id (optionid) is missing from values object - values: ";
$debugmessage .= json_encode($values);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

// Render col_price using a template.
$settings = singleton_service::get_instance_of_booking_option_settings($values->id, $values);
Expand All @@ -189,6 +234,15 @@ public function col_text($values) {

global $PAGE;

// If $values->id is missing, we show the values object in debug mode, so we can investigate what happens.
if (empty($values->id)) {
$debugmessage = "bookingoptions_wbtable function col_text: ";
$debugmessage .= "id (optionid) is missing from values object - values: ";
$debugmessage .= json_encode($values);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

$title = $values->text;

// If we download, we return the raw title without link or prefix.
Expand All @@ -200,6 +254,16 @@ public function col_text($values) {
// So we always need to retrieve them via singleton service for the current booking option ($values->id).
$optionid = $values->id;
$settings = singleton_service::get_instance_of_booking_option_settings($optionid);

// If $settings->cmid is missing, we show the settings object in debug mode, so we can investigate what happens.
if (empty($settings->cmid)) {
$debugmessage = "bookingoptions_wbtable function col_text: ";
$debugmessage .= "cmid is missing from settings object - settings: ";
$debugmessage .= json_encode($settings);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

$buyforuser = price::return_user_to_buy_for();
$cmid = $settings->cmid;
$booking = singleton_service::get_instance_of_booking_by_cmid($cmid);
Expand Down Expand Up @@ -248,6 +312,16 @@ public function col_text($values) {
* @throws dml_exception
*/
public function col_progressbar($values) {

// If $values->id is missing, we show the values object in debug mode, so we can investigate what happens.
if (empty($values->id)) {
$debugmessage = "bookingoptions_wbtable function col_progressbar: ";
$debugmessage .= "id (optionid) is missing from values object - values: ";
$debugmessage .= json_encode($values);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

// Progress bar showing the consumed quota visually.
$progressbarhtml = '';
if (get_config('booking', 'showprogressbars')) {
Expand All @@ -270,6 +344,15 @@ public function col_progressbar($values) {
*/
public function col_comments($values) {

// If $values->id is missing, we show the values object in debug mode, so we can investigate what happens.
if (empty($values->id)) {
$debugmessage = "bookingoptions_wbtable function col_comments: ";
$debugmessage .= "id (optionid) is missing from values object - values: ";
$debugmessage .= json_encode($values);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

$commentshtml = '';

// NOTE: Do not use $this->cmid and $this->context because it might be that booking options come from different instances!
Expand Down Expand Up @@ -319,10 +402,29 @@ public function col_comments($values) {
public function col_ratings($values) {
global $DB, $USER;

// If $values->id is missing, we show the values object in debug mode, so we can investigate what happens.
if (empty($values->id)) {
$debugmessage = "bookingoptions_wbtable function col_ratings: ";
$debugmessage .= "id (optionid) is missing from values object - values: ";
$debugmessage .= json_encode($values);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

// NOTE: Do not use $this->cmid and $this->context because it might be that booking options come from different instances!
// So we always need to retrieve them via singleton service for the current booking option ($values->id).
$optionid = $values->id;
$settings = singleton_service::get_instance_of_booking_option_settings($optionid);

// If $settings->cmid is missing, we show the settings object in debug mode, so we can investigate what happens.
if (empty($settings->cmid)) {
$debugmessage = "bookingoptions_wbtable function col_ratings: ";
$debugmessage .= "cmid is missing from settings object - settings: ";
$debugmessage .= json_encode($settings);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

$cmid = $settings->cmid;
$bookingsettings = singleton_service::get_instance_of_booking_settings_by_cmid($cmid);

Expand Down Expand Up @@ -401,6 +503,16 @@ public function col_ratings($values) {
* @throws coding_exception
*/
public function col_bookings($values) {

// If $values->id is missing, we show the values object in debug mode, so we can investigate what happens.
if (empty($values->id)) {
$debugmessage = "bookingoptions_wbtable function col_bookings: ";
$debugmessage .= "id (optionid) is missing from values object - values: ";
$debugmessage .= json_encode($values);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

$output = singleton_service::get_renderer('mod_booking');

$settings = singleton_service::get_instance_of_booking_option_settings($values->id, $values);
Expand Down Expand Up @@ -438,6 +550,15 @@ public function col_bookings($values) {
*/
public function col_location($values) {

// If $values->id is missing, we show the values object in debug mode, so we can investigate what happens.
if (empty($values->id)) {
$debugmessage = "bookingoptions_wbtable function col_location: ";
$debugmessage .= "id (optionid) is missing from values object - values: ";
$debugmessage .= json_encode($values);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

$settings = singleton_service::get_instance_of_booking_option_settings($values->id, $values);

if (isset($settings->entity) && (count($settings->entity) > 0)) {
Expand Down Expand Up @@ -474,6 +595,15 @@ public function col_location($values) {
*/
public function col_institution($values) {

// If $values->id is missing, we show the values object in debug mode, so we can investigate what happens.
if (empty($values->id)) {
$debugmessage = "bookingoptions_wbtable function col_institution: ";
$debugmessage .= "id (optionid) is missing from values object - values: ";
$debugmessage .= json_encode($values);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

$settings = singleton_service::get_instance_of_booking_option_settings($values->id, $values);
return $settings->institution;
}
Expand All @@ -489,6 +619,15 @@ public function col_institution($values) {
public function col_course($values) {
global $USER;

// If $values->id is missing, we show the values object in debug mode, so we can investigate what happens.
if (empty($values->id)) {
$debugmessage = "bookingoptions_wbtable function col_course: ";
$debugmessage .= "id (optionid) is missing from values object - values: ";
$debugmessage .= json_encode($values);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

$settings = singleton_service::get_instance_of_booking_option_settings($values->id, $values);

$ret = '';
Expand Down Expand Up @@ -555,6 +694,16 @@ public function col_course($values) {
* @throws coding_exception
*/
public function col_dayofweektime($values) {

// If $values->id is missing, we show the values object in debug mode, so we can investigate what happens.
if (empty($values->id)) {
$debugmessage = "bookingoptions_wbtable function col_dayofweektime: ";
$debugmessage .= "id (optionid) is missing from values object - values: ";
$debugmessage .= json_encode($values);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

$ret = '';
$settings = singleton_service::get_instance_of_booking_option_settings($values->id, $values);
if (!empty($settings->dayofweektime)) {
Expand All @@ -573,10 +722,29 @@ public function col_dayofweektime($values) {
*/
public function col_showdates($values) {

// If $values->id is missing, we show the values object in debug mode, so we can investigate what happens.
if (empty($values->id)) {
$debugmessage = "bookingoptions_wbtable function col_showdates: ";
$debugmessage .= "id (optionid) is missing from values object - values: ";
$debugmessage .= json_encode($values);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

// NOTE: Do not use $this->cmid and $this->context because it might be that booking options come from different instances!
// So we always need to retrieve them via singleton service for the current booking option ($values->id).
$optionid = $values->id;
$settings = singleton_service::get_instance_of_booking_option_settings($optionid);

// If $settings->cmid is missing, we show the settings object in debug mode, so we can investigate what happens.
if (empty($settings->cmid)) {
$debugmessage = "bookingoptions_wbtable function col_showdates: ";
$debugmessage .= "cmid is missing from settings object - settings: ";
$debugmessage .= json_encode($settings);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

$cmid = $settings->cmid;
$booking = singleton_service::get_instance_of_booking_by_cmid($cmid);

Expand Down Expand Up @@ -663,10 +831,29 @@ public function col_manageresponses($values) {
public function col_action($values) {
global $OUTPUT, $USER;

// If $values->id is missing, we show the values object in debug mode, so we can investigate what happens.
if (empty($values->id)) {
$debugmessage = "bookingoptions_wbtable function col_action: ";
$debugmessage .= "id (optionid) is missing from values object - values: ";
$debugmessage .= json_encode($values);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

// NOTE: Do not use $this->cmid and $this->context because it might be that booking options come from different instances!
// So we always need to retrieve them via singleton service for the current booking option ($values->id).
$optionid = $values->id;
$settings = singleton_service::get_instance_of_booking_option_settings($optionid);

// If $settings->cmid is missing, we show the settings object in debug mode, so we can investigate what happens.
if (empty($settings->cmid)) {
$debugmessage = "bookingoptions_wbtable function col_action: ";
$debugmessage .= "cmid is missing from settings object - settings: ";
$debugmessage .= json_encode($settings);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

$cmid = $settings->cmid;
$booking = singleton_service::get_instance_of_booking_by_cmid($cmid);
$context = context_module::instance($cmid);
Expand Down Expand Up @@ -945,12 +1132,31 @@ public function col_minanswers($values) {
* @throws coding_exception
*/
public function col_statusdescription($values) {
$ret = '';

// If $values->id is missing, we show the values object in debug mode, so we can investigate what happens.
if (empty($values->id)) {
$debugmessage = "bookingoptions_wbtable function col_statusdescription: ";
$debugmessage .= "id (optionid) is missing from values object - values: ";
$debugmessage .= json_encode($values);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

$ret = '';
// NOTE: Do not use $this->cmid and $this->context because it might be that booking options come from different instances!
// So we always need to retrieve them via singleton service for the current booking option ($values->id).
$optionid = $values->id;
$settings = singleton_service::get_instance_of_booking_option_settings($optionid);

// If $settings->cmid is missing, we show the settings object in debug mode, so we can investigate what happens.
if (empty($settings->cmid)) {
$debugmessage = "bookingoptions_wbtable function col_statusdescription: ";
$debugmessage .= "cmid is missing from settings object - settings: ";
$debugmessage .= json_encode($settings);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

$cmid = $settings->cmid;
$bookingoption = singleton_service::get_instance_of_booking_option($cmid, $optionid);
$bookinganswers = singleton_service::get_instance_of_booking_answers($settings);
Expand All @@ -972,6 +1178,15 @@ public function col_statusdescription($values) {
*/
public function col_description($values) {

// If $values->id is missing, we show the values object in debug mode, so we can investigate what happens.
if (empty($values->id)) {
$debugmessage = "bookingoptions_wbtable function col_description: ";
$debugmessage .= "id (optionid) is missing from values object - values: ";
$debugmessage .= json_encode($values);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

$description = $values->description;

// If we download, we want to show text only without HTML tags.
Expand Down Expand Up @@ -1077,6 +1292,16 @@ public function col_bookingclosingtime($values) {
* @throws coding_exception
*/
public function col_attachment($values) {

// If $values->id is missing, we show the values object in debug mode, so we can investigate what happens.
if (empty($values->id)) {
$debugmessage = "bookingoptions_wbtable function col_attachment: ";
$debugmessage .= "id (optionid) is missing from values object - values: ";
$debugmessage .= json_encode($values);
debugging($debugmessage, DEBUG_DEVELOPER);
return '';
}

return booking_option::render_attachments($values->id, 'mod-booking-option-attachments mb-2');
}
}

0 comments on commit 6f70880

Please sign in to comment.