Skip to content

Commit

Permalink
Merge pull request #59 from justin-time/AssignmentSolutions
Browse files Browse the repository at this point in the history
Add support to download assignment solutions
  • Loading branch information
Sync-my-L2P authored and Sync-my-L2P committed Apr 10, 2015
2 parents bca93fb + c066466 commit 3d27f8b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
30 changes: 30 additions & 0 deletions parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,36 @@ void Parser::parseFiles(QNetworkReply *reply, QMap<QNetworkReply*, Structureelem
// Element hinzufügen
dir->appendRow(newFile);
}

QJsonObject solutions = file["solution"].toObject();
QJsonArray solutionFiles= solutions["solutionDocuments"].toArray();
foreach(QJsonValue solutionElement, solutionFiles)
{
QJsonObject solutionDoc = solutionElement.toObject();

filename = solutionDoc["fileName"].toString();
filesize = solutionDoc["fileSize"].toString().toInt();
timestamp = solutionDoc["modifiedTimestamp"].toInt();
url = solutionDoc["downloadUrl"].toString();
url = QByteArray::fromPercentEncoding(url.toLocal8Bit());
urlParts = url.split('/');

urlParts.removeFirst();
urlParts.removeFirst();
urlParts.removeFirst();
urlParts.removeFirst();
urlParts.removeFirst();
urlParts.removeLast();
urlParts.removeLast();

Structureelement *dir = Utils::getDirectoryItem(currentCourse, urlParts);

Structureelement* newFile = new Structureelement(filename, QUrl(url), timestamp, filesize,
currentCourse->data(cidRole).toString(),
fileItem);
// Element hinzufügen
dir->appendRow(newFile);
}
}
else if(responseCategory == 3)
{
Expand Down
3 changes: 3 additions & 0 deletions utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ Structureelement *Utils::getDirectoryItem(Structureelement *courseItem, QStringL
else if (item.contains("LA_AssignmentDocuments")) {
item = "Übungsdokumente";
}
else if (item.contains("LA_SolutionDocuments")) {
item = "Übungslösungen";
}
else if (item.contains("EmailAttachments")) {
item = "E-Mail-Anhänge";
}
Expand Down

0 comments on commit 3d27f8b

Please sign in to comment.