Skip to content

Commit

Permalink
Merge branch 'master' into SAK-50756
Browse files Browse the repository at this point in the history
  • Loading branch information
bgarciaentornos authored Jan 17, 2025
2 parents 73e08d5 + 3fc2677 commit 8f2142f
Show file tree
Hide file tree
Showing 286 changed files with 12,333 additions and 15,178 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ library/src/webapp/skin/morpheus-default/
**/src/main/frontend/node/
scormplayer/scorm-tool/contentPackages
.vscode/
.java-version
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
package org.sakaiproject.announcement.api;

import java.util.List;
import java.util.Map;

import org.sakaiproject.entity.api.Entity;
import org.sakaiproject.entity.api.Reference;
Expand Down Expand Up @@ -101,12 +100,6 @@ public interface AnnouncementService extends MessageService
/** Security function giving the user permission to all groups, if granted to at the channel or site level. */
public static final String SECURE_ANNC_ALL_GROUPS = SECURE_ANNC_ROOT + SECURE_ALL_GROUPS;

/** release date property names for announcements */
public static final String RELEASE_DATE = "releaseDate";

/** retract date property names for announcements */
public static final String RETRACT_DATE = "retractDate";

/** modified date property names for announcements */
public static final String MOD_DATE = "modDate";

Expand Down Expand Up @@ -176,13 +169,6 @@ public AnnouncementChannelEdit addAnnouncementChannel(String ref) throws IdUsedE
*/
public String getRssUrl(Reference ref);

/**
* Determine if message viewable based on release/retract dates (if set)
* @param AnnouncementMessage
* @return boolean
*/
public boolean isMessageViewable(AnnouncementMessage message);

/**
* clears the message cache for this channel
* @param channelRef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -709,45 +708,6 @@ public String getRssUrl(Reference ref)
return rssUrlString.toString();
}

/**
* {@inheritDoc}
*/
public boolean isMessageViewable(AnnouncementMessage message)
{
final ResourceProperties messageProps = message.getProperties();

final Instant now = Instant.now();
try
{
final Instant releaseDate = message.getProperties().getInstantProperty(RELEASE_DATE);

if (now.isBefore(releaseDate))
{
return false;
}
}
catch (Exception e)
{
// Just not using/set Release Date
}

try
{
final Instant retractDate = message.getProperties().getInstantProperty(RETRACT_DATE);

if (now.isAfter(retractDate))
{
return false;
}
}
catch (Exception e)
{
// Just not using/set Retract Date
}

return true;
}

/**
* {@inheritDoc}
*/
Expand Down
3 changes: 2 additions & 1 deletion assignment/api/src/resources/assignment_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ gen.nograd=No hay calificaci\u00f3n
gen.notavail=La tarea no est\u00e1 disponible; Estado\: {0} <br>
gen.notope=Sin abrir
gen.notset=No establecido
gen.notsta=No la has empezado
gen.notsta=No ha empezado
gen.hpsta=Cl\u00e1usula de veracidad aceptada
gen.of=de
gen.open=Abierta
Expand Down Expand Up @@ -964,6 +964,7 @@ external.tool.label=Opciones de herramienta externa (LTI)
external.tool.placeholder=Seleccione una herramienta externa
external.tool.find=Seleccione una herramienta externa (LTI)
external.tool.goto=Ir a la herramienta externa
external.tool.deleted=*Borrado*
external.tool.new.window=Abrir herramienta externa en ventana nueva
external.tool.launched=La herramienta externa se ha abierto, refresque la p\u00e1gina para volver a lanzarla.
external.tool.expired=El lanzamiento ha expirado, refresque la p\u00e1gina
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.stream.IntStream;

import org.apache.commons.lang3.StringUtils;
import org.sakaiproject.assignment.api.AssignmentReferenceReckoner;
import org.sakaiproject.assignment.api.AssignmentService;
import org.sakaiproject.assignment.api.model.Assignment;
import org.sakaiproject.assignment.api.model.AssignmentSubmission;
Expand All @@ -32,6 +33,10 @@
import org.sakaiproject.exception.PermissionException;
import org.sakaiproject.grading.api.AssessmentNotFoundException;
import org.sakaiproject.grading.api.GradingService;
import org.sakaiproject.site.api.SiteService;
import org.sakaiproject.tasks.api.Priorities;
import org.sakaiproject.tasks.api.TaskService;
import org.sakaiproject.tasks.api.UserTaskAdapterBean;
import org.sakaiproject.user.api.User;
import org.sakaiproject.user.api.UserDirectoryService;
import org.sakaiproject.user.api.UserNotDefinedException;
Expand All @@ -45,6 +50,7 @@ public class AssignmentEventObserver implements Observer {
@Setter private AssignmentService assignmentService;
@Setter private EventTrackingService eventTrackingService;
@Setter private GradingService gradingService;
@Setter private TaskService taskService;
@Setter private UserDirectoryService userDirectoryService;

public void init() {
Expand Down Expand Up @@ -136,6 +142,26 @@ public void update(Observable o, Object arg) {
}
}
break;
case SiteService.EVENT_USER_SITE_MEMBERSHIP_ADD:

// A user has been added to a site. Lets make sure any current assignments
// for that site have a corresponding task for the new user.
String userId = userDirectoryService.idFromReference(event.getResource());
String siteId = event.getContext();
assignmentService.getAssignmentsForContext(siteId).forEach(ass -> {


String ref = AssignmentReferenceReckoner.reckoner().assignment(ass).reckon().getReference();
taskService.getTask(ref).ifPresent(task -> {

UserTaskAdapterBean userTaskBean = new UserTaskAdapterBean();
userTaskBean.setTaskId(task.getId());
userTaskBean.setUserId(userId);
userTaskBean.setPriority(Priorities.HIGH);

taskService.createUserTask(task, userTaskBean);
});
});
default:
log.debug("This observer is not interested in event [{}]", event);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.verify;

import java.io.BufferedReader;
import java.io.InputStream;
Expand All @@ -46,6 +47,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Observable;
import java.util.Optional;
import java.util.Random;
import java.util.Set;
Expand Down Expand Up @@ -85,6 +87,10 @@
import org.sakaiproject.site.api.Group;
import org.sakaiproject.site.api.Site;
import org.sakaiproject.site.api.SiteService;
import org.sakaiproject.tasks.api.Priorities;
import org.sakaiproject.tasks.api.Task;
import org.sakaiproject.tasks.api.TaskService;
import org.sakaiproject.tasks.api.UserTaskAdapterBean;
import org.sakaiproject.time.api.UserTimeService;
import org.sakaiproject.tool.api.SessionManager;
import org.sakaiproject.user.api.User;
Expand Down Expand Up @@ -126,6 +132,7 @@ public class AssignmentServiceTest extends AbstractTransactionalJUnit4SpringCont
@Autowired private SessionManager sessionManager;
@Autowired private ServerConfigurationService serverConfigurationService;
@Autowired private SiteService siteService;
@Autowired private TaskService taskService;
@Resource(name = "org.sakaiproject.time.api.UserTimeService")
private UserTimeService userTimeService;
@Autowired private UserDirectoryService userDirectoryService;
Expand Down Expand Up @@ -1489,6 +1496,45 @@ public void canSubmit() {
}
}

@Test
public void createsTasksForNewlyAddedUser() {

String siteId = "xyz";

Assignment assignment = createNewAssignment(siteId);

String assignmentRef = AssignmentReferenceReckoner.reckoner().assignment(assignment).reckon().getReference();

String studentId = "student1";
String userReference = "/user/" + studentId;
when(userDirectoryService.idFromReference(userReference)).thenReturn(studentId);

// Mock up an existing Task
Long taskId = 232L;
Task task = mock(Task.class);
when(task.getId()).thenReturn(taskId);;
when(taskService.getTask(assignmentRef)).thenReturn(Optional.of(task));

// Mock up an event, and then "fire" it
Event event = mock(Event.class);
when(event.getEvent()).thenReturn(SiteService.EVENT_USER_SITE_MEMBERSHIP_ADD);
when(event.getContext()).thenReturn(siteId);
when(event.getResource()).thenReturn(userReference);
when(event.getModify()).thenReturn(true);
assignmentEventObserver.update(null, event);

// Verify that getTask is called on our taskService mock
verify(taskService).getTask(assignmentRef);

UserTaskAdapterBean userTaskBean = new UserTaskAdapterBean();
userTaskBean.setTaskId(task.getId());
userTaskBean.setUserId(studentId);
userTaskBean.setPriority(Priorities.HIGH);

// Verify that createUserTask is called on our taskService mock, with the correct arguments
verify(taskService).createUserTask(task, userTaskBean);
}

private AssignmentSubmission createNewSubmission(String context, String submitterId, Assignment assignment) throws UserNotDefinedException, IdUnusedException {

if (assignment == null) {
Expand Down
1 change: 1 addition & 0 deletions assignment/impl/src/webapp/WEB-INF/components.xml
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@
<property name="assignmentService" ref="org.sakaiproject.assignment.api.AssignmentService"/>
<property name="eventTrackingService" ref="org.sakaiproject.event.api.EventTrackingService"/>
<property name="gradingService" ref="org.sakaiproject.grading.api.GradingService"/>
<property name="taskService" ref="org.sakaiproject.tasks.api.TaskService"/>
<property name="userDirectoryService" ref="org.sakaiproject.user.api.UserDirectoryService"/>
</bean>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2247,7 +2247,9 @@ public SimplePeerAssessmentItem(PeerAssessmentItem item) {
this.scaledFactor = item.getScaledFactor();
this.draft = item.isDraft();

this.attachmentUrlList = item.getAttachmentRefList().stream()
this.attachmentUrlList = Optional.ofNullable(item.getAttachmentRefList())
.orElseGet(Collections::emptyList)
.stream()
.map(Reference::getUrl)
.collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,7 @@ private String build_student_view_submission_context(VelocityPortlet portlet, Co
String contextString = (String) state.getAttribute(STATE_CONTEXT_STRING);
context.put("context", contextString);
context.put("NamePropSubmissionScaledPreviousGrades", ResourceProperties.PROP_SUBMISSION_SCALED_PREVIOUS_GRADES);
context.put("showUserId", serverConfigurationService.getBoolean("assignment.users.ids.show", true));

User user = (User) state.getAttribute(STATE_USER);
log.debug(this + " BUILD SUBMISSION FORM WITH USER " + user.getId() + " NAME " + user.getDisplayName());
Expand Down
2 changes: 1 addition & 1 deletion assignment/tool/src/webapp/js/assignmentsByStudent.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function renderGrouping({ studentName, actionLink, expanded, studentUserId, user
<td class="border-0">
<sakai-user-photo class="mx-2" user-id="${studentUserId}"
label="${userPhotoLabel}"
profile-popup="on"
profile-popup="on">
</sakai-user-photo>
<a href="${actionLink}" id="${studentUserId}" class="d-inline-block mt-1">
<span class="expand-icon si ${expanded ? "si-expanded" : "si-collapsed"}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function printView(url) {
<input type="hidden" name="sakai_csrf_token" value="$sakai_csrf_token" />
</form>
</div>
<form id="listSubmissionForm" name= "listSubmissionsForm" action="#toolForm("AssignmentAction")" method="post">
<form id="listSubmissionForm" name= "listSubmissionsForm" action="#toolForm("AssignmentAction")" method="post" class="d-grid">
<input type="hidden" name="assignmentId" value="$assignmentReference" />

#supplementItems($!allowViewModelAnswer $!allowReadAssignmentNoteItem $!allowViewAllPurposeItem $!assignmentModelAnswerItem $!assignmentNoteItem $!assignmentAllPurposeItem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,8 @@
class="form-control" maxlength="100"
placeholder="$tlang.getString('external.tool.placeholder')" value="$!value_ContentTitle">
<input type="hidden" id="returnContentId" name="$name_ContentId" value="$value_ContentId">
<input type="hidden" id="returnContentLaunchNewWindow" name="returnContentLaunchNewWindow">
<input type="hidden" id="returnContentToolNewpage" name="$name_ContentToolNewpage" value="$value_ContentToolNewpage">
<script>
window.returnContentItem = function (contentItem) {
console.debug("returnContentItem", contentItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ $(document).ready(function(){
default:
if($('.sakai-rubric-criteria-grading').length) {
$('body').on('rubric-ratings-changed', e => {
const criterionRatingsLength = $('.criterion-ratings').length;
const ratingsSelected = $('.rating-item.selected').length;
const criterionRatingsLength = $('sakai-rubric-grading').find('.criterion-ratings').length;
const ratingsSelected = $('sakai-rubric-grading').find('.rating-item.selected').length;
if (ratingsSelected === criterionRatingsLength) {
disableSubmitButtons(false);
} else {
Expand All @@ -43,7 +43,7 @@ $(document).ready(function(){
case 1:
if($('.sakai-rubric-criteria-grading').length) {
$('body').on('rubric-ratings-changed', e => {
const ratingsSelected = $('.rating-item.selected').length;
const ratingsSelected = $('sakai-rubric-grading').find('.rating-item.selected').length;
if (ratingsSelected > 0) {
disableSubmitButtons(false);
} else {
Expand Down Expand Up @@ -558,7 +558,7 @@ $(document).ready(function(){
<span style="font-size: smaller; color: blue;">
#set($gusers = $!service.getSortedGroupUsers($group))
#foreach ($user in $gusers)
$formattedText.escapeHtml($user.getDisplayName()) ($formattedText.escapeHtml($user.getDisplayId()))
$formattedText.escapeHtml($user.getDisplayName())#if ($showUserId) ($formattedText.escapeHtml($user.getDisplayId())) #end
#if ($velocityCount < $gusers.size()),#end
#end
</span>
Expand Down
5 changes: 0 additions & 5 deletions calendar/calendar-bundles/resources/calendar_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,6 @@ perm-calendar.all.groups=Acceder/crear eventos de grupo
perm-calendar.options=Cambiar las opciones del calendario
perm-calendar.view.audience=Ver la audiencia del evento

## Dashboard widget
widget_title=Calendario
days_message=Mostrando eventos para los pr\u00f3ximos {} d\u00edas
events_for=Eventos para

# Accesibility
a11y_last_week=\u00daltima semana
a11y_next_week=Semana pr\u00f3xima
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2579,7 +2579,9 @@ public CalendarEvent addEvent(TimeRange range, String displayName, String descri
edit.setDescription(description);
edit.setType(type);
edit.setLocation(location);
edit.setSiteId(m_toolManager.getCurrentPlacement().getContext());
if (m_toolManager.getCurrentPlacement() != null && m_toolManager.getCurrentPlacement().getContext() != null) {
edit.setSiteId(m_toolManager.getCurrentPlacement().getContext());
}
edit.setCreator();

// for site...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
*/
@Slf4j
public class IcalendarReader extends Reader {
public static final long MINUTES_IN_DAY = TimeUnit.DAYS.toMinutes(1);
public static final long MINUTES_IN_DAY = TimeUnit.DAYS.toMinutes(1) - 5;
private static final ResourceLoader resourceLoader = new ResourceLoader("calendar");

private final Map<String, String> defaultHeaderMap = getDefaultColumnMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3601,13 +3601,16 @@ public void doDescription(RunData data, Context context)
// "crack" the reference (a.k.a dereference, i.e. make a Reference)
// and get the event id and calendar reference
Reference ref = EntityManager.newReference(data.getParameters().getString(EVENT_REFERENCE_PARAMETER));
String eventId = ExternalCalendarSubscriptionService.decodeIdFromRecurrence(ref.getId());
String calId = null;
if(CalendarService.REF_TYPE_EVENT_SUBSCRIPTION.equals(ref.getSubType()))
String eventId;
String calId;
if (CalendarService.REF_TYPE_EVENT_SUBSCRIPTION.equals(ref.getSubType())) {
calId = CalendarService.calendarSubscriptionReference(ref.getContext(), ref.getContainer());
else
eventId = ExternalCalendarSubscriptionService.decodeIdFromRecurrence(ref.getId());
} else {
calId = CalendarService.calendarReference(ref.getContext(), ref.getContainer());

eventId = ref.getId();
}

// %%% get the event object from the reference new Reference(data.getParameters().getString(EVENT_REFERENCE_PARAMETER)).getResource() -ggolden
try
{
Expand Down
Loading

0 comments on commit 8f2142f

Please sign in to comment.