diff --git a/lang/en/adobeconnect.php b/lang/en/adobeconnect.php index 1e2ecb7..83d6591 100644 --- a/lang/en/adobeconnect.php +++ b/lang/en/adobeconnect.php @@ -165,4 +165,6 @@ $string['longurl'] = 'That meeting URL is too long. Try shortening it'; $string['errorrecording'] = 'Unable to find recording session'; $string['meetinfo'] = 'More Meeting Detail'; $string['meetinfotxt'] = 'See server meeting details'; -$string['invalidgroupmode'] = 'Your course (or selected grouping) has no groups. Please configure groups or select \'No groups\'.'; \ No newline at end of file +$string['invalidgroupmode'] = 'Your course (or selected grouping) has no groups. Please configure groups or select \'No groups\'.'; +$string['shortengroupnames'] = 'Course group names are too long (longest is {$a->max} characters). Total length of Meeting title (which will have group name appended) cannot exceed {$a->maxallowed} characters.'; +$string['invalidnamelength'] = 'Meeting title cannot exceed {$a} characters due to the length of group names in use.'; \ No newline at end of file diff --git a/mod_form.php b/mod_form.php index ef2d670..6d9b7b1 100644 --- a/mod_form.php +++ b/mod_form.php @@ -24,7 +24,7 @@ class mod_adobeconnect_mod_form extends moodleform_mod { /// Adding the "general" fieldset, where all the common settings are showed $mform->addElement('header', 'general', get_string('general', 'form')); - /// Adding the standard "name" field + /// Adding the standard "name" field - limit of 60 chars on Adobe Connect server $mform->addElement('text', 'name', get_string('adobeconnectname', 'adobeconnect'), array('size'=>'64')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); @@ -32,7 +32,7 @@ class mod_adobeconnect_mod_form extends moodleform_mod { $mform->setType('name', PARAM_CLEANHTML); } $mform->addRule('name', null, 'required', null, 'client'); - $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); + $mform->addRule('name', get_string('maximumchars', '', 60), 'maxlength', 60, 'client'); /// Adding the required "intro" field to hold the description of the instance $this->add_intro_editor(false, get_string('adobeconnectintro', 'adobeconnect')); @@ -180,6 +180,29 @@ class mod_adobeconnect_mod_form extends moodleform_mod { $errors['meeturl'] = get_string('invalidurl', 'adobeconnect'); } + //Check constraints specific to group mode + if (0 != $data['groupmode']) { + // get all groups for the course + $crsgroups = groups_get_all_groups($COURSE->id, 0, $data['groupingid']); + if (empty($crsgroups)) { + // Check that the course has groups if group mode is on + $errors['groupmode'] = get_string('invalidgroupmode', 'adobeconnect'); + } else { + // Check that meeting title is not too long in group mode (need to take into account group name length) + $crsgroupsmaxnamelength = $crsgroups; + array_walk($crsgroupsmaxnamelength, create_function('&$val', '$val = strlen($val->name);')); + //maximum course name is (meetingname - (1 + maxgroupnamelength)) + $maxnamelength = 60 - 1 - max($crsgroupsmaxnamelength); + if (strlen($data['name']) > $maxnamelength) { + if ($maxnamelength < 1) { + $errors['name'] = get_string('shortengroupnames', 'adobeconnect', array('max'=>max($crsgroupsmaxnamelength), 'maxallowed'=>60)); + } else { + $errors['name'] = get_string('invalidnamelength', 'adobeconnect', $maxnamelength); + } + } + } + } + // Adding activity if (empty($data['update'])) { @@ -197,15 +220,6 @@ class mod_adobeconnect_mod_form extends moodleform_mod { return $errors; } - // Check that the course has groups if group mode is on - if (0 != $data['groupmode']) { // Allow for multiple groups - // get all groups for the course - $crsgroups = groups_get_all_groups($COURSE->id, 0, $data['groupingid']); - if (empty($crsgroups)) { - $errors['groupmode'] = get_string('invalidgroupmode', 'adobeconnect'); - } - } - // Check Adobe connect server for duplicated names foreach($namematches as $matchkey => $match) { if (0 == substr_compare($match->name, $data['name'] . '_', 0, strlen($data['name'] . '_'), false)) {