$notification = $course->shortname . ' (id = ' . $course->id . '): ';
+ $originalenddate = null;
+ $guessedstartdate = null;
+ $guessedenddate = null;
+ $samestartdate = null;
+ $lowerenddate = null;
+
if ($options['guessstart'] || $options['guessall']) {
$originalstartdate = $course->startdate;
$guessedstartdate = $courseman->guess_start();
- if ($guessedstartdate == $originalstartdate) {
+ $samestartdate = ($guessedstartdate == $originalstartdate);
+ $lowerenddate = ($course->enddate && ($course->enddate < $guessedstartdate));
+
+ if ($samestartdate) {
if (!$guessedstartdate) {
$notification .= PHP_EOL . ' ' . get_string('cantguessstartdate', 'tool_analytics');
} else {
}
} else if (!$guessedstartdate) {
$notification .= PHP_EOL . ' ' . get_string('cantguessstartdate', 'tool_analytics');
+ } else if ($lowerenddate) {
+ $notification .= PHP_EOL . ' ' . get_string('cantguessstartdate', 'tool_analytics') . ': ' .
+ get_string('enddatebeforestartdate', 'error') . ' - ' . userdate($guessedstartdate);
} else {
// Update it to something we guess.
if ($options['guessend'] || $options['guessall']) {
+ if (!empty($lowerenddate) && !empty($guessedstartdate)) {
+ $course->startdate = $guessedstartdate;
+ }
+
$originalenddate = $course->enddate;
$format = course_get_format($course);
$updateit = true;
}
- if ($options['update']) {
- if ($course->enddate > $course->startdate) {
- update_course($course);
- }
+ if ($options['update'] && $updateit) {
+ update_course($course);
}
}
}
$courseid = $this->page->course->id;
$categoryid = ($this->page->context->contextlevel === CONTEXT_COURSECAT) ? $this->page->category->id : null;
$calendar = \calendar_information::create(time(), $courseid, $categoryid);
- list($data, $template) = calendar_get_view($calendar, 'mini');
+ list($data, $template) = calendar_get_view($calendar, 'mini', isloggedin());
$renderer = $this->page->get_renderer('core_calendar');
$this->content->text .= $renderer->render_from_template($template, $data);
return $this->content;
}
+
+ /**
+ * Get the upcoming event block content.
+ *
+ * @param array $events list of events
+ * @param \moodle_url|string $linkhref link to event referer
+ * @param boolean $showcourselink whether links to courses should be shown
+ * @return string|null $content html block content
+ * @deprecated since 3.4
+ */
+ public static function get_upcoming_content($events, $linkhref = null, $showcourselink = false) {
+ debugging(
+ 'get_upcoming_content() is deprecated. ' .
+ 'Please see block_calendar_upcoming::get_content() for the correct API usage.',
+ DEBUG_DEVELOPER
+ );
+
+ $content = '';
+ $lines = count($events);
+
+ if (!$lines) {
+ return $content;
+ }
+
+ for ($i = 0; $i < $lines; ++$i) {
+ if (!isset($events[$i]->time)) {
+ continue;
+ }
+ $events[$i] = calendar_add_event_metadata($events[$i]);
+ $content .= '<div class="event"><span class="icon c0">' . $events[$i]->icon . '</span>';
+ if (!empty($events[$i]->referer)) {
+ // That's an activity event, so let's provide the hyperlink.
+ $content .= $events[$i]->referer;
+ } else {
+ if (!empty($linkhref)) {
+ $href = calendar_get_link_href(new \moodle_url(CALENDAR_URL . $linkhref), 0, 0, 0,
+ $events[$i]->timestart);
+ $href->set_anchor('event_' . $events[$i]->id);
+ $content .= \html_writer::link($href, $events[$i]->name);
+ } else {
+ $content .= $events[$i]->name;
+ }
+ }
+ $events[$i]->time = str_replace('»', '<br />»', $events[$i]->time);
+ if ($showcourselink && !empty($events[$i]->courselink)) {
+ $content .= \html_writer::div($events[$i]->courselink, 'course');
+ }
+ $content .= '<div class="date">' . $events[$i]->time . '</div></div>';
+ if ($i < $lines - 1) {
+ $content .= '<hr />';
+ }
+ }
+
+ return $content;
+ }
}
--- /dev/null
+=== 3.4 ===
+
+* block_calendar_upcoming::get_upcoming_content has been deprecated. Please
+ update your code to use the new APIs. You can see an example of how these
+ may be used in block_calendar_upcoming::get_content().
'optional' => true,
'default' => 0,
],
+ 'isloggedin' => [
+ 'type' => PARAM_BOOL,
+ ],
];
}
'course' => $this->calendar->course->id,
]);
$this->url = $url;
+ $return['isloggedin'] = isloggedin();
$return['events'] = array_map(function($event) use ($cache, $output, $url) {
$context = $cache->get_context($event);
$course = $cache->get_course($event);
<div id="calendar-upcoming-block-{{uniqid}}" data-template="core_calendar/upcoming_mini">
{{> core_calendar/upcoming_mini}}
</div>
+{{#isloggedin}}
{{#js}}
require(['jquery', 'core_calendar/calendar_view'], function($, CalendarView) {
CalendarView.init($("#calendar-upcoming-block-{{uniqid}}"), 'upcoming');
});
{{/js}}
+{{/isloggedin}}
information provided here is intended especially for developers.
=== 3.4 ===
-* calendar_get_mini has been deprecated. Please update to use the new
- exporters and renderers.
+* calendar_get_mini, and calendar_get_upcoming have been deprecated. Please update to use the new exporters and renderers.
* added core_calendar_get_valid_event_timestart_range and core_calendar_event_timestart_updated callbacks for module events
when the update_event_start_day function is used in the local api.
function calendar_get_block_upcoming($events, $linkhref = null, $showcourselink = false) {
global $CFG;
- debugging(__FUNCTION__ . '() is deprecated, please use block_calendar_upcoming::get_upcoming_content() instead.',
- DEBUG_DEVELOPER);
+ debugging(
+ __FUNCTION__ . '() has been deprecated. ' .
+ 'Please see block_calendar_upcoming::get_content() for the correct API usage.',
+ DEBUG_DEVELOPER
+ );
require_once($CFG->dirroot . '/blocks/moodleblock.class.php');
require_once($CFG->dirroot . '/blocks/calendar_upcoming/block_calendar_upcoming.php');
list($data, $template) = calendar_get_view($calendar, 'mini');
return $renderer->render_from_template($template, $data);
}
+
+/**
+ * Gets the calendar upcoming event.
+ *
+ * @param array $courses array of courses
+ * @param array|int|bool $groups array of groups, group id or boolean for all/no group events
+ * @param array|int|bool $users array of users, user id or boolean for all/no user events
+ * @param int $daysinfuture number of days in the future we 'll look
+ * @param int $maxevents maximum number of events
+ * @param int $fromtime start time
+ * @return array $output array of upcoming events
+ * @deprecated since Moodle 3.4. MDL-59333
+ */
+function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxevents, $fromtime=0) {
+ debugging(
+ 'calendar_get_upcoming() has been deprecated. ' .
+ 'Please see block_calendar_upcoming::get_content() for the correct API usage.',
+ DEBUG_DEVELOPER
+ );
+
+ global $COURSE;
+
+ $display = new \stdClass;
+ $display->range = $daysinfuture; // How many days in the future we 'll look.
+ $display->maxevents = $maxevents;
+
+ $output = array();
+
+ $processed = 0;
+ $now = time(); // We 'll need this later.
+ $usermidnighttoday = usergetmidnight($now);
+
+ if ($fromtime) {
+ $display->tstart = $fromtime;
+ } else {
+ $display->tstart = $usermidnighttoday;
+ }
+
+ // This works correctly with respect to the user's DST, but it is accurate
+ // only because $fromtime is always the exact midnight of some day!
+ $display->tend = usergetmidnight($display->tstart + DAYSECS * $display->range + 3 * HOURSECS) - 1;
+
+ // Get the events matching our criteria.
+ $events = calendar_get_legacy_events($display->tstart, $display->tend, $users, $groups, $courses);
+
+ // This is either a genius idea or an idiot idea: in order to not complicate things, we use this rule: if, after
+ // possibly removing SITEID from $courses, there is only one course left, then clicking on a day in the month
+ // will also set the $SESSION->cal_courses_shown variable to that one course. Otherwise, we 'd need to add extra
+ // arguments to this function.
+ $hrefparams = array();
+ if (!empty($courses)) {
+ $courses = array_diff($courses, array(SITEID));
+ if (count($courses) == 1) {
+ $hrefparams['course'] = reset($courses);
+ }
+ }
+
+ if ($events !== false) {
+ foreach ($events as $event) {
+ if (!empty($event->modulename)) {
+ $instances = get_fast_modinfo($event->courseid)->get_instances_of($event->modulename);
+ if (empty($instances[$event->instance]->uservisible)) {
+ continue;
+ }
+ }
+
+ if ($processed >= $display->maxevents) {
+ break;
+ }
+
+ $event->time = calendar_format_event_time($event, $now, $hrefparams);
+ $output[] = $event;
+ $processed++;
+ }
+ }
+
+ return $output;
+}
foreach ($attempts as $attempt) {
if ($trackdata = scorm_get_tracks($scoid, $attempt->userid, $attempt->attempt)) {
if (isset($trackdata->score_raw)) {
- $score = $trackdata->score_raw;
+ $score = (int) $trackdata->score_raw;
if (empty($trackdata->score_min)) {
$minmark = 0;
} else {
$row[] = scorm_grade_user_attempt($scorm, $scouser->userid, $scouser->attempt);
}
// Print out all scores of attempt.
+ $emptyrow = $download ? '' : ' ';
foreach ($scoes as $sco) {
if ($sco->launch != '') {
if ($trackdata = scorm_get_tracks($sco->id, $scouser->userid, $scouser->attempt)) {
if (isset($trackdata->$element)) {
$row[] = s($trackdata->$element);
} else {
- $row[] = ' ';
+ $row[] = $emptyrow;
}
}
if ($displayoptions['resp']) {
if (isset($trackdata->$element)) {
$row[] = s($trackdata->$element);
} else {
- $row[] = ' ';
+ $row[] = $emptyrow;
}
}
if ($displayoptions['right']) {
}
$row[] = $rightans;
} else {
- $row[] = ' ';
+ $row[] = $emptyrow;
}
}
if ($displayoptions['result']) {
if (isset($trackdata->$element)) {
$row[] = s($trackdata->$element);
} else {
- $row[] = ' ';
+ $row[] = $emptyrow;
}
}
}
}
// Complete the empty cells.
for ($i = 0; $i < count($columns) - $nbmaincolumns; $i++) {
- $row[] = ' ';
+ $row[] = $emptyrow;
}
}
}
}
// Make sure the levels grades are unique within the criterion.
+ $atleastonelevel = false;
for ($j = 0; isset($data['levelid__idx_'.$i.'__idy_'.$j]); $j++) {
if (0 == strlen(trim($data['definition__idx_'.$i.'__idy_'.$j]))) {
// The level definition is empty and will not be saved.
continue;
}
+ $atleastonelevel = true;
$levelgrade = $data['grade__idx_'.$i.'__idy_'.$j];
$dimgrades[$levelgrade] = $j;
}
}
+ if (!$atleastonelevel) {
+ $errors['level__idx_'.$i.'__idy_0'] = get_string('mustdefinelevel', 'workshopform_rubric');
+ }
}
return $errors;
$string['levelgroup'] = 'Level grade and definition';
$string['levels'] = 'Levels';
$string['mustbeunique'] = 'Level grades must be unique within a criterion';
+$string['mustdefinelevel'] = 'At least one level is required';
$string['mustchooseone'] = 'You have to select one of these items';
$string['pluginname'] = 'Rubric';
}
.inplaceeditable {
- display: block;
&.inplaceeditingon {
position: relative;
&.inplaceeditable-toggle .quickediticon {
display: none;
}
+
+ &.inplaceeditable-autocomplete {
+ display: block;
+ }
}
h3.sectionname .inplaceeditable.inplaceeditingon .editinstructions {
}
.inplaceeditable {
- display: block;
&.inplaceeditingon {
position: relative;
&.inplaceeditable-toggle .quickediticon {
display: none;
}
+
+ &.inplaceeditable-autocomplete {
+ display: block;
+ }
}
h3.sectionname .inplaceeditable.inplaceeditingon .editinstructions {
.nav-tabs > .active > a[href]:focus {
cursor: pointer;
}
-.inplaceeditable {
- display: block;
-}
.inplaceeditable.inplaceeditingon {
position: relative;
}
.inplaceeditable.inplaceeditable-toggle .quickediticon {
display: none;
}
+.inplaceeditable.inplaceeditable-autocomplete {
+ display: block;
+}
h3.sectionname .inplaceeditable.inplaceeditingon .editinstructions {
margin-top: -20px;
}