mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-11-24 19:04:38 -06:00
[API/Librus] Add Librus descriptive grades ("Bieżące oceny opisowe") support.
This commit is contained in:
parent
1a2b51f3f9
commit
df52029a29
@ -288,6 +288,7 @@ public class Librus implements EdziennikInterface {
|
|||||||
targetEndpoints.add("Grades");
|
targetEndpoints.add("Grades");
|
||||||
targetEndpoints.add("PointGrades");
|
targetEndpoints.add("PointGrades");
|
||||||
targetEndpoints.add("DescriptiveGrades");
|
targetEndpoints.add("DescriptiveGrades");
|
||||||
|
targetEndpoints.add("TextGrades");
|
||||||
targetEndpoints.add("BehaviourGrades");
|
targetEndpoints.add("BehaviourGrades");
|
||||||
|
|
||||||
targetEndpoints.add("Events");
|
targetEndpoints.add("Events");
|
||||||
@ -359,6 +360,7 @@ public class Librus implements EdziennikInterface {
|
|||||||
targetEndpoints.add("Grades");
|
targetEndpoints.add("Grades");
|
||||||
targetEndpoints.add("PointGrades");
|
targetEndpoints.add("PointGrades");
|
||||||
targetEndpoints.add("DescriptiveGrades");
|
targetEndpoints.add("DescriptiveGrades");
|
||||||
|
targetEndpoints.add("TextGrades");
|
||||||
targetEndpoints.add("BehaviourGrades");
|
targetEndpoints.add("BehaviourGrades");
|
||||||
break;
|
break;
|
||||||
case FEATURE_HOMEWORKS:
|
case FEATURE_HOMEWORKS:
|
||||||
@ -498,6 +500,9 @@ public class Librus implements EdziennikInterface {
|
|||||||
case "DescriptiveGrades":
|
case "DescriptiveGrades":
|
||||||
getDescriptiveGrades();
|
getDescriptiveGrades();
|
||||||
break;
|
break;
|
||||||
|
case "TextGrades":
|
||||||
|
getTextGrades();
|
||||||
|
break;
|
||||||
case "BehaviourGrades":
|
case "BehaviourGrades":
|
||||||
getBehaviourGrades();
|
getBehaviourGrades();
|
||||||
break;
|
break;
|
||||||
@ -644,7 +649,7 @@ public class Librus implements EdziennikInterface {
|
|||||||
};
|
};
|
||||||
|
|
||||||
librusLoginCallback = redirectUrl -> {
|
librusLoginCallback = redirectUrl -> {
|
||||||
fakeAuthorize = "authorize2";
|
fakeAuthorize = "authorize";
|
||||||
authorize(AUTHORIZE_URL, authorizeCallback);
|
authorize(AUTHORIZE_URL, authorizeCallback);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2389,6 +2394,62 @@ public class Librus implements EdziennikInterface {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getTextGrades() {
|
||||||
|
callback.onActionStarted(R.string.sync_action_syncing_descriptive_grades);
|
||||||
|
apiRequest("DescriptiveGrades", data -> {
|
||||||
|
if (data == null) {
|
||||||
|
r("finish", "TextGrades");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JsonArray grades = data.get("Grades").getAsJsonArray();
|
||||||
|
//d("Got Grades: "+grades.toString());
|
||||||
|
for (JsonElement gradeEl : grades) {
|
||||||
|
JsonObject grade = gradeEl.getAsJsonObject();
|
||||||
|
long id = grade.get("Id").getAsLong();
|
||||||
|
long teacherId = grade.get("AddedBy").getAsJsonObject().get("Id").getAsLong();
|
||||||
|
int semester = grade.get("Semester").getAsInt();
|
||||||
|
long subjectId = grade.get("Subject").getAsJsonObject().get("Id").getAsLong();
|
||||||
|
String description = grade.get("Map").getAsString();
|
||||||
|
|
||||||
|
long categoryId = -1;
|
||||||
|
JsonElement skillEl = grade.get("Skill");
|
||||||
|
if (skillEl != null) {
|
||||||
|
categoryId = skillEl.getAsJsonObject().get("Id").getAsLong();
|
||||||
|
}
|
||||||
|
|
||||||
|
String str_date = grade.get("AddDate").getAsString();
|
||||||
|
long addedDate = Date.fromIso(str_date);
|
||||||
|
|
||||||
|
String category = "";
|
||||||
|
int color = -1;
|
||||||
|
GradeCategory gradeCategory = GradeCategory.search(gradeCategoryList, categoryId);
|
||||||
|
if (gradeCategory != null) {
|
||||||
|
category = gradeCategory.text;
|
||||||
|
color = gradeCategory.color;
|
||||||
|
}
|
||||||
|
|
||||||
|
Grade gradeObject = new Grade(
|
||||||
|
profileId,
|
||||||
|
id,
|
||||||
|
category,
|
||||||
|
color,
|
||||||
|
"",
|
||||||
|
description,
|
||||||
|
0.0f,
|
||||||
|
0,
|
||||||
|
semester,
|
||||||
|
teacherId,
|
||||||
|
subjectId
|
||||||
|
);
|
||||||
|
gradeObject.type = Grade.TYPE_DESCRIPTIVE;
|
||||||
|
|
||||||
|
gradeList.add(gradeObject);
|
||||||
|
metadataList.add(new Metadata(profileId, Metadata.TYPE_GRADE, gradeObject.id, profile.getEmpty(), profile.getEmpty(), addedDate));
|
||||||
|
}
|
||||||
|
r("finish", "TextGrades");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void getBehaviourGrades() {
|
private void getBehaviourGrades() {
|
||||||
d(TAG, "Grades settings: "+enableStandardGrades+", "+enablePointGrades+", "+enableDescriptiveGrades);
|
d(TAG, "Grades settings: "+enableStandardGrades+", "+enablePointGrades+", "+enableDescriptiveGrades);
|
||||||
if (!enableBehaviourGrades) {
|
if (!enableBehaviourGrades) {
|
||||||
|
Loading…
Reference in New Issue
Block a user