Home /Modules/advantage/DiStudentInput.sleela

DiStudentInput.sleela

lib/advantage/learner-vs-professional/series/02-student-input-gate/DiStudentInput.sleela · 104 line(s) · sleela

<< lib/advantage/learner-vs-professional/series/02-student-input-gate/DiStudentInput.sleela
   SLeeLa courseware.
   Definition: Device Instructor gate that accepts only good student input: a claim, evidence registered in the shared registry, and the next step in sequitur order. >>
#sleela 3.0
material;
artifact;
pure;
gasoline;
< Lesson 2. A student submission is good when it has a claim, names evidence >
< that is in the registry, and is the very next step in order. The gate says >
< exactly why a submission is refused, so the student can fix it. >
class DiStudentInput {
  < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
  << Eleven catalogued attributes with getter/setter pairs. A worker-class
     lesson carries the baseline identity record. >>
  String metaVersion = "1.0.0";
  int metaId = 39102;
  String metaAuthor = "Kiro Agent";
  String metaDate = "2026-11-11";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "none";
  < metaOrigin: National | <nation> | International | Galactic >
  String metaOrigin = "International";
  String metaBirthDate = "2026-11-11";
  < metaScienceRating: maturity/robustness on a 1..10 scale >
  int metaScienceRating = 5;
  < metaNationalSchedule: a real, citable instrument or "none" >
  String metaNationalSchedule = "none";

  String getMetaVersion() { return metaVersion; }
  void setMetaVersion(String v) { metaVersion = v; }
  int getMetaId() { return metaId; }
  void setMetaId(int v) { metaId = v; }
  String getAuthor() { return metaAuthor; }
  void setAuthor(String v) { metaAuthor = v; }
  String getDate() { return metaDate; }
  void setDate(String v) { metaDate = v; }
  String getCopyright() { return metaCopyright; }
  void setCopyright(String v) { metaCopyright = v; }
  String getTrademark() { return metaTrademark; }
  void setTrademark(String v) { metaTrademark = v; }
  String getCorporation() { return metaCorporation; }
  void setCorporation(String v) { metaCorporation = v; }
  String getOrigin() { return metaOrigin; }
  void setOrigin(String v) { metaOrigin = v; }
  String getBirthDate() { return metaBirthDate; }
  void setBirthDate(String v) { metaBirthDate = v; }
  int getScienceRating() { return metaScienceRating; }
  void setScienceRating(int v) { metaScienceRating = v; }
  String getNationalSchedule() { return metaNationalSchedule; }
  void setNationalSchedule(String v) { metaNationalSchedule = v; }

  SLNounRegistry reg = new SLNounRegistry();
  int lastStep = 0;
  int good = 0;
  int refused = 0;

  < Result codes: 0 good, 1 empty claim, 2 evidence not registered, 3 step out of order. >
  int submit(int step, String claim, String evidence) {
    int code = 0;
    if (claim == "") { code = 1; }
    else if (!reg.has(evidence)) { code = 2; }
    else if (step != lastStep + 1) { code = 3; }
    if (code == 0) {
      lastStep = step;
      good = good + 1;
    } else {
      refused = refused + 1;
    }
    return code;
  }

  String reason(int code) {
    if (code == 0) { return "good input"; }
    if (code == 1) { return "refused: say what you claim"; }
    if (code == 2) { return "refused: evidence is not an entry in the registry"; }
    return "refused: this step does not follow the last accepted step";
  }

  void show(int step, String claim, String evidence) {
    int code = submit(step, claim, evidence);
    print("  step " + step + " [" + claim + "] evidence=" + evidence + " : " + reason(code));
  }

  void main() {
    print("== Lesson 2: student input gate ==");
    reg.declareField("toy shelf");
    reg.register("red box", "toy shelf");
    reg.register("blue box", "toy shelf");
    reg.register("ball", "red box");

    show(1, "the ball is in the red box", "red box");
    show(2, "", "blue box");
    show(2, "the book is in the blue box", "green box");
    show(3, "the ball is a noun", "ball");
    show(2, "the blue box is on the shelf", "blue box");
    show(3, "the ball is a noun", "ball");

    print("-- instructor tally --");
    print("  good=" + good + " refused=" + refused + " last accepted step=" + lastStep);
  }
}