diff --git a/app/graphql/mutations/ask_question.rb b/app/graphql/mutations/ask_question.rb index 2c0297a5b..6609f4180 100644 --- a/app/graphql/mutations/ask_question.rb +++ b/app/graphql/mutations/ask_question.rb @@ -3,6 +3,7 @@ module Mutations class AskQuestion < BaseMutation argument :registration_id, ID, required: true, loads: Types::RegistrationType + argument :urgent, Boolean, required: false argument :body, String, required: true field :question, Types::QuestionType, null: false @@ -15,8 +16,8 @@ def authorized?(registration:, **_args) raise GraphQL::ExecutionError, 'You do not have permission.' end - def resolve(registration:, body:) - q = Question.new(registration: registration, body: body) + def resolve(registration:, urgent:, body:) + q = Question.new(registration: registration, urgent: urgent, body: body) saved = q.save raise GraphQL::ExecutionError, q.errors.full_messages.to_sentence unless saved diff --git a/app/graphql/types/question_type.rb b/app/graphql/types/question_type.rb index a2f18a614..c9916e660 100644 --- a/app/graphql/types/question_type.rb +++ b/app/graphql/types/question_type.rb @@ -11,6 +11,7 @@ class QuestionType < Types::BaseObject def registration RecordLoader.for(Registration).load(object.registration_id) end + field :urgent, Boolean, null: false field :body, String, null: false field :created_at, GraphQL::Types::ISO8601DateTime, null: false end diff --git a/app/javascript/components/workflows/proctor/exams/index.tsx b/app/javascript/components/workflows/proctor/exams/index.tsx index 8f9482d67..557557863 100644 --- a/app/javascript/components/workflows/proctor/exams/index.tsx +++ b/app/javascript/components/workflows/proctor/exams/index.tsx @@ -101,6 +101,7 @@ interface Question { type: MessageType.Question; time: DateTime; id: string; + urgent: boolean; body: string; registration: { id: string; @@ -152,6 +153,7 @@ export interface MessageProps { iconClass?: string; tooltip: string; time: DateTime; + urgent: boolean; body: React.ReactElement | string; } @@ -161,6 +163,7 @@ const ShowMessage: React.FC = (props) => { iconClass, tooltip, time, + urgent, body, children, } = props; @@ -174,6 +177,7 @@ const ShowMessage: React.FC = (props) => { {`${tooltip} (${time.toLocaleString(DateTime.TIME_SIMPLE)})`} + {urgent && LOCKED OUT} {children}

{body}

@@ -784,6 +788,7 @@ const ShowQuestion: React.FC<{ const { registration, body, + urgent, time, } = question; const reply = useCallback(() => replyTo(registration.id), [registration.id]); @@ -791,6 +796,7 @@ const ShowQuestion: React.FC<{ @@ -1084,6 +1090,7 @@ const newQuestionSubscriptionSpec = graphql` displayName } } + urgent body } questionsEdge { @@ -1371,6 +1378,7 @@ const ExamMessages: React.FC<{ displayName } } + urgent body } } @@ -1410,6 +1418,7 @@ const ExamMessages: React.FC<{ questions: res.questions.edges.map(({ node: question }) => ({ type: MessageType.Question, id: question.id, + urgent: question.urgent, body: question.body, registration: question.registration, time: DateTime.fromISO(question.createdAt), diff --git a/app/javascript/components/workflows/student/exams/show/components/AnomalousMessaging.tsx b/app/javascript/components/workflows/student/exams/show/components/AnomalousMessaging.tsx index beec8cebe..ca6914482 100644 --- a/app/javascript/components/workflows/student/exams/show/components/AnomalousMessaging.tsx +++ b/app/javascript/components/workflows/student/exams/show/components/AnomalousMessaging.tsx @@ -31,7 +31,7 @@ const AnomalousMessaging: React.FC<{

Ask a question

- + diff --git a/app/javascript/components/workflows/student/exams/show/components/navbar/AskQuestion.tsx b/app/javascript/components/workflows/student/exams/show/components/navbar/AskQuestion.tsx index 37279ccb8..20eba5e44 100644 --- a/app/javascript/components/workflows/student/exams/show/components/navbar/AskQuestion.tsx +++ b/app/javascript/components/workflows/student/exams/show/components/navbar/AskQuestion.tsx @@ -36,6 +36,7 @@ const ShowQuestion: React.FC<{ graphql` fragment AskQuestion_single on Question { createdAt + urgent body } `, @@ -54,9 +55,11 @@ const ShowQuestion: React.FC<{ const SendQuestion: React.FC<{ registrationId: string; + urgent: boolean; }> = (props) => { const { registrationId, + urgent, } = props; const [val, setVal] = useState(''); const [inTimeout, setInTimeout] = useState(false); @@ -151,6 +154,7 @@ const SendQuestion: React.FC<{ variables: { input: { registrationId, + urgent, body: val, }, }, @@ -186,11 +190,13 @@ const questionPaginationConfig = { interface AskQuestionProps { examKey: AskQuestion$key; + urgent: boolean; } const AskQuestion: React.FC = (props) => { const { examKey, + urgent, } = props; const { alert } = useContext(AlertContext); const [res, { isLoading, hasMore, loadMore }] = usePagination( @@ -222,7 +228,7 @@ const AskQuestion: React.FC = (props) => { const { edges } = res.myRegistration.questions; return (
- +
{edges.length === 0 && ( diff --git a/db/migrate/20200522182009_create_schema.rb b/db/migrate/20200522182009_create_schema.rb index fd02ce871..f0f4de401 100644 --- a/db/migrate/20200522182009_create_schema.rb +++ b/db/migrate/20200522182009_create_schema.rb @@ -104,7 +104,7 @@ def change t.index [:user_id, :exam_version_id], unique: true t.index [:room_id, :user_id], unique: true t.index [:user_id, :room_id], unique: true - + t.boolean :published, null: false, default: false t.datetime :start_time @@ -175,6 +175,7 @@ def change create_table :questions do |t| t.references :registration, null: false, foreign_key: true + t.boolean :urgent, null: false, default: false t.text :body, null: false t.timestamps end @@ -220,7 +221,7 @@ def change t.string :student_feedback, null: true t.float :points, null: false t.integer :order, null: true - + t.timestamps end diff --git a/db/schema.rb b/db/schema.rb index 948b8cb7a..f531624a7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -164,6 +164,7 @@ create_table "questions", force: :cascade do |t| t.bigint "registration_id", null: false + t.boolean "urgent", default: false, null: false t.text "body", null: false t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false