Skip to content

fb_name()

mkraska edited this page Oct 5, 2026 · 1 revision

[txt, isOK]: fb_name(n, i, lon)

  • txt feedback text
  • isOK flag for test result
  • n the names array (content of the names input field)
  • i index of the contact/support object whose resolved reaction's name is to be checked
  • lon list of allowed name strings, e.g. ["N_A","A","F_A"]

Source

This function checks only whether the name the student assigned to the reaction resolved at index i is one of the allowed names in lon - nothing else. It is deliberately kept separate from Feedback for "contact" (fb_contact()) / fb_bar_name() rather than built into them, so that a question can score and weight the naming convention independently from the geometric/physical correctness of the reaction.

fb_name() does not itself report "no reaction found" or "more than one reaction found": if n[i] is not a list resolving to exactly one load, it silently returns ["", false] with no feedback text. It is meant to be used alongside fb_contact() (or fb_bar()/fb_unidir()) on the same index, which already produces that feedback - fb_name() only adds the naming check on top, once a single reaction is actually resolved there. If there are multiple reactions at object i, the first one is checked.

Checks done by fb_name():

  • Does n[i] resolve to exactly one load? (If not: ["", false], no feedback text - see above.)
  • Is that load's name a member of lon? If not, the feedback names the offending symbol, e.g. "(A) ist kein passender Name".
fb_name(n,i,lon):=block([name,txt],
  name: none,
  if listp(n[i]) and  not emptyp(n[i]) then name: n[n[i][1]] else return(["", false]),
  if member(name,lon) then return( ["",true]) else 
    return([castext("\\({@name@} \\) ist kein passender Name"), false]) 
);

Typical PRT

Feedback variables:

obj: stackjson_parse(objects);
[text, isOK]: fb_unidir(obj, names, i_SB, "Pendelstütze B: ");
[textn, isOKn]: fb_name(names, i_SB, ["B"]);

PRT node

A separate node testing isOKn = true, with {@textn@} as its feedback - so a wrong direction/position (via fb_contact()/fb_unidir()/fb_bar()) and an unsuitable name are reported, and scored, independently.

Tryout Space

In order to try code snippets in jsfiddle,

  1. copy the code from the wiki page to the clipboard
  2. follow the link for the JSXGraph version you want to try
  3. Replace the code in the HTML section (contents of <p id="init">) with the content of the clipboard

The remaining jsfiddle pages don't seem to work any more (as of 04/26)

Clone this wiki locally