Skip to content

Commit

Permalink
SAK-40166 Allow rubric grading in Questions screen (Samigo) (sakaipro…
Browse files Browse the repository at this point in the history
…ject#6168)

* SAK-40166 Allow rubric grading in Questions screen (Samigo)

- It requires to pass a new parameter (evaluatedItemId) all around the
Rubrics structure to difference between users on the same screen.
- Each Rubric grading is a modal component, cloned the first time its
called (a workaround to make CKeditor editable and avod ids clashing).

* Update QuestionScoresBean.java
  • Loading branch information
bgarciaentornos authored and Miguel Pellicer committed Oct 31, 2018
1 parent d3271a6 commit d8e2fab
Show file tree
Hide file tree
Showing 14 changed files with 186 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public void saveRubricEvaluation(String toolId, String associatedItemId, String
Resource<ToolItemRubricAssociation> rubricToolItemAssociationResource = getRubricAssociationResource(
toolId, associatedItemId).get();

String criterionJsonData = createCriterionJsonPayload(associatedItemId, params, rubricToolItemAssociationResource);
String criterionJsonData = createCriterionJsonPayload(associatedItemId, evaluatedItemId, params, rubricToolItemAssociationResource);

if (existingEvaluation == null) { // Create a new one

Expand Down Expand Up @@ -404,7 +404,7 @@ public void saveRubricEvaluation(String toolId, String associatedItemId, String

}

private String createCriterionJsonPayload(String associatedItemId,
private String createCriterionJsonPayload(String associatedItemId, String evaluatedItemId,
Map<String,String> formPostParameters,
Resource<ToolItemRubricAssociation> association) throws Exception {

Expand Down Expand Up @@ -436,11 +436,11 @@ private String createCriterionJsonPayload(String associatedItemId,
}
index++;

final String selectedRatingPoints = criterionData.getValue().get(RubricsConstants.RBCS_PREFIX + associatedItemId + "-criterion");
final String selectedRatingPoints = criterionData.getValue().get(RubricsConstants.RBCS_PREFIX + evaluatedItemId + "-"+ associatedItemId + "-criterion");

if (StringUtils.isNotBlank(criterionData.getValue().get(RubricsConstants.RBCS_PREFIX + associatedItemId + "-criterion-override"))) {
if (StringUtils.isNotBlank(criterionData.getValue().get(RubricsConstants.RBCS_PREFIX + evaluatedItemId + "-" + associatedItemId + "-criterion-override"))) {
pointsAdjusted = true;
points = criterionData.getValue().get(RubricsConstants.RBCS_PREFIX + associatedItemId + "-criterion-override");
points = criterionData.getValue().get(RubricsConstants.RBCS_PREFIX + evaluatedItemId + "-" + associatedItemId + "-criterion-override");
} else {
pointsAdjusted = false;
points = selectedRatingPoints;
Expand All @@ -459,7 +459,7 @@ private String createCriterionJsonPayload(String associatedItemId,

criterionJsonData += String.format("{ \"criterionId\" : \"%s\", \"points\" : \"%s\", " +
"\"comments\" : \"%s\", \"pointsAdjusted\" : %b, \"selectedRatingId\" : \"%s\" }",
criterionData.getKey(), points, StringEscapeUtils.escapeJson(criterionData.getValue().get(RubricsConstants.RBCS_PREFIX + associatedItemId + "-criterion-comment")),
criterionData.getKey(), points, StringEscapeUtils.escapeJson(criterionData.getValue().get(RubricsConstants.RBCS_PREFIX + evaluatedItemId + "-"+ associatedItemId + "-criterion-comment")),
pointsAdjusted, selectedRatingId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,30 @@ <h5 class="criterion-item-title">
</div>
</div>
<div class="criterion-actions">
<sakai-rubric-grading-comment on-update-comment="updateStateDetails" criterion="{{criterionitem}}" entity-id="{{entityId}}"></sakai-rubric-grading-comment>
<sakai-rubric-grading-comment on-update-comment="updateStateDetails" criterion="{{criterionitem}}" evaluated-item-id="{{evaluatedItemId}}" entity-id="{{entityId}}"></sakai-rubric-grading-comment>

<strong class$="points-display {{isOverridden(criterionitem.pointoverride,criterionitem.selectedvalue)}}">
&nbsp;
{{criterionitem.selectedvalue}}
&nbsp;
</strong>


</strong>

<template is="dom-if" if="[[options.fineTunePoints]]">
<input type="number" min="0" max="{{criterionitem.pointrange.high}}" onkeypress="allowOnlyNumbersAndTab(event)" oninput="restrictValuesRange(event,this)" title="[[lang('point_override_details','Fine tune points by entering a number and overriding the selected rating points')]]" class="fine-tune-points form-control hide-input-arrows" id="rbcs-[[entityId]]-criterion-override-[[criterionitem.id]]" name="rbcs-[[entityId]]-criterion-override-[[criterionitem.id]]" on-input="finetuneRating" value="{{criterionitem.pointoverride::input}}">
<input type="number" min="0" max="{{criterionitem.pointrange.high}}" onkeypress="allowOnlyNumbersAndTab(event)" oninput="restrictValuesRange(event,this)" title="[[lang('point_override_details','Fine tune points by entering a number and overriding the selected rating points')]]" class="fine-tune-points form-control hide-input-arrows" id="rbcs-[[evaluatedItemId]]-[[entityId]]-criterion-override-[[criterionitem.id]]" name="rbcs-[[evaluatedItemId]]-[[entityId]]-criterion-override-[[criterionitem.id]]" on-input="finetuneRating" value="{{criterionitem.pointoverride::input}}">
</template>
<input type="hidden" id="rbcs-[[entityId]]-criterion-[[criterionitem.id]]" name="rbcs-[[entityId]]-criterion-[[criterionitem.id]]" value="{{criterionitem.selectedvalue}}">
<input aria-labelledby="[[lang('points','Points')]]" type="hidden" id="rbcs-[[evaluatedItemId]]-[[entityId]]-criterion-[[criterionitem.id]]" name="rbcs-[[evaluatedItemId]]-[[entityId]]-criterion-[[criterionitem.id]]" value="{{criterionitem.selectedvalue}}">
</div>
</div>
</template>
</div>
<div class="rubric-totals">
<input type="hidden" id="rbcs-[[entityId]]-totalpoints" name="rbcs-[[entityId]]-totalpoints" value="{{totalPoints}}">
<input type="hidden" aria-labelledby="[[lang('total','Total')]]" id="rbcs-[[evaluatedItemId]]-[[entityId]]-totalpoints" name="rbcs-[[evaluatedItemId]]-[[entityId]]-totalpoints" value="{{totalPoints}}">
<div class="total-points">
<sr-lang key="total">Total</sr-lang>: <strong>{{totalPoints}}</strong>
</div>
</div>

<input name="rbcs-[[entityId]]-state-details" id="rbcs-[[entityId]]-state-details" type="hidden" value="[[stateDetails]]">
<input aria-labelledby="[[lang('rubric','rubric')]]" name="rbcs-[[evaluatedItemId]]-[[entityId]]-state-details" id="rbcs-[[evaluatedItemId]]-[[entityId]]-state-details" type="hidden" value="[[stateDetails]]">

</template>

Expand Down Expand Up @@ -118,6 +116,9 @@ <h5 class="criterion-item-title">
},
entityId: {
type: String,
},
evaluatedItemId: {
type: String,
}
},
behaviors: [rubrics.behaviors],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</div>
<div class="popover-content form">
<div class="form-group">
<textarea class="form-control" name="rbcs-[[entityId]]-criterion-comment-[[criterion.id]]" id="criterion_[[entityId]]_comment_[[criterion.id]]" value="{{comments::keyup}}"></textarea>
<textarea aria-labelledby="[[lang('criterion_comment','Leave a comment about this criterion for the student')]]" name="rbcs-[[entityId]]-criterion-comment-[[criterion.id]]" id="criterion_[[entityId]]_comment_[[criterion.id]]" value="{{comments::keyup}}"></textarea>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ <h3>[[rubric.title]]</h3>
rubric-association="[[association]]"
state-details="[[stateDetails]]"
entity-id="[[entityId]]"
evaluated-item-id="[[evaluatedItemId]]"
evaluation-details="[[evaluation.criterionOutcomes]]"
></sakai-rubric-criterion-grading>

Expand Down Expand Up @@ -78,6 +79,9 @@ <h3>[[rubric.title]]</h3>
},
stateDetails: {
type: String,
},
evaluatedItemId: {
type: String,
}
},
rubricResponse: function(request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,7 @@ download=Download

obj=Objectives
keywords=Keywords
objPercent=Percent Correct
objPercent=Percent Correct

saver=Save
saverubricgrading = Save Rubric Grading
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

import javax.faces.event.ActionEvent;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -118,6 +120,12 @@ public class QuestionScoresBean

private String showTagsInEvaluationStyle;

@Setter @Getter
private String rubricStateDetails;

@Setter @Getter
private boolean hasAssociatedRubric;

/**
* Creates a new QuestionScoresBean object.
*/
Expand Down Expand Up @@ -990,4 +998,8 @@ public String getShowTagsInEvaluationStyle() {
public void setShowTagsInEvaluationStyle(String showTagsInEvaluationStyle) {
this.showTagsInEvaluationStyle = showTagsInEvaluationStyle;
}

public boolean isHasAssociatedRubric() {
return hasAssociatedRubric;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ public void processAction(ActionEvent ae) throws AbortProcessingException {
// RUBRICS, save the binding between the assignment and the rubric
if (assessmentBean.getAssessment() instanceof AssessmentFacade) {
String associationId = assessmentBean.getAssessmentId().toString() + "." + itemauthorbean.getItemId();
rubricsService.saveRubricAssociation(RubricsConstants.RBCS_TOOL_SAMIGO, associationId, paramUtil.getRubricConfigurationParameters(null));
rubricsService.saveRubricAssociation(RubricsConstants.RBCS_TOOL_SAMIGO, associationId, paramUtil.getRubricConfigurationParameters(null, null));
} else {
String pubAssociationId = RubricsConstants.RBCS_PUBLISHED_ASSESSMENT_ENTITY_PREFIX + assessmentBean.getAssessmentId().toString() + "." + itemauthorbean.getItemId();
rubricsService.saveRubricAssociation(RubricsConstants.RBCS_TOOL_SAMIGO, pubAssociationId, paramUtil.getRubricConfigurationParameters(null));
rubricsService.saveRubricAssociation(RubricsConstants.RBCS_TOOL_SAMIGO, pubAssociationId, paramUtil.getRubricConfigurationParameters(null, null));
}
}
catch (FinFormatException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.math.NumberUtils;
import org.sakaiproject.component.cover.ServerConfigurationService;
import org.sakaiproject.rubrics.logic.RubricsConstants;
import org.sakaiproject.rubrics.logic.RubricsService;
import org.sakaiproject.spring.SpringBeanLocator;
import org.sakaiproject.tool.assessment.data.dao.assessment.AssessmentAccessControl;
import org.sakaiproject.tool.assessment.data.dao.assessment.EvaluationModel;
import org.sakaiproject.tool.assessment.data.dao.assessment.PublishedAnswer;
Expand Down Expand Up @@ -71,8 +74,6 @@
import org.sakaiproject.util.ResourceLoader;
import org.sakaiproject.tool.assessment.data.ifc.shared.TypeIfc;

// end testing

/**
* <p>
* This handles the selection of the Question Score entry page.
Expand Down Expand Up @@ -103,6 +104,8 @@ public class QuestionScoreListener implements ActionListener,
private static final String noAnswer = ContextUtil.getLocalizedString(MSG_BUNDLE, "no_answer");
private static final String noneOfTheAbove = ContextUtil.getLocalizedString(MSG_BUNDLE, "none_above");

private RubricsService rubricsService = (RubricsService) SpringBeanLocator.getInstance().getBean("org.sakaiproject.rubrics.logic.RubricsService");

/**
* Standard process action method.
*
Expand Down Expand Up @@ -957,10 +960,11 @@ else if (results.getFirstName() != null
}
bean.setAgents(agents);
bean.setAllAgents(agents);
bean
.setTotalPeople(Integer.valueOf(bean.getAgents().size())
.toString());
bean.setTotalPeople(Integer.valueOf(bean.getAgents().size()).toString());
bean.setAgentResultsByItemGradingId(agentResultsByItemGradingIdMap);

bean.setRubricStateDetails("");
bean.setHasAssociatedRubric(rubricsService.hasAssociatedRubric(RubricsConstants.RBCS_TOOL_SAMIGO, RubricsConstants.RBCS_PUBLISHED_ASSESSMENT_ENTITY_PREFIX + bean.getPublishedId() + "." + bean.getItemId()));
}

catch (RuntimeException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
import org.sakaiproject.event.api.LearningResourceStoreService.LRS_Verb;
import org.sakaiproject.event.api.LearningResourceStoreService.LRS_Verb.SAKAI_VERB;
import org.sakaiproject.event.api.NotificationService;
import org.sakaiproject.rubrics.logic.RubricsConstants;
import org.sakaiproject.rubrics.logic.RubricsService;
import org.sakaiproject.samigo.util.SamigoConstants;
import org.sakaiproject.tool.assessment.data.dao.grading.AssessmentGradingData;
import org.sakaiproject.tool.assessment.data.dao.grading.ItemGradingAttachment;
Expand All @@ -59,8 +61,10 @@
import org.sakaiproject.tool.assessment.ui.bean.evaluation.QuestionScoresBean;
import org.sakaiproject.tool.assessment.ui.bean.evaluation.TotalScoresBean;
import org.sakaiproject.tool.assessment.ui.listener.util.ContextUtil;
import org.sakaiproject.tool.assessment.util.ParameterUtil;
import org.sakaiproject.tool.assessment.util.SamigoLRSStatements;
import org.sakaiproject.tool.assessment.util.TextFormat;
import org.sakaiproject.tool.cover.SessionManager;

/**
* <p>
Expand All @@ -78,6 +82,7 @@ public class QuestionScoreUpdateListener
implements ActionListener
{
private final EventTrackingService eventTrackingService= ComponentManager.get( EventTrackingService.class );
private final RubricsService rubricsService = ComponentManager.get(RubricsService.class);

//private static EvaluationListenerUtil util;
//private static BeanSort bs;
Expand Down Expand Up @@ -126,6 +131,7 @@ public boolean saveQuestionScores(QuestionScoresBean bean, TotalScoresBean tbean
{
try
{
ParameterUtil paramUtil = new ParameterUtil();
GradingService delegate = new GradingService();
//String publishedId = ContextUtil.lookupParam("publishedId");
String itemId = ContextUtil.lookupParam("itemId");
Expand Down Expand Up @@ -234,6 +240,11 @@ public boolean saveQuestionScores(QuestionScoresBean bean, TotalScoresBean tbean
hasUpdateAttachment = true;
updateAttachment(data, ar, bean);
}

// Persist the rubric evaluation
String entityId = RubricsConstants.RBCS_PUBLISHED_ASSESSMENT_ENTITY_PREFIX + bean.getPublishedId() + "." + bean.getItemId();
String evaluatedItemId = ar.getAssessmentGradingId() + "." + bean.getItemId();
rubricsService.saveRubricEvaluation(RubricsConstants.RBCS_TOOL_SAMIGO, entityId, evaluatedItemId, ar.getIdString(), SessionManager.getCurrentSessionUserId(), paramUtil.getRubricConfigurationParameters(entityId, evaluatedItemId));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public void processAction(ActionEvent event) throws AbortProcessingException {
for (Object questionObj : sectionContent.getItemContents()) {
ItemContentsBean question = (ItemContentsBean) questionObj;
String entityId = RubricsConstants.RBCS_PUBLISHED_ASSESSMENT_ENTITY_PREFIX + tbean.getPublishedId() + "." + question.getItemData().getItemId();
String rubricStateDetails = ContextUtil.lookupParam(RubricsConstants.RBCS_PREFIX + entityId + "-state-details");
String evalId = studentScoresBean.getAssessmentGradingId() + "." + question.getItemData().getItemId();
String rubricStateDetails = ContextUtil.lookupParam(RubricsConstants.RBCS_PREFIX + evalId + "-" + entityId + "-state-details");
question.setRubricStateDetails(rubricStateDetails);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ public boolean saveStudentScores(StudentScoresBean bean, TotalScoresBean tbean,

// Persist the rubric evaluation
String entityId = RubricsConstants.RBCS_PUBLISHED_ASSESSMENT_ENTITY_PREFIX + tbean.getPublishedId() + "." + question.getItemData().getItemId();
rubricsService.saveRubricEvaluation(RubricsConstants.RBCS_TOOL_SAMIGO, entityId, bean.getAssessmentGradingId() + "." + question.getItemData().getItemId(), bean.getStudentId(), SessionManager.getCurrentSessionUserId(), paramUtil.getRubricConfigurationParameters(entityId));
String evaluatedItemId = bean.getAssessmentGradingId() + "." + question.getItemData().getItemId();
rubricsService.saveRubricEvaluation(RubricsConstants.RBCS_TOOL_SAMIGO, entityId, evaluatedItemId, bean.getStudentId(), SessionManager.getCurrentSessionUserId(), paramUtil.getRubricConfigurationParameters(entityId, evaluatedItemId));

List<ItemGradingData> gradingarray = question.getItemGradingDataArray();
log.debug("****1. pub questionId = " + question.getItemData().getItemId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ public class ParameterUtil {
* @param entityId Entity ID of a rubric association
* @return Map of parameters key and parameters value
*/
public Map<String,String> getRubricConfigurationParameters(String entityId) {
public Map<String,String> getRubricConfigurationParameters(String entityId, String evaluatedItemId) {
FacesContext context = FacesContext.getCurrentInstance();
Map<String, String> requestParams = context.getExternalContext().getRequestParameterMap();
Map<String, String> list = new HashMap<>();

String entity = RubricsConstants.RBCS_PREFIX;
if (evaluatedItemId != null && !evaluatedItemId.isEmpty()) {
entity += evaluatedItemId + "-";
}
if (entityId != null && !entityId.isEmpty()) {
entity += entityId + "-";
}
Expand Down
Loading

0 comments on commit d8e2fab

Please sign in to comment.