Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CP3108 Staff Dashboard - Assessment Uploader #1080

Closed
wants to merge 18 commits into from

Conversation

Wong-ZZ
Copy link
Contributor

@Wong-ZZ Wong-ZZ commented Apr 20, 2020

Context

This PR adds the Assessment Uploader component for the CP3108 Staff Dashboard project. The Assessment Uploader, also called the GroundControl, provides an interface for staff to manage assessments for the course. Staff can upload, delete, publish or update assessments through this interface.

Implementation

  • The GroundControl is accessible through the GroundControl tab in the navigation bar and can only be accessed by staffs/admin.
  • Added various request methods to aid with the uploading, deleting, publishing and updating of assessments.
  • Added an optional field, isPublished to IAssessmentOverview.
  • Added @blueprintjs/datetime for the date input for changing an assessment's open/close dates.

The UI for GroundControl can be seen here:
aaaa

Other Information

Corresponding PR to cadet: PR 586
More info in the wiki: Assessment Uploader

@coveralls
Copy link

coveralls commented Apr 20, 2020

Pull Request Test Coverage Report for Build 4909

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 37.4%

Totals Coverage Status
Change from base Build 4908: 0.0%
Covered Lines: 3205
Relevant Lines: 7581

💛 - Coveralls

Copy link

@sun-yitao sun-yitao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I attempt to delete an assignment, I immediately get logged out with the following message:
Screenshot 2020-04-23 at 1 11 44 AM

The log from the backend seems to be fine:

[info] Sent 200 in 1ms
[info] GET /v1/notification
[debug] Processing with CadetWeb.NotificationController.index/2
  Parameters: %{}
  Pipelines: [:api, :auth, :ensure_auth]
[debug] QUERY OK source="users" db=0.2ms
SELECT u0."id", u0."name", u0."role", u0."nusnet_id", u0."group_id", u0."inserted_at", u0."updated_at" FROM "users" AS u0 WHERE (u0."id" = $1) [10]
[debug] QUERY OK source="notifications" db=0.2ms
SELECT n0."id", n0."type", n0."read", n0."user_id", n0."assessment_id", n0."submission_id", n0."inserted_at", n0."updated_at" FROM "notifications" AS n0 WHERE (n0."user_id" = $1) AND (n0."read" = FALSE) [10]
[info] Sent 200 in 1ms
[info] GET /v1/assessments
[debug] Processing with CadetWeb.AssessmentsController.index/2
  Parameters: %{}
  Pipelines: [:api, :auth, :ensure_auth]
[debug] QUERY OK source="users" db=0.3ms
SELECT u0."id", u0."name", u0."role", u0."nusnet_id", u0."group_id", u0."inserted_at", u0."updated_at" FROM "users" AS u0 WHERE (u0."id" = $1) [10]
[debug] QUERY OK db=1.4ms
SELECT s0."id", s0."title", s0."is_published", s0."type", s0."summary_short", s0."summary_long", s0."open_at", s0."close_at", s0."cover_picture", s0."mission_pdf", s0."number", s0."story", s0."reading", s0."password", s0."inserted_at", s0."updated_at", s0."max_grade", s0."max_xp", s1."xp" + s1."xp_adjustment" + s1."xp_bonus", s1."grade" + s1."adjustment", s1."status", s2."count", s3."count" FROM (SELECT a0."id" AS "id", a0."title" AS "title", a0."is_published" AS "is_published", a0."type" AS "type", a0."summary_short" AS "summary_short", a0."summary_long" AS "summary_long", a0."open_at" AS "open_at", a0."close_at" AS "close_at", a0."cover_picture" AS "cover_picture", a0."mission_pdf" AS "mission_pdf", a0."number" AS "number", a0."story" AS "story", a0."reading" AS "reading", a0."password" AS "password", a0."inserted_at" AS "inserted_at", a0."updated_at" AS "updated_at", s1."max_grade" AS "max_grade", s1."max_xp" AS "max_xp" FROM "assessments" AS a0 INNER JOIN (SELECT q0."assessment_id" AS "assessment_id", sum(q0."max_grade") AS "max_grade", sum(q0."max_xp") AS "max_xp" FROM "questions" AS q0 GROUP BY q0."assessment_id") AS s1 ON a0."id" = s1."assessment_id") AS s0 LEFT OUTER JOIN (SELECT s0."id" AS "id", s0."xp_bonus" AS "xp_bonus", s0."status" AS "status", s0."unsubmitted_at" AS "unsubmitted_at", s0."assessment_id" AS "assessment_id", s0."student_id" AS "student_id", s0."unsubmitted_by_id" AS "unsubmitted_by_id", s0."inserted_at" AS "inserted_at", s0."updated_at" AS "updated_at", s1."xp" AS "xp", s1."xp_adjustment" AS "xp_adjustment", s1."grade" AS "grade", s1."adjustment" AS "adjustment" FROM "submissions" AS s0 INNER JOIN (SELECT a0."submission_id" AS "submission_id", sum(a0."grade") AS "grade", sum(a0."adjustment") AS "adjustment", sum(a0."xp") AS "xp", sum(a0."xp_adjustment") AS "xp_adjustment" FROM "answers" AS a0 GROUP BY a0."submission_id") AS s1 ON s0."id" = s1."submission_id") AS s1 ON (s0."id" = s1."assessment_id") AND (s1."student_id" = $1) LEFT OUTER JOIN (SELECT q0."assessment_id" AS "assessment_id", count(q0."id") AS "count" FROM "questions" AS q0 GROUP BY q0."assessment_id") AS s2 ON s0."id" = s2."assessment_id" LEFT OUTER JOIN (SELECT a0."submission_id" AS "submission_id", count(a0."id") AS "count" FROM "answers" AS a0 WHERE (NOT (a0."grader_id" IS NULL)) GROUP BY a0."submission_id") AS s3 ON s1."id" = s3."submission_id" ORDER BY s0."open_at" [10]

@Wong-ZZ
Copy link
Contributor Author

Wong-ZZ commented Apr 23, 2020

I couldn't recreate the error which you encountered but I did find a bug that occurs when deleting an assessment and I'm not sure if it is related to the error you are facing.

Can you try pulling from my latest commit from the backend PR and see if you still face the same error. Also can you display the browser console when deleting the assessment so that I can see the response from the backend? Thanks a lot.

@Wong-ZZ
Copy link
Contributor Author

Wong-ZZ commented Apr 25, 2020

I just remembered that the nginx config file from the cadet repo does not allow for DELETE requests which causes you to get logged out when deleting an assessment.

nginx.conf.txt
Try using this config for nginx instead

@sun-yitao
Copy link

I just remembered that the nginx config file from the cadet repo does not allow for DELETE requests which causes you to get logged out when deleting an assessment.

nginx.conf.txt
Try using this config for nginx instead

Thanks for pointing that out. I used the nginx config provided and now it no longer logs me out but it seems to be something to do with the backend instead:
Screenshot 2020-04-26 at 3 27 10 PM

[info] DELETE /v1/assessments/3
[debug] Processing with CadetWeb.AssessmentsController.delete/2
  Parameters: %{"id" => "3"}
  Pipelines: [:api, :auth, :ensure_auth]
[debug] QUERY OK source="users" db=0.3ms
SELECT u0."id", u0."name", u0."role", u0."nusnet_id", u0."group_id", u0."inserted_at", u0."updated_at" FROM "users" AS u0 WHERE (u0."id" = $1) [10]
[debug] QUERY OK source="assessments" db=0.3ms
SELECT a0."id", a0."title", a0."is_published", a0."type", a0."summary_short", a0."summary_long", a0."open_at", a0."close_at", a0."cover_picture", a0."mission_pdf", a0."number", a0."story", a0."reading", a0."password", a0."inserted_at", a0."updated_at" FROM "assessments" AS a0 WHERE (a0."id" = $1) [3]
[debug] QUERY ERROR source="submissions" db=0.6ms queue=0.2ms
DELETE FROM "submissions" AS s0 WHERE (s0."assessment_id" = $1) [3]
[info] Sent 500 in 14ms
[error] #PID<0.675.0> running CadetWeb.Endpoint (connection #PID<0.674.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: DELETE /v1/assessments/3
** (exit) an exception was raised:
    ** (Postgrex.Error) ERROR 23503 (foreign_key_violation) update or delete on table "submissions" violates foreign key constraint "answers_submission_id_fkey" on table "answers"

    table: answers
    constraint: answers_submission_id_fkey

Key (id)=(5) is still referenced from table "answers".
        (ecto_sql) lib/ecto/adapters/sql.ex:621: Ecto.Adapters.SQL.raise_sql_call_error/1
        (ecto_sql) lib/ecto/adapters/sql.ex:554: Ecto.Adapters.SQL.execute/5
        (cadet) lib/cadet/assessments/assessments.ex:67: Cadet.Assessments.delete_assessment/2
        (cadet) lib/cadet_web/controllers/assessments_controller.ex:77: CadetWeb.AssessmentsController.delete/2
        (cadet) lib/cadet_web/controllers/assessments_controller.ex:1: CadetWeb.AssessmentsController.action/2
        (cadet) lib/cadet_web/controllers/assessments_controller.ex:1: CadetWeb.AssessmentsController.phoenix_controller_pipeline/2
        (phoenix) lib/phoenix/router.ex:288: Phoenix.Router.__call__/2
        (cadet) lib/plug/error_handler.ex:64: CadetWeb.Router.call/2
        (cadet) lib/cadet_web/endpoint.ex:1: CadetWeb.Endpoint.plug_builder_call/2
        (cadet) lib/plug/debugger.ex:122: CadetWeb.Endpoint."call (overridable 3)"/2
        (cadet) lib/cadet_web/endpoint.ex:1: CadetWeb.Endpoint.call/2
        (phoenix) lib/phoenix/endpoint/cowboy2_handler.ex:42: 

@Wong-ZZ
Copy link
Contributor Author

Wong-ZZ commented Apr 26, 2020

You have to pull from the latest commit I made to the backend PR a few days ago that fixed this specific bug

@sun-yitao
Copy link

You have to pull from the latest commit I made to the backend PR a few days ago that fixed this specific bug

Oh yes the latest commit works now, thanks!

@seanlowjk
Copy link
Contributor

Do let me know if you would want to fix the merge conflicts yourself thanks =)

@angelsl
Copy link
Contributor

angelsl commented May 20, 2020

#1058, which contained some or all of the commits from this PR, was merged.

So.. I'm not sure if this needs to be merged anymore.

@seanlowjk seanlowjk closed this May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants