Skip to content

Commit ec73b80

Browse files
committed
INT-17780: Add a checkbox in collaborate to hide the duration
1 parent 75864ef commit ec73b80

File tree

10 files changed

+74
-11
lines changed

10 files changed

+74
-11
lines changed

classes/renderables/meetingstatus.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ public function __construct($times,
100100
/** @var mod_collaborate_renderer $output */
101101
$output = $PAGE->get_renderer('mod_collaborate');
102102
// This should be migrated to a renderable and template at some point.
103-
$this->meetingtimes = $output->meeting_times($times);
103+
if (empty($collaborate->hideduration)) {
104+
$this->meetingtimes = $output->meeting_times($times);
105+
}
104106

105107
$params = ['action' => 'forward', 'id' => $cm->id, 'sesskey' => sesskey()];
106108
$this->fwdurl = new \moodle_url('view.php', $params);

db/install.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<FIELD NAME="candownloadrecordings" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false"/>
3232
<FIELD NAME="largesessionenable" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
3333
<FIELD NAME="canenablelargesession" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false"/>
34+
<FIELD NAME="hideduration" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
3435
</FIELDS>
3536
<KEYS>
3637
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
@@ -115,4 +116,4 @@
115116
</KEYS>
116117
</TABLE>
117118
</TABLES>
118-
</XMLDB>
119+
</XMLDB>

db/upgrade.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,5 +447,18 @@ function xmldb_collaborate_upgrade($oldversion) {
447447
upgrade_mod_savepoint(true, 2021111105, 'collaborate');
448448
}
449449

450+
if ($oldversion < 2022020301) {
451+
452+
// Define field completionlaunch to be added to collaborate.
453+
$table = new xmldb_table('collaborate');
454+
$field = new xmldb_field('hideduration', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
455+
if (!$dbman->field_exists($table, $field)) {
456+
$dbman->add_field($table, $field);
457+
}
458+
459+
// Collaborate savepoint reached.
460+
upgrade_mod_savepoint(true, 2022020301, 'collaborate');
461+
}
462+
450463
return true;
451464
}

lang/en/collaborate.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
$string['deleterecordingconfirmation'] = 'Are you sure you want to delete the recording entitled "{$a}"?';
7575
$string['downloadrec'] = 'Download recording';
7676
$string['duration'] = 'Duration';
77+
$string['hideduration'] = 'Hide duration view';
7778
$string['ends'] = 'Ends - {$a}';
7879
$string['error:apicallfailed'] = 'API call failed ( {$a} )';
7980
$string['error:apifailure'] = 'An error occurred whilst talking to the collaborate server - please try again later. If the problem persists, please contact support.';

lib.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ function collaborate_update_instance(stdClass $collaborate, mod_collaborate_mod_
158158
$collaborate->timestart = $data->timestart;
159159
$collaborate->timeend = $data->timeend;
160160
$collaborate->intro = local::entitydecode($collaborate->intro);
161+
$hideduration = isset($collaborate->hideduration) && boolval($collaborate->hideduration);
162+
$collaborate->hideduration = $hideduration ?: 0;
161163
$cansharevideo = isset($collaborate->cansharevideo) && boolval($collaborate->cansharevideo);
162164
$collaborate->cansharevideo = $cansharevideo ?: 0;
163165
$canpostmessages = isset($collaborate->canpostmessages) && boolval($collaborate->canpostmessages);
@@ -382,11 +384,15 @@ function collaborate_pluginfile($course, $cm, $context, $filearea, array $args,
382384
* @param cm_info $cm
383385
*/
384386
function collaborate_cm_info_view(cm_info $cm) {
385-
global $PAGE;
387+
global $PAGE, $DB;
386388
$renderer = $PAGE->get_renderer('mod_collaborate');
387-
$times = local::get_times($cm->instance);
388-
$o = html_writer::tag('span', $renderer->meeting_times($times), ['class' => 'label label-info']);
389-
$cm->set_after_link($o);
389+
390+
$hideduration = $DB->get_field('collaborate', 'hideduration', array('id' => $cm->instance));
391+
if (empty($hideduration)) {
392+
$times = local::get_times($cm->instance);
393+
$o = html_writer::tag('span', $renderer->meeting_times($times), ['class' => 'label label-info']);
394+
$cm->set_after_link($o);
395+
}
390396
}
391397

392398
/**
@@ -501,4 +507,4 @@ function collaborate_get_recent_mod_activity(&$activities, &$index, $timestart,
501507
$activities[$index++] = $activity;
502508
}
503509

504-
}
510+
}

mod_form.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ public function definition() {
108108
$mform->addElement('select', 'duration', get_string('duration', 'mod_collaborate'), $options);
109109
$mform->setDefault('duration', HOURSECS);
110110

111+
$mform->addElement('advcheckbox', 'hideduration',
112+
get_string('hideduration', 'mod_collaborate'), '', array('group' => 1), array(0, 1));
113+
$mform->setDefault('hideduration', get_config('collaborate', 'hideduration'));
114+
111115
// Guest access enabled yes / no.
112116
$mform->addElement('checkbox', 'guestaccessenabled',
113117
get_string('guestaccessenabled', 'mod_collaborate'), '', array('group' => 1), array(0, 1));

settings.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,13 @@
260260
$setting = new \admin_setting_configcheckbox($name, $title, '', $default, $checked, $unchecked);
261261
$settings->add($setting);
262262

263+
$name = 'collaborate/hideduration';
264+
$title = new lang_string('hideduration', 'collaborate');
265+
$description = new lang_string('hideduration', 'collaborate');
266+
$default = $unchecked;
267+
$setting = new \admin_setting_configcheckbox($name, $title, '', $default, $checked, $unchecked);
268+
$settings->add($setting);
269+
263270
// Performance settings.
264271
$name = 'collaborate/performancesettings';
265272
$setting = new \admin_setting_heading($name, get_string('performancesettings', 'mod_collaborate'), '');

templates/meetingstatus.mustache

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@
3434

3535
<div class="tab-pane active" id="maininfo" role="tabpanel">
3636
<div class = "path-mod-collaborate__meetingstatus">
37-
<div class = "path-mod-collaborate__meetingstatus_times">{{{meetingtimes}}}</div>
38-
37+
{{#meetingtimes}}
38+
<div class = "path-mod-collaborate__meetingstatus_times">{{{meetingtimes}}}</div>
39+
{{/meetingtimes}}
3940
{{#statusunrestored}}
4041
{{> core/notification_info}}
4142
{{/statusunrestored}}

tests/behat/collaborate.feature

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,4 +361,32 @@ Feature: Collaborate instances can be created by teachers and joined by students
361361
And I set the following fields to these values:
362362
| Collaborate guest role | Presenter |
363363
And I click on "Save and display" "button"
364-
Then I should see "In large scale sessions, guests must be participants"
364+
Then I should see "In large scale sessions, guests must be participants"
365+
366+
Scenario: Collaborate instance with hide duration view configuration enable does not show the duration.
367+
Given I log in as "teacher1"
368+
And the following "activity" exists:
369+
| activity | collaborate |
370+
| course | C1 |
371+
| section | 1 |
372+
| name | Test collab |
373+
| hideduration | 1 |
374+
| duration | 9999 |
375+
And I am on "Course 1" course homepage with editing mode on
376+
And I should not see "(Duration of course)"
377+
And I follow "Test collab"
378+
And I should not see "(Duration of course)"
379+
380+
Scenario: Collaborate instance with hide duration view configuration disable show the duration.
381+
Given I log in as "teacher1"
382+
And the following "activity" exists:
383+
| activity | collaborate |
384+
| course | C1 |
385+
| section | 1 |
386+
| name | Test collab |
387+
| hideduration | 0 |
388+
| duration | 9999 |
389+
And I am on "Course 1" course homepage with editing mode on
390+
And I should see "(Duration of course)"
391+
And I follow "Test collab"
392+
And I should see "(Duration of course)"

version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
defined('MOODLE_INTERNAL') || die();
2626

2727
$plugin->component = 'mod_collaborate';
28-
$plugin->version = 2022020100;
28+
$plugin->version = 2022020301;
2929
$plugin->release = '3.11.3';
3030
$plugin->requires = 2021051700;
3131
$plugin->maturity = MATURITY_STABLE;

0 commit comments

Comments
 (0)