diff options
| author | jwansek <eddie.atten.ea29@gmail.com> | 2022-03-04 17:38:01 +0000 | 
|---|---|---|
| committer | jwansek <eddie.atten.ea29@gmail.com> | 2022-03-04 17:38:01 +0000 | 
| commit | 524fa81d71d335a04ab3610c39c5c8e74eb732a4 (patch) | |
| tree | 699260f2fece94510f4d61c366091d1b5f91ba2a | |
| parent | 92f710554dac6fb75e0c3b4bcf4a0305ee4df4c3 (diff) | |
| download | Smarker-524fa81d71d335a04ab3610c39c5c8e74eb732a4.tar.gz Smarker-524fa81d71d335a04ab3610c39c5c8e74eb732a4.zip | |
started work on templating for tex
| -rw-r--r-- | jinja_helpers.py | 2 | ||||
| -rw-r--r-- | reflect.py | 5 | ||||
| -rw-r--r-- | smarker.conf | 6 | ||||
| -rw-r--r-- | smarker.conf.example | 17 | ||||
| -rw-r--r-- | templates/tex.jinja2 | 74 | 
5 files changed, 82 insertions, 22 deletions
| diff --git a/jinja_helpers.py b/jinja_helpers.py index ca0748d..7f51881 100644 --- a/jinja_helpers.py +++ b/jinja_helpers.py @@ -42,7 +42,7 @@ def junit_xml_to_html(junit_xml, student_id):      pdfkit.from_string(lxml.etree.tostring(root).decode(), out_fname)      # remove the tempfiles -    input("%s continue..." % html_path) +    # input("%s continue..." % html_path)      shutil.rmtree(os.path.split(html_path)[0])      os.remove(xml_f.name) @@ -260,8 +260,9 @@ def gen_reflection_report(client_code_path, assessment_struct, student_no, confi              out["files"][i][required_file]["exception"] = {}              out["files"][i][required_file]["exception"]["type"] = str(type(e))              out["files"][i][required_file]["exception"]["str"] = str(e) -            # TODO: work out how to only get the exception stack of the client code -            out["files"][i][required_file]["exception"]["traceback"] = ''.join(traceback.format_exception(None, e, e.__traceback__)) +            # TODO: test this indexing so we can be sure we're getting client code only +            e_list = traceback.format_exception(None, e, e.__traceback__) +            out["files"][i][required_file]["exception"]["traceback"] = ''.join([e_list[0]] + e_list[12:])              continue diff --git a/smarker.conf b/smarker.conf index 62180b5..354762c 100644 --- a/smarker.conf +++ b/smarker.conf @@ -4,6 +4,12 @@ port = 3306  user = root
  passwd = *************
 +[tex]
 +show_full_docs = True
 +show_source = True
 +show_all_regex_occurrences = True
 +show_all_run_output = True
 +
  [md]
  show_full_docs = False
  show_source = False
 diff --git a/smarker.conf.example b/smarker.conf.example deleted file mode 100644 index e8db25c..0000000 --- a/smarker.conf.example +++ /dev/null @@ -1,17 +0,0 @@ -[mysql]
 -host = 192.168.1.92
 -port = 3306
 -user = smarker
 -passwd = smarkerPassword
 -
 -[md]
 -show_full_docs = False
 -show_source = False
 -show_all_regex_occurrences = True
 -show_all_run_output = False
 -
 -[txt]
 -show_full_docs = False
 -show_source = False
 -show_all_regex_occurrences = True
 -show_all_run_output = False
\ No newline at end of file diff --git a/templates/tex.jinja2 b/templates/tex.jinja2 index bcc6aab..6aa366c 100644 --- a/templates/tex.jinja2 +++ b/templates/tex.jinja2 @@ -2,7 +2,16 @@  \usepackage[margin=1in]{geometry} % margins
  \usepackage{forest} % for the class tree
 -\usepackage{pdfpages}
 +\usepackage{pdfpages} % for importing the test results pdf
 +\usepackage{xcolor} % colours
 +\usepackage{listings}
 +\lstset{
 +basicstyle=\small\ttfamily,
 +columns=flexible,
 +breaklines=true
 +}
 +
 +\newcommand{\errortext}[1]{\textcolor{red}{\textbf{#1}}}
  \author{((( student_no )))}
  \title{((( name ))) - Automatic marking report}
 @@ -20,7 +29,68 @@      \caption{Class inheritance tree}
  \end{figure}
 +\section{File Analysis}
 +((* set flat_files = flatten_struct(files) *))
 +((* for filename, files_contents in flat_files.items() *))
 +    \subsection{\texttt{((( filename )))}}
 +    ((* if files_contents["present"] *))
 +        ((* if files_contents["has_exception"] *))
 +            \errortext{File cannot be run - has compile time exception.}
 +
 +            Please note that this file cannot be analysed or have tests preformed upon it-
 +            this can lead to the whole test suite failing if another module imports this.
 +                    
 +            \textbf{Exception Type:} \texttt{((( files_contents["exception"]["type"] )))}
 +            
 +            \textbf{Exception String:} \texttt{((( files_contents["exception"]["str"] )))}
 +
 +            \textbf{Full Traceback:}
 +
 +            \begin{lstlisting}
 +((( files_contents["exception"]["traceback"] )))
 +            \end{lstlisting}
 +        ((* else *))
 +            \subsubsection{Documentation:}
 +
 +            ((( len_documentation(files_contents["documentation"]["comments"], files_contents["documentation"]["doc"]) ))) characters long
 +            ((* if tex_show_full_docs == "True" *))
 +                
 +                \textbf{Comments:}
 +                ((* if files_contents["documentation"]["comments"] == "None" *))
 +                    \errortext{No comments present.}
 +                ((* else *))
 +                    \begin{lstlisting}
 +((( files_contents["documentation"]["comments"] )))
 +                    \end{lstlisting}
 +                ((* endif *))
 +
 +                \textbf{Docstring:}
 +                ((* if files_contents["documentation"]["doc"] == "None" *))
 +                    \errortext{No docstring present.}
 +                ((* else *))
 +                    \begin{lstlisting}
 +((( files_contents["documentation"]["doc"] )))
 +                    \end{lstlisting}
 +                ((* endif *))
 +            ((* endif *))
 +
 +            ((* if "classes" in files_contents.keys() *))
 +                \subsubsection{Classes}
 +
 +
 +            ((* endif *))
 +
 +        ((* endif *))
 +    ((* else *))
 +        \errortext{File is not present.}
 +    ((* endif *))
 +((* endfor *))
 +
  \section{Tests}
 -\includepdf[pages={1-},scale=0.9]{((( junit_xml_to_html(test_results["junitxml"], student_no) )))}
 +((* if test_results["pytest_report"] == "*** No Tests ***" *))
 +    No tests were executed.
 +((* else *))
 +    \includepdf[pages={1-},scale=1.0]{((( junit_xml_to_html(test_results["junitxml"], student_no) )))}
 +((* endif *))
  \end{document}
\ No newline at end of file | 
