Skip to content

Commit

Permalink
Fixed submissions loading for data wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
allomanta committed Sep 19, 2024
1 parent a9fd8f1 commit 93005be
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 51 deletions.
56 changes: 18 additions & 38 deletions IguideME.Web/Controllers/Apps/TileController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -534,26 +534,26 @@ public ActionResult GetUserDiscussionEntries(string userID)
}


// [Authorize]
// [HttpGet]
// [Route("/tiles/{tileID}/submissions")]
// [ProducesResponseType(StatusCodes.Status204NoContent)]
// [ProducesResponseType(StatusCodes.Status400BadRequest)]
// [ProducesResponseType(StatusCodes.Status401Unauthorized)]
// public ActionResult GetTileSubmissions(string tileID)
// {
// // Only instructors may view submissions of other students
// if (!this.IsAdministrator())
// return Unauthorized();
[Authorize]
[HttpGet]
[Route("/tiles/{tileID}/submissions")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
public ActionResult GetTileSubmissions(string tileID)
{
// Only instructors may view submissions of other students
if (!this.IsAdministrator())
return Unauthorized();

// bool success = int.TryParse(tileID, out int id);
if (int.TryParse(tileID, out int id))
{
return Ok(_databaseManager.GetTileSubmissions(this.GetCourseID(), id));
}

return BadRequest();

// return success
// ? Json(
// _databaseManager.GetTileSubmissions(
// this.GetCourseID(), id))
// : BadRequest();
// }
}

// [Authorize]
// [HttpGet]
Expand Down Expand Up @@ -759,26 +759,6 @@ public ActionResult UploadTileData(int tileID, JObject data)
return NoContent();
}

// [Authorize(Policy = "IsInstructor")]
// [HttpGet]
// // DBrefTODO: The entry Id should be changed into assignmentID
// // [Route("/entries/{entryID}/submissions")]
// [Route("/entries/{assignmentID}/submissions")]
// [ProducesResponseType(StatusCodes.Status204NoContent)]
// [ProducesResponseType(StatusCodes.Status400BadRequest)]
// [ProducesResponseType(StatusCodes.Status401Unauthorized)]
// public ActionResult GetEntrySubmissions(string assignmentID)
// {
// // TODO: check userID?
// bool success = int.TryParse(assignmentID, out int entry_id);

// return success
// ? Json(
// _databaseManager.GetAssignmentSubmissions(
// this.GetCourseID(), entry_id))
// : BadRequest();
// }

// [Authorize]
// [HttpGet]
// [Route("/tiles/Grade-summary/{userID}")]
Expand Down
12 changes: 2 additions & 10 deletions IguideME.Web/Frontend/src/api/tiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,8 @@ export async function uploadData({
.then((response) => response.data);
}

export async function getTileSubmissions({
tileId,
userID,
}: {
tileId: number;
userID?: string;
}): Promise<Submission[]> {
return await apiClient
.get(userID ? `tiles/${tileId}/submissions/${userID}` : `tiles/${tileId}/submissions`)
.then((response) => response.data);
export async function getTileSubmissions({ tileId }: { tileId: number }): Promise<Submission[]> {
return await apiClient.get(`tiles/${tileId}/submissions`).then((response) => response.data);
}

export async function AddDataWizardTile({ tileId, groupId }: { tileId: number; groupId: number }): Promise<void> {
Expand Down
1 change: 0 additions & 1 deletion IguideME.Web/Services/Constants/DatabaseQueries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,6 @@ INNER JOIN `assignments`
INNER JOIN `tile_entries`
ON `submissions`.`assignment_id` = `tile_entries`.`content_id`
WHERE `tile_entries`.`tile_id`=@tileID
AND `submissions`.`user_id`=@userID
;";

public const string QUERY_ALL_USER_SUBMISSIONS_FOR_TILE =
Expand Down
31 changes: 31 additions & 0 deletions IguideME.Web/Services/DatabaseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1906,6 +1906,37 @@ public List<AssignmentSubmission> GetTileSubmissionsForUser(
}
}

return submissions;
}

public List<AssignmentSubmission> GetTileSubmissions(
int tileID,
long syncID = 0
)
{
List<AssignmentSubmission> submissions = new();

using (
SQLiteDataReader r1 = Query(
DatabaseQueries.QUERY_TILE_SUBMISSIONS_FOR_STUDENT,
new SQLiteParameter("tileID", tileID)
)
)
{
while (r1.Read())
{
AssignmentSubmission submission =
new(
r1.GetInt32(0),
r1.GetInt32(1),
r1.GetValue(2).ToString(),
r1.GetDouble(3),
r1.GetInt32(4)
);
submissions.Add(submission);
}
}

return submissions;
}

Expand Down
4 changes: 2 additions & 2 deletions charts/iguideme/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: iguideme
description: IguideME
type: application
version: 0.3.217
appVersion: "0.3.217"
version: 0.3.218
appVersion: "0.3.218"

0 comments on commit 93005be

Please sign in to comment.