Skip to content

Commit

Permalink
SAK-44879 Allow marking rubric associations active (sakaiproject#8952)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianfish authored Feb 11, 2021
1 parent adb07d7 commit 17f4990
Show file tree
Hide file tree
Showing 20 changed files with 168 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3830,14 +3830,12 @@ protected String build_instructor_grade_submission_context(VelocityPortlet portl
if (state.getAttribute(GRADE_SUBMISSION_DONE) != null) {
context.put("gradingDone", Boolean.TRUE);
state.removeAttribute(GRADE_SUBMISSION_DONE);
state.removeAttribute(RUBRIC_STATE_DETAILS);
}

// put the grade confirmation message if applicable
if (state.getAttribute(GRADE_SUBMISSION_SUBMIT) != null) {
context.put("gradingSubmit", Boolean.TRUE);
state.removeAttribute(GRADE_SUBMISSION_SUBMIT);
state.removeAttribute(RUBRIC_STATE_DETAILS);
}

// letter grading
Expand All @@ -3846,10 +3844,6 @@ protected String build_instructor_grade_submission_context(VelocityPortlet portl
// Check if the assignment has a rubric associated or not
context.put("hasAssociatedRubric", assignment.isPresent() && rubricsService.hasAssociatedRubric(RubricsConstants.RBCS_TOOL_ASSIGNMENT, assignment.get().getId()));

if (state.getAttribute(RUBRIC_STATE_DETAILS) != null) {
context.put(RUBRIC_STATE_DETAILS, state.getAttribute(RUBRIC_STATE_DETAILS));
}

String siteId = (String) state.getAttribute(STATE_CONTEXT_STRING);
String toolId = toolManager.getCurrentPlacement().getId();

Expand Down Expand Up @@ -4118,7 +4112,6 @@ public void doPrev_back_next_submission(RunData rundata, String option) {
}

if (state.getAttribute(STATE_MESSAGE) == null) {
state.removeAttribute(RUBRIC_STATE_DETAILS);
if ("back".equals(option)) {
// SAK-29314 - calculate our position relative to the list so we can return to the correct page
state.setAttribute(STATE_GOTO_PAGE, calcPageFromSubmission(state));
Expand Down Expand Up @@ -5820,7 +5813,6 @@ public void doCancel_grade_submission(RunData data) {
} else {
state.setAttribute(STATE_MODE, MODE_INSTRUCTOR_GRADE_SUBMISSION);
}
state.removeAttribute(RUBRIC_STATE_DETAILS);
} // doCancel_grade_submission

/**
Expand Down Expand Up @@ -5851,8 +5843,6 @@ private void resetGradeSubmission(SessionState state) {
// SAK-29314
state.removeAttribute(STATE_VIEW_SUBS_ONLY);

state.removeAttribute(RUBRIC_STATE_DETAILS);

resetAllowResubmitParams(state);
}

Expand Down Expand Up @@ -5896,7 +5886,6 @@ public void doList_assignments(RunData data) {
state.setAttribute(STATE_MODE, MODE_LIST_ASSIGNMENTS);
state.setAttribute(SORTED_BY, SORTED_BY_DEFAULT);
state.setAttribute(SORTED_ASC, Boolean.TRUE.toString());
state.removeAttribute(RUBRIC_STATE_DETAILS);

} // doList_assignments

Expand Down Expand Up @@ -6104,7 +6093,6 @@ private void grade_submission_option(RunData data, String gradeOption) {

// Remove any rubrics related state
state.getAttributeNames().stream().filter(n -> n.startsWith(RubricsConstants.RBCS_PREFIX)).forEach(state::removeAttribute);
state.removeAttribute(RUBRIC_STATE_DETAILS);

// SAK-29314 - update the list being iterated over
sizeResources(state);
Expand Down Expand Up @@ -6838,10 +6826,6 @@ private void setNewAssignmentParameters(RunData data, boolean validify) {
String order = params.getString(NEW_ASSIGNMENT_ORDER);
state.setAttribute(NEW_ASSIGNMENT_ORDER, order);

//Returns the rubrics state in the case of validation problems in the form
String rubricStateDetails = params.getString(RUBRIC_STATE_DETAILS);
state.setAttribute(RUBRIC_STATE_DETAILS, rubricStateDetails);

String contextString = toolManager.getCurrentPlacement().getContext();

boolean groupAssignment = rangeAndGroups.setNewOrEditedAssignmentParameters(data, state, contextString);
Expand Down Expand Up @@ -9907,7 +9891,8 @@ public void doHardRemove_confirm_assignment(RunData data) {
}

// remove rubric association if there is one
rubricsService.deleteRubricAssociation(RubricsConstants.RBCS_TOOL_ASSIGNMENT, id);
// TODO: this should be in the service and in a transaction!!
rubricsService.deleteRubricAssociationsByItemIdPrefix(id, RubricsConstants.RBCS_TOOL_ASSIGNMENT);

assignmentService.deleteAssignment(a);
}
Expand Down Expand Up @@ -10993,15 +10978,6 @@ public boolean readGradeForm(RunData data, SessionState state, String gradeOptio
state.setAttribute(GRADE_SUBMISSION_FEEDBACK_COMMENT, feedbackComment);
}

// Pour any rubrics parameters into the state
Iterable<String> iterable = () -> params.getNames();
StreamSupport.stream(iterable.spliterator(), false).filter(n -> n.startsWith(RubricsConstants.RBCS_PREFIX)).forEach(n -> {
if (n.endsWith("state-details")) {
state.setAttribute(RUBRIC_STATE_DETAILS, params.get(n));
}
state.setAttribute(n, params.get(n));
});

String feedbackText = processAssignmentFeedbackFromBrowser(state, params.getCleanString(GRADE_SUBMISSION_FEEDBACK_TEXT));
// feedbackText value changed?
hasChange = !hasChange && submission != null ? valueDiffFromStateAttribute(state, feedbackText, submission.getFeedbackText()) : hasChange;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@
import org.sakaiproject.assignment.api.model.AssignmentSubmissionSubmitter;
import org.sakaiproject.entity.api.Reference;
import org.sakaiproject.exception.PermissionException;
import org.sakaiproject.rubrics.logic.RubricsConstants;
import org.sakaiproject.rubrics.logic.RubricsService;
import org.sakaiproject.service.gradebook.shared.AssignmentHasIllegalPointsException;
import org.sakaiproject.service.gradebook.shared.ConflictingAssignmentNameException;
import org.sakaiproject.service.gradebook.shared.GradebookExternalAssessmentService;
Expand Down Expand Up @@ -87,7 +85,6 @@ public class AssignmentToolUtils {
private GradebookExternalAssessmentService gradebookExternalAssessmentService;
private GradebookFrameworkService gradebookFrameworkService;
private GradebookService gradebookService;
private RubricsService rubricsService;
private TimeService timeService;
private ToolManager toolManager;
private LTIService ltiService;
Expand Down
1 change: 0 additions & 1 deletion assignment/tool/src/webapp/WEB-INF/applicationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<property name="gradebookExternalAssessmentService" ref="org.sakaiproject.service.gradebook.GradebookExternalAssessmentService" />
<property name="gradebookFrameworkService" ref="org.sakaiproject.service.gradebook.GradebookFrameworkService"/>
<property name="gradebookService" ref="org.sakaiproject.service.gradebook.GradebookService" />
<property name="rubricsService" ref="org.sakaiproject.rubrics.logic.RubricsService"/>
<property name="toolManager" ref="org.sakaiproject.tool.api.ToolManager"/>
<property name="userDirectoryService" ref="org.sakaiproject.user.api.UserDirectoryService" />
<property name="timeService" ref="org.sakaiproject.time.api.TimeService" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,6 @@
entity-id="$assignment.Id"
evaluated-item-id="$submission.Id"
evaluated-item-owner-id="$submitterId"

#if($!rbcs-state-details && "$!rbcs-state-details" != "")
state-details='$rbcs-state-details'
#end
></sakai-rubric-grading>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,19 @@ This section contains the options for grading this assignment, including rubrics

## Rubrics
<div class="form-group">
<sakai-rubric-association token="$!rbcs-token" dont-associate-label="$tlang.getString("dont.associate.label")"
dont-associate-value="0" associate-label="$tlang.getString("associate.label")" associate-value="1" tool-id="sakai.assignment"
#if("$!assignment.Id" != "") entity-id="$assignment.Id" #end
#if($rbcs-state-details && "$!rbcs-state-details" != "") state-details="$rbcs-state-details" #end
fine-tune-points="$tlang.getString("option.pointsoverride")" hide-student-preview="$tlang.getString("option.studentpreview")">
<sakai-rubric-association
token="$!rbcs-token"
dont-associate-label="$tlang.getString("dont.associate.label")"
dont-associate-value="0"
associate-label="$tlang.getString("associate.label")"
associate-value="1"
tool-id="sakai.assignment"
#if("$!assignment.Id" != "")
entity-id="$assignment.Id"
#end
fine-tune-points="$tlang.getString("option.pointsoverride")"
hide-student-preview="$tlang.getString("option.studentpreview")"
>
</sakai-rubric-association>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2529,7 +2529,8 @@ public void updateGradebookSettings(final GradebookInformation settings) {
* @param assignmentId the id of the assignment to remove
*/
public void removeAssignment(final Long assignmentId) {
rubricsService.deleteRubricAssociation(RubricsConstants.RBCS_TOOL_GRADEBOOKNG, assignmentId.toString());

rubricsService.deleteRubricAssociationsByItemIdPrefix(assignmentId.toString(), RubricsConstants.RBCS_TOOL_GRADEBOOKNG);
this.gradebookService.removeAssignment(assignmentId);

EventHelper.postDeleteAssignmentEvent(getGradebook(), assignmentId, getUserRoleOrNone());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,6 @@ public class DiscussionForumTool {
private boolean gradeByPercent;
private boolean gradeByLetter;

private static final String RUBRIC_STATE_DETAILS = "rbcs-state-details";
private static final String RUBRIC_TOKEN = "rbcs-token";
private String rbcsStateDetails = "";

/**
* Dependency Injected
*/
Expand Down Expand Up @@ -1085,9 +1081,6 @@ public String processActionDeleteForum() {

forumManager.deleteForum(selectedForum.getForum());

// remove rubric association if there is one
//rubricsService.deleteRubricAssociation(RubricsConstants.RBCS_TOOL_FORUMS, RubricsConstants.RBCS_FORUM_ENTITY_PREFIX + forumId);

if(beforeChangeHM != null){
updateSynopticMessagesForForumComparingOldMessagesCount(getSiteId(), forumId, null, beforeChangeHM, SynopticMsgcntrManager.NUM_OF_ATTEMPTS);
}
Expand Down Expand Up @@ -2046,9 +2039,6 @@ public String processActionDeleteTopic() {

forumManager.deleteTopic(selectedTopic.getTopic());

// remove rubric association if there is one
//rubricsService.deleteRubricAssociation(RubricsConstants.RBCS_TOOL_FORUMS, RubricsConstants.RBCS_TOPIC_ENTITY_PREFIX + topicId);

if(beforeChangeHM != null){
updateSynopticMessagesForForumComparingOldMessagesCount(getSiteId(), forumId, topicId, beforeChangeHM, SynopticMsgcntrManager.NUM_OF_ATTEMPTS);
}
Expand Down Expand Up @@ -3448,7 +3438,6 @@ private void reset()
prepareRemoveAttach.clear();
assignments.clear();
refreshPendingMsgs = true;
rbcsStateDetails = "";
}

/**
Expand Down Expand Up @@ -5838,7 +5827,6 @@ public String processDfGradeSubmitFromDialog(){

public String processDfGradeSubmit()
{
keepStateDetails(null);
GradebookService gradebookService = getGradebookService();
if (gradebookService == null) {
// Maybe print an error message if it's possible to get into this state
Expand Down Expand Up @@ -7890,18 +7878,6 @@ private DiscussionForumBean duplicateForum(Long originalForumId) {

forum = saveForumSettings(oldForum.getDraft());

//copy rubrics
/*
try {
Optional<ToolItemRubricAssociation> rubricAssociation = rubricsService.getRubricAssociation(RubricsConstants.RBCS_TOOL_FORUMS, RubricsConstants.RBCS_FORUM_ENTITY_PREFIX + oldForum.getId());
if (rubricAssociation.isPresent()) {
rubricsService.saveRubricAssociation(RubricsConstants.RBCS_TOOL_FORUMS, RubricsConstants.RBCS_FORUM_ENTITY_PREFIX + forum.getId(), rubricAssociation.get().getFormattedAssociation());
}
} catch(Exception e){
log.error("Error while trying to duplicate Rubrics: {} ", e.getMessage());
}
*/

forum = forumManager.getForumById(forum.getId());
List attachList = forum.getAttachments();
if (attachList != null)
Expand Down Expand Up @@ -9189,17 +9165,6 @@ public String getRbcsToken() {
return rubricsService.generateJsonWebToken(RubricsConstants.RBCS_TOOL_FORUMS);
}

public void keepStateDetails(ActionEvent e) {//this is currently only used for rubrics, but could be used to avoid repeating code on each submit action
List rbcsDetails = getRequestParamArrayValueLike("rbcs-state-details");
if(rbcsDetails != null){
Iterator iter = rbcsDetails.iterator();
if (iter.hasNext()) {
rbcsStateDetails = (String)iter.next();
log.debug("rbcsStateDetails " + rbcsStateDetails);
}
}
}

public boolean hasAssociatedRubric(){
return (allowedToGradeItem && (getRubricAssociationId() != null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,6 @@
});
}
</script>
<!-- RUBRICS VARIABLES -->
<%
FacesContext fcontext = FacesContext.getCurrentInstance();
Application appl = fcontext.getApplication();
ValueBinding vbinding = appl.createValueBinding("#{ForumTool}");
DiscussionForumTool forumTool = (DiscussionForumTool) vbinding.getValue(fcontext);
String stateDetails = forumTool.getRbcsStateDetails();
%>
<!-- END RUBRICS VARIABLES -->

<!-- Y:\msgcntr\messageforums-app\src\webapp\jsp\dfReviseForumSettingsAttach.jsp -->
<h:form id="revise">
Expand Down Expand Up @@ -401,15 +392,15 @@


<h:panelGroup layout="block" styleClass="act">
<h:commandButton action="#{ForumTool.processActionSaveForumSettings}" actionListener="#{ForumTool.keepStateDetails}" value="#{msgs.cdfm_button_bar_save_setting}"
<h:commandButton action="#{ForumTool.processActionSaveForumSettings}" value="#{msgs.cdfm_button_bar_save_setting}"
rendered="#{!ForumTool.selectedForum.markForDeletion}" accesskey="s" styleClass="blockMeOnClick active">
<f:param value="#{ForumTool.selectedForum.forum.id}" name="forumId"/>
</h:commandButton>
<h:commandButton id="saveandadd" action="#{ForumTool.processActionSaveForumAndAddTopic}" actionListener="#{ForumTool.keepStateDetails}" value="#{msgs.cdfm_button_bar_save_setting_add_topic}" accesskey="t"
<h:commandButton id="saveandadd" action="#{ForumTool.processActionSaveForumAndAddTopic}" value="#{msgs.cdfm_button_bar_save_setting_add_topic}" accesskey="t"
rendered = "#{!ForumTool.selectedForum.markForDeletion}" styleClass="blockMeOnClick">
<f:param value="#{ForumTool.selectedForum.forum.id}" name="forumId"/>
</h:commandButton>
<h:commandButton action="#{ForumTool.processActionSaveForumAsDraft}" actionListener="#{ForumTool.keepStateDetails}" value="#{msgs.cdfm_button_bar_save_draft}" accesskey="v"
<h:commandButton action="#{ForumTool.processActionSaveForumAsDraft}" value="#{msgs.cdfm_button_bar_save_draft}" accesskey="v"
rendered = "#{!ForumTool.selectedForum.markForDeletion}" styleClass="blockMeOnClick">
<f:param value="#{ForumTool.selectedForum.forum.id}" name="forumId"/>
</h:commandButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
Application appl = fcontext.getApplication();
ValueBinding vbinding = appl.createValueBinding("#{ForumTool}");
DiscussionForumTool forumTool = (DiscussionForumTool) vbinding.getValue(fcontext);
String stateDetails = forumTool.getRbcsStateDetails();
String entityId = "top." + forumTool.getSelectedTopic().getTopic().getId();
%>
<!-- END RUBRICS VARIABLES -->
Expand Down Expand Up @@ -391,9 +390,6 @@
<% if(entityId != null && !"".equals(entityId)){ %>
entity-id=<%= entityId %>
<%}%>
<% if(stateDetails != null && !"".equals(stateDetails)){ %>
state-details=<%= stateDetails %>
<%}%>

fine-tune-points='<h:outputText value="#{msgs.option_pointsoverride}" />'
hide-student-preview='<h:outputText value="#{msgs.option_studentpreview}" />'
Expand Down Expand Up @@ -456,17 +452,17 @@
});
</script>
<div class="act">
<h:commandButton action="#{ForumTool.processActionSaveTopicSettings}" actionListener="#{ForumTool.keepStateDetails}" value="#{msgs.cdfm_button_bar_save_setting}" accesskey="s"
<h:commandButton action="#{ForumTool.processActionSaveTopicSettings}" value="#{msgs.cdfm_button_bar_save_setting}" accesskey="s"
rendered="#{!ForumTool.selectedTopic.markForDeletion}" styleClass="blockMeOnClick active">
<f:param value="#{ForumTool.selectedTopic.topic.id}" name="topicId"/>
<f:param value="#{ForumTool.selectedForum.forum.id}" name="forumId"/>
</h:commandButton>
<h:commandButton action="#{ForumTool.processActionSaveTopicAsDraft}" actionListener="#{ForumTool.keepStateDetails}" value="#{msgs.cdfm_button_bar_save_draft}" accesskey="v"
<h:commandButton action="#{ForumTool.processActionSaveTopicAsDraft}" value="#{msgs.cdfm_button_bar_save_draft}" accesskey="v"
rendered="#{!ForumTool.selectedTopic.markForDeletion}" styleClass="blockMeOnClick">
<f:param value="#{ForumTool.selectedTopic.topic.id}" name="topicId"/>
<f:param value="#{ForumTool.selectedForum.forum.id}" name="forumId"/>
</h:commandButton>
<h:commandButton action="#{ForumTool.processActionSaveTopicAndAddTopic}" actionListener="#{ForumTool.keepStateDetails}" value="#{msgs.cdfm_button_bar_save_setting_add_topic}" accesskey="t"
<h:commandButton action="#{ForumTool.processActionSaveTopicAndAddTopic}" value="#{msgs.cdfm_button_bar_save_setting_add_topic}" accesskey="t"
rendered="#{!ForumTool.selectedTopic.markForDeletion}" styleClass="blockMeOnClick">
<f:param value="#{ForumTool.selectedTopic.topic.id}" name="topicId"/>
<f:param value="#{ForumTool.selectedForum.forum.id}" name="forumId"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
<%
}
String stateDetails = forumTool.getRbcsStateDetails();
boolean hasAssociatedRubric = forumTool.hasAssociatedRubric();
String entityId = forumTool.getRubricAssociationId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1086,8 +1086,6 @@ public void deleteDiscussionForum(DiscussionForum forum) {
forum = (DiscussionForum) getForumById(true, id);
List<Topic> topics = getTopicsByIdWithMessages(id);
for (Topic topic : topics) {
// remove rubric association if there is one
rubricsService.deleteRubricAssociation(RubricsConstants.RBCS_TOOL_FORUMS, RubricsConstants.RBCS_TOPIC_ENTITY_PREFIX + topic.getId());
forum.removeTopic(topic);
getSessionFactory().getCurrentSession().merge(topic);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@
@JsonPropertyOrder({"id", "toolId", "itemId", "rubricId", "parameters", "metadata"})
@NoArgsConstructor
@Table(name = "rbc_tool_item_rbc_assoc",
indexes = {@Index(name = "rbc_tool_item_owner", columnList = "toolId, itemId, ownerId")},
uniqueConstraints = @UniqueConstraint(columnNames = {"rubric_id", "toolId", "itemId"})
indexes = {@Index(name = "rbc_tool_item_owner", columnList = "toolId, itemId, ownerId")}
)
@ToString(exclude = {"rubric", "parameters"})
public class ToolItemRubricAssociation implements Modifiable, Serializable, Cloneable {
Expand All @@ -91,6 +90,9 @@ public class ToolItemRubricAssociation implements Modifiable, Serializable, Clon
@Embedded
private Metadata metadata;

@Column(name = "active", nullable = false)
private boolean active;

@ElementCollection
@CollectionTable(name = "rbc_tool_item_rbc_assoc_conf", joinColumns = @JoinColumn(name = "association_id", referencedColumnName = "id"))
@MapKeyColumn(name = "parameter_label")
Expand Down
Loading

0 comments on commit 17f4990

Please sign in to comment.