slatex / sTeX

A semantic Extension of TeX/LaTeX
49 stars 9 forks source link

Answer classes for export in problem.sty #401

Closed kohlhase closed 8 months ago

kohlhase commented 10 months ago

Answerclasses currently have the attributes id, pts, and schema, they also need the feedback attribute, so that we can write

 \answclass[id=foo,feedback=bar,pts=2]{answer class description}

for the answer class awarding 2 points by default, and providing the feedback bar. Here is a complete example, it is also at https://gl.mathhub.info/MiKoCourses/krmt/-/blob/main/source/SS23/probex.en.tex:

\begin{sproblem}[id=foo,title=FOO]
  consider the following situation
  \begin{subproblem}[id=foo:first,title=First subproblem,pts=2]
    find a Bar here
    \begin{solution}
      here it is 
    \end{solution}
    \begin{gnote}
      that was easy
      \anscls[id=nf,pts=0,feedback=try harder]{not found}
      \anscls[id=downtown,pts=1,
        feedback={that was already good, but we want a street address}]
        {only specifies there are lots downtown}
      \anscls[id=streetaddress,pts=2]{gives a street address}
      \anscls[id=directions,pts=2]{gives directions to walk there}
    \end{gnote}
  \end{subproblem}
\end{sproblem}

This should export the JSON (see https://gl.mathhub.info/MiKoCourses/krmt/-/blob/main/source/SS23/probex.json:

{"type":"sproblem",
 "id":"foo",
 "title":"FOO",
 "subproblems":[
     {"id":"foo:first",
      "title":"First subproblem",
      "pts":2,
      "gnote":{"text":"that was easy",
           "anscls": [
           {"id":"nf",
            "pts":0,
            "feedback":"try harder"
            "description":"not found"},
           {"id":"downtown",
            "pts":1,
            "feedback":"that was already good, but we want a street address"
            "description":"only specifies there are lots downtown"},
           {"id":"streetaddress",
            "pts":2,
            "description":"gives street address"},
           {"id":"directions",
            "pts":2,
            "description":"gives directions to walk there"}
           ]
          }
     }
 ]
}
lambdaTotoro commented 10 months ago

I think the information "type" : "sproblem" is not necessary. Same for ids for answer classes. You're likely to just reproduce (parts of) the description anyway. Default description, feedback and points is sensible, though.

That would lead to JSON looking something like this:

{
    "id" : "foo",
    "title" : "FOO",
    "subproblems" : [
        {
            "id" : "foo:first",
            "title" : "First subproblem",
            "pts" : 2,
            "gnote" : {
                "text":"that was easy",
                "anscls": [
                    {
                        "pts" : 0,
                        "feedback" : "try harder",
                        "description" : "not found"
                    },
                    {
                        "pts" : 1.5,
                        "feedback" : "that was already good, but we want a street address",
                        "description" : "only specifies there are lots downtown"
                    },
                    {
                        "pts" : 2,
                        "description" : "gives street address"
                    },
                    {
                        "pts":2,
                        "description" : "gives directions to walk there"
                    }
                ]
            }
        }
    ]
}
Jazzpirate commented 10 months ago

one caveat: "title", "feedback" and "description" are going to be HTML. Largely they should be "trivial" HTML in the sense of: maybe a div with some class that won't exist and can be ignored with plain text content. But I'm not in charge of what people put in there, so comple-latex-in-complex-HTML-out, I guess :D

lambdaTotoro commented 9 months ago

Actually, I've noticed I need a bit more information in the JSON. We use the numbers of exercises for correcting, so it would be helpful to have them included in the json. Otherwise, it's difficult to know if the third problem specified is "1.3" or if there's only "1.1" and "1.2" and this one is already "2.1"...

And because I was editing anyway, I also added some answer traits (as opposed to answer classes, see #404 if you can find it).

{
    "id" : "foo",
    "title" : "FOO",
    "number" : "2.1",
    "subproblems" : [
        {
            "id" : "foo:first",
            "title" : "First subproblem",
            "number" : "2.1.1",
            "pts" : 2,
            "gnote" : {
                "text":"that was easy",
                "anscls": [
                    {
                        "pts" : 0,
                        "feedback" : "try harder",
                        "description" : "not found"
                    },
                    {
                        "pts" : 1.5,
                        "feedback" : "that was already good, but we want a street address",
                        "description" : "only specifies there are lots downtown"
                    },
                    {
                        "pts" : 2,
                        "description" : "gives street address"
                    },
                    {
                        "pts":2,
                        "description" : "gives directions to walk there"
                    },
                    {
                        "pts" : "+0.5",
                        "description" : "Student did better",
                        "feedback" : "well done"
                    },
                    {
                        "pts" : "-0.5",
                        "description" : "Student did worse"
                    }
                ]
            }
        }
    ]
}
kohlhase commented 8 months ago

this is done, right?