Skip to content

Commit

Permalink
Small interview QoL improvements (#2743)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request
Ports tgstation/tgstation#59621 which allows us to embed links in
interview questions. Also fixes an annoying config verification error
that didn't mean anything.

## Why It's Good For The Game
Allows us to link rules and lore in interviews, so people are asked to
read them.

## Changelog

:cl: bobbahbrown, Mark Suckerberg
admin: Links can now be embedded in interview questions to get players
to read them.
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->

---------

Co-authored-by: Bobbahbrown <[email protected]>
  • Loading branch information
MarkSuckerberg and bobbah authored Feb 22, 2024
1 parent df41851 commit c942de8
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
1 change: 1 addition & 0 deletions code/controllers/configuration/config_entry.dm
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
str_val = trim(str_val)
if (str_val != "")
config_entry_value += str_val
return TRUE

/datum/config_entry/number_list
abstract_type = /datum/config_entry/number_list
Expand Down
10 changes: 8 additions & 2 deletions code/modules/interview/interview.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
GLOB.interviews.approved_ckeys |= owner_ckey
GLOB.interviews.close_interview(src)
log_admin_private("[key_name(approved_by)] has approved interview #[id] for [owner_ckey][!owner ? "(DC)": ""].")
message_admins("<span class='adminnotice'>[key_name(approved_by)] has approved interview #[id] for [owner_ckey][!owner ? "(DC)": ""].</span>")
message_admins("<span class='adminnotice'>[key_name(approved_by)] has approved [link_self()] for [owner_ckey][!owner ? "(DC)": ""].</span>")
if (owner)
SEND_SOUND(owner, sound('sound/effects/adminhelp.ogg'))
to_chat(owner, "<font color='red' size='4'><b>-- Interview Update --</b></font>" \
Expand All @@ -79,7 +79,7 @@
GLOB.interviews.close_interview(src)
GLOB.interviews.cooldown_ckeys |= owner_ckey
log_admin_private("[key_name(denied_by)] has denied interview #[id] for [owner_ckey][!owner ? "(DC)": ""].")
message_admins("<span class='adminnotice'>[key_name(denied_by)] has denied interview #[id] for [owner_ckey][!owner ? "(DC)": ""].</span>")
message_admins("<span class='adminnotice'>[key_name(denied_by)] has denied [link_self()] for [owner_ckey][!owner ? "(DC)": ""].</span>")
addtimer(CALLBACK(GLOB.interviews, TYPE_PROC_REF(/datum/interview_manager, release_from_cooldown), owner_ckey), 180)
if (owner)
SEND_SOUND(owner, sound('sound/effects/adminhelp.ogg'))
Expand Down Expand Up @@ -160,3 +160,9 @@
"response" = responses.len < i ? null : responses[i]
)
.["questions"] += list(data)

/**
* Generates a clickable link to open this interview
*/
/datum/interview/proc/link_self()
return "<a href='?_src_=holder;[HrefToken(TRUE)];interview=[REF(src)]'>Interview #[id]</a>"
2 changes: 1 addition & 1 deletion code/modules/interview/interview_manager.dm
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ GLOBAL_DATUM_INIT(interviews, /datum/interview_manager, new)
if(X.prefs.toggles & SOUND_ADMINHELP)
SEND_SOUND(X, sound('sound/effects/adminhelp.ogg'))
window_flash(X, ignorepref = TRUE)
to_chat(X, "<span class='adminhelp'>Interview for [ckey] enqueued for review. Current position in queue: [to_queue.pos_in_queue]</span>", confidential = TRUE)
to_chat(X, "<span class='adminhelp'>[to_queue.link_self()] for [ckey] enqueued for review. Current position in queue: [to_queue.pos_in_queue]</span>", confidential = TRUE)

/**
* Removes a ckey from the cooldown list, used for enforcing cooldown after an interview is denied.
Expand Down
5 changes: 4 additions & 1 deletion config/interviews.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Interview welcome message displayed at the top of all interview questionnaires
# Should help to describe why the questionnaire is being given to the interviewee
# You can include links using markdown-style link notation, like [our rules](https://shiptest.net/wiki/Rules)
INTERVIEW_WELCOME_MSG Welcome to our server. As you have not played here before, or played very little, we'll need you to answer a few questions below. After you submit your answers they will be reviewed and you may be asked further questions before being allowed to play. Please be patient as there may be others ahead of you.

# Interview questions are listed here, in the order that they will be displayed in-game.
# You can include links using markdown-style link notation, like [our rules](https://shiptest.net/wiki/Rules)
INTERVIEW_QUESTIONS Why have you joined the server today?
INTERVIEW_QUESTIONS Have you played space-station 13 before? If so, on what servers?
INTERVIEW_QUESTIONS Do you know anybody on the server today? If so, who?
INTERVIEW_QUESTIONS Do you have any additional comments?
INTERVIEW_QUESTIONS Have you read and understood our [rules](https://shiptest.net/wiki/Rules)?
INTERVIEW_QUESTIONS Do you have any additional comments or questions?
25 changes: 22 additions & 3 deletions tgui/packages/tgui/interfaces/Interview.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,31 @@ export const Interview = (props, context) => {
}
};

// Matches a complete markdown-style link, capturing the whole [...](...)
const link_regex = /(\[[^[]+\]\([^)]+\))/;
// Decomposes a markdown-style link into the link and display text
const link_decompose_regex = /\[([^[]+)\]\(([^)]+)\)/;

// Renders any markdown-style links within a provided body of text
const linkify_text = (text) => {
let parts = text.split(link_regex);
for (let i = 1; i < parts.length; i += 2) {
const match = link_decompose_regex.exec(parts[i]);
parts[i] = (
<a key={'link' + i} href={match[2]}>
{match[1]}
</a>
);
}
return parts;
};

return (
<Window width={500} height={600} noClose={!is_admin}>
<Window.Content scrollable>
{(!read_only && (
<Section title="Welcome!">
<p>{welcome_message}</p>
<p>{linkify_text(welcome_message)}</p>
</Section>
)) ||
rendered_status(status)}
Expand Down Expand Up @@ -87,8 +106,8 @@ export const Interview = (props, context) => {
)}
{questions.map(({ qidx, question, response }) => (
<Section key={qidx} title={`Question ${qidx}`}>
<p>{question}</p>
{(read_only && (
<p>{linkify_text(question)}</p>
{((read_only || is_admin) && (
<BlockQuote>{response || 'No response.'}</BlockQuote>
)) || (
<TextArea
Expand Down

0 comments on commit c942de8

Please sign in to comment.