Loading htdocs/collection/edit.php +10 −6 Original line number Diff line number Diff line Loading @@ -99,7 +99,11 @@ if ($copy) { } else { $type = 'submitcancel'; if ($new) { if ($collection->get('group') && is_outcomes_group($collection->get('group'))) { $submitstr = array('button' => get_string('save'), 'cancel' => get_string('cancel')); $confirm = array('cancel' => get_string('confirmcancelcreatingcollection','collection')); } else if ($new) { $submitstr = array('button' => get_string('next') . ': ' . get_string('editviews', 'collection'), 'cancel' => get_string('cancel')); $confirm = array('cancel' => get_string('confirmcancelcreatingcollection','collection')); } Loading Loading @@ -268,7 +272,7 @@ function collectionedit_submit(Pieform $form, $values) { } $values['coverimage'] = (isset($values['coverimage']) ? $values['coverimage'] : null); $groupid = $collection->get('group'); $values['outcomeportfolio'] = (int)($groupid && is_outcomes_group($groupid)); $values['outcomeportfolio'] = (int)($groupid && is_outcomes_group($groupid) && $values['outcomeportfolio']); $collection = Collection::save($values); if (isset($values['progresscompletion'])) { Loading htdocs/collection/manageoutcomes.php +40 −7 Original line number Diff line number Diff line Loading @@ -56,6 +56,26 @@ $strings= get_outcome_lang_strings(); $js = <<< EOJS {$strings} jQuery(function($) { /** * Prevent short title input element to submit form on 'enter' krey pressed */ function removeSubmitOnEnter() { $("#outcome_forms input[name='short_title']").on('keypress', function(e){ if (e.keyCode == 13) { e.preventDefault(); e.stopPropagation(); } }) } /** * Set maxlength attribute on textareas */ function setMaxlength() { $("textarea").attr('maxlength', 255); } /* * Validate short_title field not empty */ Loading Loading @@ -107,7 +127,7 @@ jQuery(function($) { data.push({ "short_title": short_title, "full_title": full_title, "outcome_type": outcome_type, "outcome_type": outcome_type || '', "id": id, }); }); Loading @@ -117,9 +137,15 @@ jQuery(function($) { }, "POST", function(data) { formchangemanager.reset(); const id = new URL(location.href).searchParams.get('id'); window.location.href= config.wwwroot + 'collection/outcomesoverview.php?id=' + id; if (data) { $("#messages div").html(data); } }, function(error) { $("#messages")[0].scrollIntoView(true); } ); } Loading @@ -141,6 +167,9 @@ jQuery(function($) { function (data) { if (data.html) { $("#outcome_forms").append(data.html); $("#outcome_forms .requiredmarkerdesc").remove(); removeSubmitOnEnter(); setMaxlength(); $("#outcome_forms .delete-outcome a").last().on("click", removeForms); $("#outcome_buttons_container")[0].scrollIntoView({block: "end"}); } Loading @@ -153,7 +182,7 @@ jQuery(function($) { */ function deleteOutcome(e) { e.preventDefault(); const deleteform = $(e.target).parent().parent(); const deleteform = $(e.target).closest('div'); const outcomeform = deleteform.next(); // get hidden db id const id = outcomeform.find(`input[name="id"]`).val(); Loading Loading @@ -198,7 +227,11 @@ jQuery(function($) { $("#submit_save").on("click", saveOutcomesForm); $("#add_outcome").on("click", addOutcomeForm); $(".delete-outcome a").on("click", deleteOutcome); $("#outcome_forms .requiredmarkerdesc").remove(); removeSubmitOnEnter(); // Somehow maxlength is not being set on the textareas // need to add it using jquery setMaxlength(); }); EOJS; $cancelredirecturl = get_config('wwwroot') . 'view/groupviews.php?group=' . $collection->get('group'); Loading htdocs/collection/views.php +3 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,9 @@ $collection = new Collection($id); if (!$USER->can_edit_collection($collection)) { throw new AccessDeniedException(get_string('canteditcollection', 'collection')); } if ($collection->get('outcomeportfolio')) { throw new AccessDeniedException(get_string('canteditcollection', 'collection')); } $sesskey = $USER->get('sesskey'); $inlinejs = ''; if ($accesschanged = $SESSION->get('pageaccesschanged')) { Loading htdocs/group/edit.php +12 −4 Original line number Diff line number Diff line Loading @@ -557,12 +557,20 @@ function editgroup_validate(Pieform $form, $values) { $form->set_error('request', get_string('membershipopenrequest', 'group')); } } if ($values['grouptype'] === 'outcomes' && empty($values['controlled'])) { if ($values['grouptype'] === 'outcomes') { if (empty($values['controlled'])) { $form->set_error('controlled', get_string('membershipoutcomesnotcontrolled', 'group')); } if ($values['grouptype'] === 'outcomes' && !in_array($values['institution'], $instwithoutcomes)) { if (!in_array($values['institution'], $instwithoutcomes)) { $form->set_error('grouptype', get_string('institutionoutcomesnotallowed', 'group')); } } // don't allow to change the type to other than outcomes // if there are still some collections with outcomesportfolio if ($group_data->grouptype === 'outcomes' && $values['grouptype'] !== 'outcomes' && record_exists('collection', 'group', $group_data->id, 'outcomeportfolio', 1)) { $form->set_error('grouptype', get_string('existingoutcomecollections', 'group')); } if (!empty($values['invitefriends']) && !empty($values['suggestfriends'])) { $form->set_error('invitefriends', get_string('suggestinvitefriends', 'group')); } Loading htdocs/group/outcomes.php +14 −2 Original line number Diff line number Diff line Loading @@ -29,9 +29,11 @@ function get_outcome_types($collection) { function get_outcomes_type_options($collection) { $outcome_types = get_outcome_types($collection); $options = array( 0 => ''); if ($outcome_types) { foreach($outcome_types as $type) { $options[$type->id] = $type->title; } } return $options; } Loading Loading @@ -62,6 +64,7 @@ function create_outcome_form($name, $title, $collection, $new=true, $outcome=nul 'type' => 'container', 'title' => $title, 'isformgroup' => false, 'class' => 'outcome-item', 'elements' => array( 'id' => array( 'type' => 'hidden', Loading @@ -73,6 +76,11 @@ function create_outcome_form($name, $title, $collection, $new=true, $outcome=nul 'description' => get_string('shorttitledesc', 'collection'), 'defaultvalue'=> $new ? null : $outcome->short_title, 'size' => 70, 'maxlength' => 70, 'rules' => array( 'required' => true, 'maxlength' => 70, ), ), 'full_title' => array( 'type' => 'textarea', Loading @@ -80,6 +88,10 @@ function create_outcome_form($name, $title, $collection, $new=true, $outcome=nul 'defaultvalue'=> $new ? null : $outcome->full_title, 'rows' => 5, 'cols' => 30, 'maxlength' => 255, 'rules' => array( 'maxlength' => 255, ), ), 'outcome_type' => array( 'type' => 'select', Loading Loading
htdocs/collection/edit.php +10 −6 Original line number Diff line number Diff line Loading @@ -99,7 +99,11 @@ if ($copy) { } else { $type = 'submitcancel'; if ($new) { if ($collection->get('group') && is_outcomes_group($collection->get('group'))) { $submitstr = array('button' => get_string('save'), 'cancel' => get_string('cancel')); $confirm = array('cancel' => get_string('confirmcancelcreatingcollection','collection')); } else if ($new) { $submitstr = array('button' => get_string('next') . ': ' . get_string('editviews', 'collection'), 'cancel' => get_string('cancel')); $confirm = array('cancel' => get_string('confirmcancelcreatingcollection','collection')); } Loading Loading @@ -268,7 +272,7 @@ function collectionedit_submit(Pieform $form, $values) { } $values['coverimage'] = (isset($values['coverimage']) ? $values['coverimage'] : null); $groupid = $collection->get('group'); $values['outcomeportfolio'] = (int)($groupid && is_outcomes_group($groupid)); $values['outcomeportfolio'] = (int)($groupid && is_outcomes_group($groupid) && $values['outcomeportfolio']); $collection = Collection::save($values); if (isset($values['progresscompletion'])) { Loading
htdocs/collection/manageoutcomes.php +40 −7 Original line number Diff line number Diff line Loading @@ -56,6 +56,26 @@ $strings= get_outcome_lang_strings(); $js = <<< EOJS {$strings} jQuery(function($) { /** * Prevent short title input element to submit form on 'enter' krey pressed */ function removeSubmitOnEnter() { $("#outcome_forms input[name='short_title']").on('keypress', function(e){ if (e.keyCode == 13) { e.preventDefault(); e.stopPropagation(); } }) } /** * Set maxlength attribute on textareas */ function setMaxlength() { $("textarea").attr('maxlength', 255); } /* * Validate short_title field not empty */ Loading Loading @@ -107,7 +127,7 @@ jQuery(function($) { data.push({ "short_title": short_title, "full_title": full_title, "outcome_type": outcome_type, "outcome_type": outcome_type || '', "id": id, }); }); Loading @@ -117,9 +137,15 @@ jQuery(function($) { }, "POST", function(data) { formchangemanager.reset(); const id = new URL(location.href).searchParams.get('id'); window.location.href= config.wwwroot + 'collection/outcomesoverview.php?id=' + id; if (data) { $("#messages div").html(data); } }, function(error) { $("#messages")[0].scrollIntoView(true); } ); } Loading @@ -141,6 +167,9 @@ jQuery(function($) { function (data) { if (data.html) { $("#outcome_forms").append(data.html); $("#outcome_forms .requiredmarkerdesc").remove(); removeSubmitOnEnter(); setMaxlength(); $("#outcome_forms .delete-outcome a").last().on("click", removeForms); $("#outcome_buttons_container")[0].scrollIntoView({block: "end"}); } Loading @@ -153,7 +182,7 @@ jQuery(function($) { */ function deleteOutcome(e) { e.preventDefault(); const deleteform = $(e.target).parent().parent(); const deleteform = $(e.target).closest('div'); const outcomeform = deleteform.next(); // get hidden db id const id = outcomeform.find(`input[name="id"]`).val(); Loading Loading @@ -198,7 +227,11 @@ jQuery(function($) { $("#submit_save").on("click", saveOutcomesForm); $("#add_outcome").on("click", addOutcomeForm); $(".delete-outcome a").on("click", deleteOutcome); $("#outcome_forms .requiredmarkerdesc").remove(); removeSubmitOnEnter(); // Somehow maxlength is not being set on the textareas // need to add it using jquery setMaxlength(); }); EOJS; $cancelredirecturl = get_config('wwwroot') . 'view/groupviews.php?group=' . $collection->get('group'); Loading
htdocs/collection/views.php +3 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,9 @@ $collection = new Collection($id); if (!$USER->can_edit_collection($collection)) { throw new AccessDeniedException(get_string('canteditcollection', 'collection')); } if ($collection->get('outcomeportfolio')) { throw new AccessDeniedException(get_string('canteditcollection', 'collection')); } $sesskey = $USER->get('sesskey'); $inlinejs = ''; if ($accesschanged = $SESSION->get('pageaccesschanged')) { Loading
htdocs/group/edit.php +12 −4 Original line number Diff line number Diff line Loading @@ -557,12 +557,20 @@ function editgroup_validate(Pieform $form, $values) { $form->set_error('request', get_string('membershipopenrequest', 'group')); } } if ($values['grouptype'] === 'outcomes' && empty($values['controlled'])) { if ($values['grouptype'] === 'outcomes') { if (empty($values['controlled'])) { $form->set_error('controlled', get_string('membershipoutcomesnotcontrolled', 'group')); } if ($values['grouptype'] === 'outcomes' && !in_array($values['institution'], $instwithoutcomes)) { if (!in_array($values['institution'], $instwithoutcomes)) { $form->set_error('grouptype', get_string('institutionoutcomesnotallowed', 'group')); } } // don't allow to change the type to other than outcomes // if there are still some collections with outcomesportfolio if ($group_data->grouptype === 'outcomes' && $values['grouptype'] !== 'outcomes' && record_exists('collection', 'group', $group_data->id, 'outcomeportfolio', 1)) { $form->set_error('grouptype', get_string('existingoutcomecollections', 'group')); } if (!empty($values['invitefriends']) && !empty($values['suggestfriends'])) { $form->set_error('invitefriends', get_string('suggestinvitefriends', 'group')); } Loading
htdocs/group/outcomes.php +14 −2 Original line number Diff line number Diff line Loading @@ -29,9 +29,11 @@ function get_outcome_types($collection) { function get_outcomes_type_options($collection) { $outcome_types = get_outcome_types($collection); $options = array( 0 => ''); if ($outcome_types) { foreach($outcome_types as $type) { $options[$type->id] = $type->title; } } return $options; } Loading Loading @@ -62,6 +64,7 @@ function create_outcome_form($name, $title, $collection, $new=true, $outcome=nul 'type' => 'container', 'title' => $title, 'isformgroup' => false, 'class' => 'outcome-item', 'elements' => array( 'id' => array( 'type' => 'hidden', Loading @@ -73,6 +76,11 @@ function create_outcome_form($name, $title, $collection, $new=true, $outcome=nul 'description' => get_string('shorttitledesc', 'collection'), 'defaultvalue'=> $new ? null : $outcome->short_title, 'size' => 70, 'maxlength' => 70, 'rules' => array( 'required' => true, 'maxlength' => 70, ), ), 'full_title' => array( 'type' => 'textarea', Loading @@ -80,6 +88,10 @@ function create_outcome_form($name, $title, $collection, $new=true, $outcome=nul 'defaultvalue'=> $new ? null : $outcome->full_title, 'rows' => 5, 'cols' => 30, 'maxlength' => 255, 'rules' => array( 'maxlength' => 255, ), ), 'outcome_type' => array( 'type' => 'select', Loading