Skip to content

Commit

Permalink
Merge branch 'master' into feature/SAK-29396_gb_refactor
Browse files Browse the repository at this point in the history
Conflicts:
	edu-services/gradebook-service/api/src/java/org/sakaiproject/service/gradebook/shared/GradebookService.java
	edu-services/gradebook-service/impl/src/java/org/sakaiproject/component/gradebook/GradebookServiceHibernateImpl.java

SAK-29396
  • Loading branch information
steveswinsburg committed May 28, 2015
2 parents 07f7286 + 76b6bdd commit de4b850
Show file tree
Hide file tree
Showing 39 changed files with 1,243 additions and 338 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ stuviewsubm.attfromserverlabelmore= or select more files from workspace or site
feedbacktext = Feedback Text
stuviewsubm.submitreminder=Don't forget to save or submit!
stuviewsubm.modifytoresubmit=You may resubmit if you modify this submission.
stuviewsubm.reminder=Don't forget to submit
stuviewsubm.reminder=Don't forget to submit!
feedbackcomment = Feedback Comment

stuviewsubm.typesubhaschanged.inline = The submission type for this assignment has changed. This text from your previous submission is for your reference only and will NOT be included if you resubmit.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1520,12 +1520,12 @@ protected String build_student_view_submission_context(VelocityPortlet portlet,

// the attachments from the previous submission
List submittedAttachments = s.getSubmittedAttachments();
newAttachments = areAttachmentsNew(submittedAttachments, currentAttachments);
newAttachments = areAttachmentsModified(submittedAttachments, currentAttachments);
}
else
{
// There is no previous submission, attachments are modified if anything has been uploaded
newAttachments = currentAttachments != null && !currentAttachments.isEmpty();
newAttachments = CollectionUtils.isNotEmpty(currentAttachments);
}

// put the resubmit information into context
Expand Down Expand Up @@ -1615,17 +1615,20 @@ protected String build_student_view_submission_context(VelocityPortlet portlet,
} // build_student_view_submission_context

/**
* Determines if there are new attachments
* @return true if currentAttachments is not empty and isn't equal to oldAttachments
* Determines if the attachments have been modified
* @return true if currentAttachments isn't equal to oldAttachments
*/
private boolean areAttachmentsNew(List oldAttachments, List currentAttachments)
private boolean areAttachmentsModified(List oldAttachments, List currentAttachments)
{
if (currentAttachments == null || currentAttachments.isEmpty())
boolean hasCurrent = CollectionUtils.isNotEmpty(currentAttachments);
boolean hasOld = CollectionUtils.isNotEmpty(oldAttachments);

if (!hasCurrent)
{
//there are no current attachments
return false;
return hasOld;
}
if (oldAttachments == null || oldAttachments.isEmpty())
if (!hasOld)
{
//there are no old attachments (and there are new ones)
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,8 @@ function enableSubmitUnlessNoFile(checkForFile)

#if ($submitted && ($submissionType == 2 || $submissionType == 5) && !$!new_attachments)
<span class="messageInformation">$tlang.getString("stuviewsubm.modifytoresubmit")</span>
#elseif ($submissionType == 5)
<span class="messageInformation">$tlang.getString("stuviewsubm.reminder")</span>
#else
<span class="messageInformation">$tlang.getString("stuviewsubm.submitreminder")</span>
#end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2796,7 +2796,7 @@ protected void copy(BasicCitationCollection other)
this.m_comparator = new MultipleKeyComparator( TITLE_AS_KEY, true );
}

set(other);
set(other, true);

}

Expand Down Expand Up @@ -3181,7 +3181,7 @@ protected void checkForUpdates()
}
else
{
set((BasicCitationCollection) edit);
set((BasicCitationCollection) edit, false);
}
}

Expand All @@ -3191,7 +3191,7 @@ protected void checkForUpdates()
* copy
* @param other
*/
protected void set(BasicCitationCollection other)
protected void set(BasicCitationCollection other, boolean isTemporary)
{
this.m_description = other.m_description;
// this.m_comparator = other.m_comparator;
Expand Down Expand Up @@ -3220,7 +3220,7 @@ protected void set(BasicCitationCollection other)
{
newCitation.copy(oldCitation);
newCitation.m_id = oldCitation.m_id;
newCitation.m_temporary = false;
newCitation.m_temporary = isTemporary;
this.saveCitation(newCitation);
this.add(newCitation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

<query name="findCurrentlyInstructingEnrollmentSets">
<![CDATA[
from EnrollmentSetCmImpl as enrollmentSet where :userId in elements(enrollmentSet.officialInstructors) and
from EnrollmentSetCmImpl as enrollmentSet join enrollmentSet.officialInstructors as instructor where :userId = instructor and
(enrollmentSet.courseOffering.startDate is null or enrollmentSet.courseOffering.startDate <= current_date()) and
(enrollmentSet.courseOffering.endDate is null or enrollmentSet.courseOffering.endDate >= current_date())
]]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@

<query name="findInstructingSections">
<![CDATA[
select sec from SectionCmImpl as sec, EnrollmentSetCmImpl as es
where :userId in elements(es.officialInstructors) and
select sec from SectionCmImpl as sec, EnrollmentSetCmImpl as es join es.officialInstructors as instructor
where :userId = instructor and
sec.enrollmentSet = es
]]>
</query>

<query name="findInstructingSectionsByAcademicSession">
<![CDATA[
select sec from SectionCmImpl as sec, EnrollmentSetCmImpl as es
where :userId in elements(es.officialInstructors) and
select sec from SectionCmImpl as sec, EnrollmentSetCmImpl as es join es.officialInstructors as instructor
where :userId = instructor and
sec.enrollmentSet = es and
sec.courseOffering.academicSession.eid=:academicSessionEid
]]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,12 @@ public String toString() {
.append(getDescription())
.toString();
}

protected boolean isTitleEmpty() {
return title == null || title.length() == 0;
}

protected boolean isDescriptionEmpty() {
return description == null || description.length() == 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,22 @@ public String getStatus() {
public void setStatus(String status) {
this.status = status;
}

@Override
public String getTitle() {
if (isTitleEmpty() && canonicalCourse != null) {
return canonicalCourse.getTitle();
}

return title;
}

@Override
public String getDescription() {
if (isDescriptionEmpty() && canonicalCourse != null) {
return canonicalCourse.getDescription();
}

return description;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,22 @@ public void setOfficialInstructors(Set officialInstructors) {
this.officialInstructors = officialInstructors;
}

@Override
public String getTitle() {
if (isTitleEmpty() && courseOffering != null) {
return courseOffering.getTitle();
}

return title;
}

@Override
public String getDescription() {
if (isDescriptionEmpty() && courseOffering != null) {
return courseOffering.getDescription();
}

return description;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,22 @@ public Integer getMaxSize() {
public void setMaxSize(Integer maxSize) {
this.maxSize = maxSize;
}

@Override
public String getTitle() {
if (isTitleEmpty() && enrollmentSet != null) {
return enrollmentSet.getTitle();
}

return title;
}

@Override
public String getDescription() {
if (isDescriptionEmpty() && enrollmentSet != null) {
return enrollmentSet.getDescription();
}

return description;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,14 @@ public boolean isAssignmentDefined(String gradebookUid, String assignmentTitle)
* @return A mapping from user display IDs to grades.
*/
public Map<String,String> getImportCourseGrade(String gradebookUid, boolean useDefault);


/**
* @param gradebookUid
* @param useDefault If true, assume zero for missing grades. Otherwise, null.
* @param mapTheGrades If true, map the numerical grade to letter grade. If false, return a string of the numerical grade.
* @return A mapping from user display IDs to grades.
*/
public Map<String,String> getImportCourseGrade(String gradebookUid, boolean useDefault, boolean mapTheGrades);

/**
* Get the Gradebook. Note that this returns Object to avoid circular dependency with sakai-gradebook-tool
Expand All @@ -438,13 +445,15 @@ public boolean isAssignmentDefined(String gradebookUid, String assignmentTitle)
public Object getGradebook(String uid) throws GradebookNotFoundException;

/**
* Check if there are students that have not submitted
*
* @param gradebookUid
* @return
*/
public boolean checkStudentsNotSubmitted(String gradebookUid);

/**
* Check if a gradeable object with the given id exists
*
* @param gradableObjectId
* @return true if a gradable object with the given id exists and was not
Expand All @@ -461,12 +470,15 @@ public boolean isAssignmentDefined(String gradebookUid, String assignmentTitle)
public Map<String,String> getViewableSectionUuidToNameMap(String gradebookUid);

/**
* Check if the current user has the gradebook.gradeAll permission
*
* @param gradebookUid
* @return true if current user has the gradebook.gradeAll permission
*/
public boolean currentUserHasGradeAllPerm(String gradebookUid);

/**
* Check if the given user is allowed to grade all students in this gradebook
*
* @param gradebookUid
* @param userUid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,22 +647,21 @@ public Object doInHibernate(Session session) throws HibernateException {
}

@Override
public Map<String,String> getImportCourseGrade(String gradebookUid)
public Map<String, String> getImportCourseGrade(String gradebookUid)
{
return getImportCourseGrade(gradebookUid, true);
return getImportCourseGrade(gradebookUid, true, true);
}

@Override
public Map<String, String> getImportCourseGrade(String gradebookUid, boolean useDefault)
{
return getImportCourseGrade(gradebookUid, useDefault, true);
}

/**
* @param gradebookUid
* @param useDefault If true, assume zero for missing grades. Otherwise, null.
* @return A mapping from user display IDs to grades.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Map<String,String> getImportCourseGrade(String gradebookUid, boolean useDefault)
public Map<String, String> getImportCourseGrade(String gradebookUid, boolean useDefault, boolean mapTheGrades)
{
HashMap<String,String> returnMap = new HashMap<>();
HashMap<String, String> returnMap = new HashMap<String, String> ();

try
{
Expand All @@ -679,9 +678,9 @@ public Map<String,String> getImportCourseGrade(String gradebookUid, boolean useD
CourseGrade courseGrade = getCourseGrade(gradebookId);

Map viewableEnrollmentsMap = authz.findMatchingEnrollmentsForViewableCourseGrade(gradebookUid, thisGradebook.getCategory_type(), null, null);
Map enrollmentMap = new HashMap();
Map<String, EnrollmentRecord> enrollmentMap = new HashMap<String, EnrollmentRecord>();

Map enrollmentMapUid = new HashMap();
Map<String, EnrollmentRecord> enrollmentMapUid = new HashMap<String, EnrollmentRecord>();
for (Iterator iter = viewableEnrollmentsMap.keySet().iterator(); iter.hasNext(); )
{
EnrollmentRecord enr = (EnrollmentRecord)iter.next();
Expand All @@ -695,33 +694,45 @@ public Map<String,String> getImportCourseGrade(String gradebookUid, boolean useD

GradeMapping gradeMap= thisGradebook.getSelectedGradeMapping();

EnrollmentRecord enr = (EnrollmentRecord)enrollmentMapUid.get(gradeRecord.getStudentId());
EnrollmentRecord enr = enrollmentMapUid.get(gradeRecord.getStudentId());
if(enr != null)
{
if(gradeRecord.getEnteredGrade() != null && !gradeRecord.getEnteredGrade().equalsIgnoreCase(""))
// SAK-29243: if we are not mapping grades, we don't want letter grade here
if(mapTheGrades && StringUtils.isNotBlank(gradeRecord.getEnteredGrade()))
{
returnMap.put(enr.getUser().getDisplayId(), gradeRecord.getEnteredGrade());
}
else
{
if(!nonAssignment) {
String grade = null;
Double grade = null;

if(useDefault)
{
grade = gradeRecord.getNonNullAutoCalculatedGrade();
}
else
{
grade = gradeRecord.getAutoCalculatedGrade();
}

if(useDefault) {
grade = (String)gradeMap.getGrade(gradeRecord.getNonNullAutoCalculatedGrade());
} else {
grade = (String)gradeMap.getGrade(gradeRecord.getAutoCalculatedGrade());
}
if(mapTheGrades)
{
returnMap.put(enr.getUser().getDisplayId(), (String)gradeMap.getGrade(grade));
}
else
{
returnMap.put(enr.getUser().getDisplayId(), grade.toString());
}

returnMap.put(enr.getUser().getDisplayId(), grade);
}
}
}
}
}
catch(Exception e)
{
e.printStackTrace();
log.error("Error in getImportCourseGrade", e);
}
return returnMap;
}
Expand All @@ -734,7 +745,7 @@ public CourseGrade getCourseGrade(Long gradebookId) {
}

@SuppressWarnings({ "unchecked", "rawtypes" })
private List getPointsEarnedCourseGradeRecords(final CourseGrade courseGrade, final Collection studentUids) {
public List getPointsEarnedCourseGradeRecords(final CourseGrade courseGrade, final Collection studentUids) {
HibernateCallback hc = new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException {
if(studentUids == null || studentUids.size() == 0) {
Expand Down
Loading

0 comments on commit de4b850

Please sign in to comment.