This commit is contained in:
Ilya Tregubov 2024-08-13 10:43:55 +08:00
commit efaade00b5
3 changed files with 9 additions and 4 deletions

View File

@ -57,9 +57,13 @@ $PAGE->set_url($url);
// If the typ is pagebreak so the item will be saved directly.
if (!$item->id && $typ === 'pagebreak') {
require_sesskey();
feedback_create_pagebreak($feedback->id);
redirect($editurl->out(false));
exit;
$redirectmessage = '';
if (!feedback_create_pagebreak($feedback->id)) {
$redirectmessage = get_string('cannotcreatepagebreak', 'mod_feedback');
}
redirect($editurl, $redirectmessage, null, \core\output\notification::NOTIFY_WARNING);
}
//get the existing item or create it

View File

@ -41,6 +41,7 @@ $string['bold'] = 'Bold';
$string['calendarend'] = '{$a} closes';
$string['calendarstart'] = '{$a} opens';
$string['cannotaccess'] = 'You can only access this feedback from a course';
$string['cannotcreatepagebreak'] = 'Page breaks cannot be added at the beginning of a feedback, and only one page break can be added at the end';
$string['cannotsavetempl'] = 'Saving templates is not allowed';
$string['captcha'] = 'Captcha';
$string['captchanotset'] = 'Captcha hasn\'t been set.';

View File

@ -1972,7 +1972,7 @@ function feedback_delete_completedtmp() {
function feedback_create_pagebreak($feedbackid) {
global $DB;
//check if there already is a pagebreak on the last position
// Disallow pagebreak if there's already one present in last position, or the feedback has no items.
$lastposition = $DB->count_records('feedback_item', array('feedback'=>$feedbackid));
if ($lastposition == feedback_get_last_break_position($feedbackid)) {
return false;