Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General reorganization and fix #22. #34

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,60 @@ Scripts for preparing student programs for grading.
Scripts convert student repository code to a PDF file for
grading.

## Example

In this example we have the following structure:

hw1
├── config.json
└── submissions
├── jh
│   └── Lab10Code
│   ├── Employee.java
│   ├── Faculty.java
│   ├── Person.java
│   ├── Staff.java
│   └── Student.java
└── wk
└── Lab10Code
├── Employee.java
├── Faculty.java
├── Person.java
├── Staff.java
└── Student.java


`config.json` contains the following:

{
"directory" : "/Users/karl/GoogleDrive/Courses/CS-140/StudentSubmissions/S1-2014/grading/Lab10",
"files" : [
"Lab10Code/Person.java",
"Lab10Code/Student.java",
"Lab10Code/Employee.java",
"Lab10Code/Faculty.java",
"Lab10Code/Staff.java"
]
}

* `directory` - Path to the directory containing student submission
subdirectories. Paths are relative to the configuration file's location.
* `files` - List of files to process for each submission directory. Paths are
relative to each student's submission directory.

`submissions` contians a subdirectory for each students' work. The names of each
subdirectories is not important. In this example they are the initials of each
student.

We process the assignment as follows:

$ python path/to/assignmentconvert.py hw1/config.json

## Run tests

$ cd grading-scripts
$ python run_tests.py

## Writting a processor

See `assignmentconvert.py` for an example.
122 changes: 0 additions & 122 deletions assignment.py

This file was deleted.

31 changes: 9 additions & 22 deletions assignmentconvert.py → collect_pdfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,17 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
import argparse
import os
from assignment import Assignment
from command import Command
from submissions import SubmissionProcessor


class LabConvert(object):

class LabConvert(SubmissionProcessor):
def __init__(self):
parser = argparse.ArgumentParser()
parser.add_argument('config', help='JSON configuration file')
parser.add_argument(
'-v', '--verbose',
help='increase output verbosity',
action='store_true'
)
args = parser.parse_args()
Command.set_default_verbosity(args.verbose)
self._a2pdf = Command(
'a2pdf --noperl-syntax --noline-numbers "{ins}" -o "{ins}.pdf"')
self._pdfcat = Command('pdftk "{ins}" cat output "{outs}"')
self._create_log = Command('git log > log.txt')
self._rm = Command('rm "{ins}"')
Assignment(args.config).accept(self.process_submission)
super().__init__(self)
self._a2pdf = self.command(
'a2pdf --noperl-syntax --noline-numbers {ins} -o {ins}.pdf')
self._pdfcat = self.command('pdftk {ins} cat output {outs}')
self._create_log = self.command('git log > log.txt')
self._rm = self.command('rm {ins}')

def process_submission(self, directory, files):
self._create_log()
Expand All @@ -49,4 +36,4 @@ def process_submission(self, directory, files):


if __name__ == '__main__':
LabConvert()
LabConvert().run()
79 changes: 0 additions & 79 deletions command.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions run_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (C) 2014 Karl R. Wurst
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA

from unittest import TestLoader
from unittest.runner import TextTestRunner
from os.path import dirname, abspath


if __name__ == '__main__':
TextTestRunner().run(TestLoader().discover(abspath(dirname(__file__))))
Loading