MDL-18297: Changed date conditions so that the text and behaviour is more natural.
This commit is contained in:
@@ -294,6 +294,12 @@
|
||||
if(!empty($CFG->enableavailability)) {
|
||||
$cm->availablefrom = $fromform->availablefrom;
|
||||
$cm->availableuntil = $fromform->availableuntil;
|
||||
// The form time is midnight, but because we want it to be
|
||||
// inclusive, set it to 23:59:59 on that day.
|
||||
if ($cm->availableuntil) {
|
||||
$cm->availableuntil = strtotime('23:59:59',
|
||||
$cm->availableuntil);
|
||||
}
|
||||
$cm->showavailability = $fromform->showavailability;
|
||||
condition_info::update_cm_from_form($cm,$fromform,true);
|
||||
}
|
||||
@@ -348,6 +354,12 @@
|
||||
if(!empty($CFG->enableavailability)) {
|
||||
$newcm->availablefrom = $fromform->availablefrom;
|
||||
$newcm->availableuntil = $fromform->availableuntil;
|
||||
// The form time is midnight, but because we want it to be
|
||||
// inclusive, set it to 23:59:59 on that day.
|
||||
if ($newcm->availableuntil) {
|
||||
$newcm->availableuntil = strtotime('23:59:59',
|
||||
$newcm->availableuntil);
|
||||
}
|
||||
$newcm->showavailability = $fromform->showavailability;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ $string['addgrades']='Add {no} grade conditions to form';
|
||||
$string['addcompletions']='Add {no} activity conditions to form';
|
||||
$string['availabilityconditions']='Restrict availability';
|
||||
$string['availablefrom']='Only available from';
|
||||
$string['availableuntil']='Only available until';
|
||||
$string['availableuntil']='Only available until end';
|
||||
$string['badavailabledates']='Invalid dates. If you set both dates, the \'available from\' date should be before the \'until\' date.';
|
||||
$string['completion_complete']=' must be marked complete';
|
||||
$string['completion_incomplete']=' must not be marked complete';
|
||||
@@ -23,8 +23,9 @@ $string['requires_completion_0']='Not available unless the activity <strong>$a</
|
||||
$string['requires_completion_1']='Not available until the activity <strong>$a</strong> is marked complete.';
|
||||
$string['requires_completion_2']='Not available until the activity <strong>$a</strong> is complete and passed.';
|
||||
$string['requires_completion_3']='Not available unless the activity <strong>$a</strong> is complete and failed.';
|
||||
$string['requires_date']='Not available until $a.';
|
||||
$string['requires_date_before']='Not available from $a.';
|
||||
$string['requires_date']='Available from $a.';
|
||||
$string['requires_date_before']='Available until $a.';
|
||||
$string['requires_date_both']='Available from $a->from to $a->until.';
|
||||
$string['requires_grade_any']='Not available until you have a grade in <strong>$a</strong>.';
|
||||
$string['requires_grade_min']='Not available until you achieve a required score in <strong>$a</strong>.';
|
||||
$string['requires_grade_max']='Not available unless you get an appropriate score in <strong>$a</strong>.';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<h1>Available dates</h1>
|
||||
|
||||
<p>
|
||||
Using the 'Only available from' and 'Only available until' dates, you can make
|
||||
Using the 'Only available from' and 'Only available until end' dates, you can make
|
||||
an activity appear or disappear. The activity is only shown to students from the
|
||||
'available from' date, and it disappears on the 'available until' date. Students
|
||||
'available from' date, and it disappears after the 'available until end' date. Students
|
||||
cannot access it outside those times, even if they guess the URL.
|
||||
</p>
|
||||
|
||||
@@ -16,7 +16,7 @@ any time (as long as the student can access the course).
|
||||
<li> If you choose to show information about an activity that is unavailable,
|
||||
then before the 'available from' date, students will see the activity
|
||||
greyed-out, with informational text about the date that it appears.</li>
|
||||
<li> The activity completely vanishes on the 'available to' date, even if
|
||||
<li> The activity completely vanishes at midnight on the 'available to end' date, even if
|
||||
you've chosen to show information.</li>
|
||||
<li> Setting 'Visible' to 'Hide' overrides these settings. If you set 'Visible'
|
||||
to 'Hide', the activity is never available regardless of date.</li>
|
||||
|
||||
+40
-10
@@ -269,14 +269,17 @@ WHERE
|
||||
}
|
||||
|
||||
// Dates
|
||||
if ($this->cm->availablefrom) {
|
||||
$information .= get_string('requires_date', 'condition', userdate(
|
||||
$this->cm->availablefrom, get_string('strftimedate', 'langconfig')));
|
||||
}
|
||||
|
||||
if ($this->cm->availableuntil) {
|
||||
$information .= get_string('requires_date_before', 'condition', userdate(
|
||||
$this->cm->availableuntil, get_string('strftimedate', 'langconfig')));
|
||||
if ($this->cm->availablefrom && $this->cm->availableuntil) {
|
||||
$information .= get_string('requires_date_both', 'condition',
|
||||
(object)array(
|
||||
'from' => self::show_time($this->cm->availablefrom, false),
|
||||
'until' => self::show_time($this->cm->availableuntil, true)));
|
||||
} else if ($this->cm->availablefrom) {
|
||||
$information .= get_string('requires_date', 'condition',
|
||||
self::show_time($this->cm->availablefrom, false));
|
||||
} else if ($this->cm->availableuntil) {
|
||||
$information .= get_string('requires_date_before', 'condition',
|
||||
self::show_time($this->cm->availableuntil, true));
|
||||
}
|
||||
|
||||
$information = trim($information);
|
||||
@@ -385,8 +388,9 @@ WHERE
|
||||
if ($this->cm->availablefrom) {
|
||||
if (time() < $this->cm->availablefrom) {
|
||||
$available = false;
|
||||
$information .= get_string('requires_date', 'condition', userdate(
|
||||
$this->cm->availablefrom, get_string('strftimedate','langconfig')));
|
||||
|
||||
$information .= get_string('requires_date', 'condition',
|
||||
self::show_time($this->cm->availablefrom, false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,6 +413,32 @@ WHERE
|
||||
return $available;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a time either as a date (if it falls exactly on the day) or
|
||||
* a full date and time, according to user's timezone.
|
||||
* @param int $time Time
|
||||
* @param bool $until True if this date should be treated as the second of
|
||||
* an inclusive pair - if so the time will be shown unless date is 23:59:59.
|
||||
* Without this the date shows for 0:00:00.
|
||||
* @return string Date
|
||||
*/
|
||||
private function show_time($time, $until) {
|
||||
// Break down the time into fields
|
||||
$userdate = usergetdate($time);
|
||||
|
||||
// Handle the 'inclusive' second date
|
||||
if($until) {
|
||||
$dateonly = $userdate['hours']==23 && $userdate['minutes']==59 &&
|
||||
$userdate['seconds']==59;
|
||||
} else {
|
||||
$dateonly = $userdate['hours']==0 && $userdate['minutes']==0 &&
|
||||
$userdate['seconds']==0;
|
||||
}
|
||||
|
||||
return userdate($time, get_string(
|
||||
$dateonly ? 'strftimedate' : 'strftimedatetime', 'langconfig'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool True if information about availability should be shown to
|
||||
* normal users
|
||||
|
||||
@@ -1640,6 +1640,16 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
upgrade_main_savepoint($result, 2009040600);
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2009041700) {
|
||||
/// To ensure the UI remains consistent with no behaviour change, any
|
||||
/// 'until' date in an activity condition should have 1 second subtracted
|
||||
/// (to go from 0:00 on the following day to 23:59 on the previous one).
|
||||
$DB->execute('UPDATE {course_modules} SET availableuntil = availableuntil - 1 WHERE availableuntil <> 0');
|
||||
|
||||
/// Main savepoint reached
|
||||
upgrade_main_savepoint($result, 2009041700);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
// This is compared against the values stored in the database to determine
|
||||
// whether upgrades should be performed (see lib/db/*.php)
|
||||
|
||||
$version = 2009040601; // YYYYMMDD = date of the last version bump
|
||||
$version = 2009041700; // YYYYMMDD = date of the last version bump
|
||||
// XX = daily increments
|
||||
|
||||
$release = '2.0 dev (Build: 20090417)'; // Human-friendly version name
|
||||
|
||||
Reference in New Issue
Block a user