HackerDan.com http://hackerdan.com Dan's Blog Fri, 30 Jun 2017 02:35:36 +0000 http://wordpress.org/?v=2.2.1 en Using Java CUP http://hackerdan.com/programing/using-java-cup/ http://hackerdan.com/programing/using-java-cup/#comments Tue, 16 Mar 2010 05:24:49 +0000 Dan http://hackerdan.com/programing/using-java-cup/ The following is a tutorial on using java CUP with JFlex for the project 2 assignment in CS4413/CS5413 at Lakehead University

Install and Setup

It is assumed that you have java and jflex (see http://hackerdan.com/programing/using-jflex/) installed and working.

Download CUP from http://www2.cs.tum.edu/projects/cup/ (direct link: http://www2.cs.tum.edu/projects/cup/java-cup-11a.jar)

Move java-cup-11a.jar onto your class path or add the directory java-cup-11a.jar is in to your class path.

For example, if java-cup-11a.jar is in /home/dan/comp_class/java-cup-11a, add /home/dan/comp_class/java-cup-11a to your class path. See http://hackerdan.com/programing/using-jflex/ for details on changing environment variables.

Create a directory named parser (this is where your code will go), and copy all the files included with the project from WebCT. The following files should be included:


Note that lexer.flex is different from project 1 and contains a complete lexer for use with this project. Also note that the Token class has been replaced by LEXSymbol.java which functions differently. You can use your solution from project 1 in place of lexer.flex but it will likely need some heavy modifications.

If you have JFlex installed from project 1 and a working java compiler everything should be ready to go.

Using Java CUP

First run JFlex on the lexer.java file to generate Lexer.java (see http://hackerdan.com/programing/using-jflex/ for details).

Add your changes to parser.cup (fill out the nonterminals, precedences and grammar sections, see the next section for tips) and run:

java -jar /home/dan/comp_class/java-cup-11a.jar parser.cup

This should generate parser.java and sym.java and have output similar to:

------- CUP v0.11a beta 20060608 Parser Generation Summary -------
0 errors and 0 warnings
42 terminals, 18 non-terminals, and 90 productions declared,
producing 192 unique parse states.
0 terminals declared but not used.
0 non-terminals declared but not used.
0 productions never reduced.
0 conflicts detected (0 expected).
Code written to "parser.java", and "sym.java".
---------------------------------------------------- (v0.11a beta 20060608)

If you get Errors that look like the following:

Error: Syntax error @ Symbol: LBRACK (unknown:82/19 - unknown:82/20)
Error : Illegal use of reserved word

It means there is a syntax error on the given line (in this case 82).

If you get a warning such as:

Warning : Scanner at 122(10): Unrecognized character '{' -- ignored

It means there is an illegal character in your .cup file (many of the common regex and EBNF characters are not supported in Java CUP).

If you get a warning such as:

Warning : Terminal "UMINUS" was declared but never used

It means one of your terminals or none terminal which was declared in your .cup was never used in your grammar. In some cases this is ok.

If you get a warning such as:

Warning : *** Reduce/Reduce conflict found in state #12
between lvalue ::= ID (*)
and type ::= ID (*)
under symbols: {ID}
Resolved in favor of the first production.

It means a conflict was found in your grammar where two rules have identical right parts and the parser is basically guessing which one to use. For example:

nterm1 ::= ID;
nterm2 ::= ID;

Will cause this error as the rules are the same.

If you get a warning such as:

Warning : *** Shift/Reduce conflict found in state #12
between lvalue ::= ID (*)
under symbol ID
Resolved in favor of shifting.

It means there is a conflict in your grammar where after shifting two rules are identical, for example:

nterm1 ::= TERM '+' nterm3;
nterm2 ::= TERM '+' ID;
nterm3 ::= ID;

In this case nterm1 and nterm2 are identical after ID is substituted in for nterm3.

Although grammar conflicts are warnings, they should not be ignored as they indicate there is likely a problem with your grammar despite the syntax being valid.

Warnings such as:

Warning : *** Production "formal ::= type ID " never reduced

mean that rule can never be reached from the given “start with” rule. This is a problem if you expect that rule to be part of your parser.

Keep fixing any warnings and errors until generation succeeds with no errors. Next we need to compile the generated code:

Compile LEXSymbol.java (from WebCT):

javac -classpath .:/home/dan/comp_class/java-cup-11a/java-cup-11a.jar parser/LEXSymbol.java

/home/dan/comp_class/java-cup-11a/java-cup-11a.jar with the full path to java-cup-11a.jar on your system in the above and following examples (or set up your classpath so the -classpath argument is not needed).

Compile sym.java (generated by Java CUP):

javac -classpath .:/home/dan/comp_class/java-cup-11a/java-cup-11a.jar parser/sym.java

Compile parser.java (generated by Java CUP):

javac -classpath .:/home/dan/comp_class/java-cup-11a/java-cup-11a.jar parser/parser.java

Compile Lexer.java (generated by JFlex):

javac -classpath .:/home/dan/comp_class/java-cup-11a/java-cup-11a.jar parser/Lexer.java

Compile Driver.java (from WebCT):

javac -classpath .:/home/dan/comp_class/java-cup-11a/java-cup-11a.jar parser/Driver.java

If there were any errors or warnings while compiling, there is a issue with one of your specification files (.cup or .flex), something wrong with your environment variables (class path issue), or an issue relating to how your java package is set up.

Once everything is compiled you may run your parser like so:

java -classpath .:/home/dan/comp_class/java-cup-11a/java-cup-11a.jar parser.Driver parser/test.cmm

where the second argument is the path to your .cmm code file.

If there was an issue with your grammar or the code in the .cmm file is not valid, you will get error such as:

Syntax error parser/test.cmm:22:2 Got: 'else'

if the .cmm is valid you should go back to your .cup file and try to fix any issues and regenerate and recompile everything.

A successful run (assuming the code file is valid) will look like:

parsing [parser/test.cmm]
Lexeme for comment [/* Foo Class */]
Lexeme for comment [/* Main Class */]
Parsing Completed. Top symbol = #0

At this point you should have a parser capable of validating  a C– file, which is all that is required for the project. However if you would like to use Java CUP to make a C– interpreter capable of running simple C– code there are a few more steps needed which you can read about in the PDFs on the following link: http://www.cs.auckland.ac.nz/~bruce-h/lectures/330ChaptersPDF/ (particularly chapter 9).

Parser Specification

Java CUP’s specification file has five main sections:

Any settings or emended code that will affect how the parser.java file is generated. In our case this section is provided for us and should not need any changes.

Code between “parser code {:” and “:}” is placed in the parser class in the generated parser.java file.

This section lists all terminals that may be used in the parsers’ grammar. These terminals are the tokens from our JFlex scanner and in this case are provided for us.

The format of the terminal line is as follows:

terminal [TYPE] TERM [, TERM]*;

Where the optional TYPE parameter specifies what type the terminal objects listed are of and the TERM parameters list the terminals that may be used in the grammar section.

Non Terminals
Non terminals are the rules of the grammar and follow the same format as in the terminal section. Each terminal must be defined before it may be used and as with the terminals the type parameter is optional.


nonterminal classList, classDed, deck, formals, statement, assignment;

Note that both terminal and non terminal names cannot be CUP reserved words (”code”, “action”, “parser”, “terminal”, “non”, “nonterminal”, etc).


Often grammar is ambiguous and this section lets us state the precedences and associatively of terminals outside of our grammar (allowing us to keep the grammar simple, and still resolve ambiguity). This section is optional if your grammar has no ambiguity.

The format is as follows:

precedence (left | right | nonassoc) terminal [, terminal]*;

These lines set the order of precedence, from highest to lowest, from bottom to top. For example:

precedence left ADD, SUBTRACT;
precedence left TIMES, DIVIDE;

Resolves the ambiguity in grammar such as:

with ADD and SUBTRACT having a lower precedence than TIMES and DIVIDE (multiplication and division will be performed before the addition and subtraction).

Any terminal not listed will be given the lowest precedence. See http://www2.cs.tum.edu/projects/cup/manual.html for more information.


Finally the grammar section allows the specification of the parsers’ grammar in a BNF like format. Note that this format is not the same as the EBNF format that the grammar for C– is given in, and some rules and changes will need to be added and made.

The starting rule is specified with the “start with” tag as shown below:

start with classList;

An example of a simple grammar is shown below:

start with A;

A ::= A ADD A
| a;

This is a simplistic explanation of the grammars in CUP, for more info see: http://www2.cs.tum.edu/projects/cup/manual.html.

Project Hints

  • Don’t modify the code in Driver.java,  SrcLoc.java, or LEXSymbol.java. There should be no need for this project, however, looking over how they work will help in creating your parser and understanding how it works.
  • Don’t modify the code in parser.java or Lexer.java manually, they should be generated via Java CUP and JFlex respectively. You can embed code in the specification file that will be placed in the generated .java file, however, there should be no need for this project.
  • Make sure you have your class path settings right or give the full path to the Java CUP jar like in the examples given.
  • Make sure you have the java package set up correctly. All class and java files should be in the parser package and in a directory with the same name.
  • Don’t ignore warnings from Java CUP, they almost always indicate that something is wrong and needs fixing.
  • If you use the given .jflex file the only file you need to submit is the .cup file, however, you may also include example outputs, test cases and screenshots.
  • If you don’t use the given .jflex make sure to include yours and any .java files it uses. Also ensure that you note any changes you made. Your lexer from project 1 may need some changes to work with Java CUP, use the given .jflex files as an example.
  • The grammar given in the project for C– will need changes to work with Java CUP, but should be equivalent.
  • If you make any improvements to the given grammar, make sure to note them and why they were added so they are not marked as incorrect.
  • Make sure to put your name and student number on everything (you would be surprised how many students forget this).
  • Use Java CUP 11a beta 20060608 executable standalone Jar-package (this is what I will use to mark your project)


Java CUP

  • Java CUP: http://www2.cs.tum.edu/projects/cup
  • Java CUP Manual: http://www2.cs.tum.edu/projects/cup/manual.html
  • Java CUP Download: http://www2.cs.tum.edu/projects/cup/java-cup-11a.jar


  • JFlex: http://jflex.de/
  • JFlex Download: http://jflex.de/jflex-1.4.3.zip
  • JFlex Manual: http://jflex.de/manual.html


  • Bruce Hutton’s Lecture Notes: http://www.cs.auckland.ac.nz/~bruce-h/lectures/330ChaptersPDF/


  • CUP grammar for the Java programming language: http://www2.cs.tum.edu/projects/cup/javagrm.tar.gz
  • CUP/JFLex interoperability: http://www2.cs.tum.edu/projects/cup/minimal.tar.gz
  • CUP/JFLex sample project: http://www2.cs.tum.edu/projects/cup/demo.zip
Using JFlex http://hackerdan.com/programing/using-jflex/ http://hackerdan.com/programing/using-jflex/#comments Fri, 15 Jan 2010 21:06:32 +0000 Dan http://hackerdan.com/programing/using-jflex/ The following is a tutorial on using JFlex for the project 1 assignment in CS4413/CS5413 at Lakehead University

Step 1: Download and Setup JFlex

The first step is to download and setup jflex (assuming you have java installed and setup correctly).

The link to download it is: http://jflex.de/jflex-1.4.3.zip
Once you have the zip file downloaded unzip it into a folder where you would like to install it. This can be any folder as long as your user account has permission to run the programs in it. In my case (using linux) I have installed it to /home/dan/compilers/jflex-1.4.3.

Next you need to add the bin directory in jflex-1.4.3 to the system’s path. How to do this is different on each OS.

For windows XP:
1. Start -> Control Panel -> System -> Advanced
2. Click on Environment Variables, under System Variables, find PATH, and click on it.
3. In the Variable Value text box add ;my_path_to_jflex\jflex-1.4.3\bin\ to the end  where “my_path_to_jflex” is your path to the jflex folder you installed. For example if you installed jflex to C:\Users\Dan\jflex-1.4.3 the text that you would add to the path would be ;C:\Users\Dan\jflex-1.4.3\bin\  make sure to not to delete the contents of the text box and only add to them.
4. Click OK -> OK -> OK untill you are back to the desktop.

See http://support.microsoft.com/kb/310519 for more information on system variables in xp.

For windows Vista and 7:
1. Click on the start menu and type “edit the system environment variables” into the search box in till you see the control panel short cut come up.
2. Click “edit the system environment variables” and then click Environment Variables on the window that pops up.
3. From the System variables list find Path and double click on it.
4. In the Variable Value text box add ;my_path_to_jflex\jflex-1.4.3\bin\ to the end where “my_path_to_jflex” is your path to the jflex folder you installed. For example if you installed jflex to C:\Users\Dan\jflex-1.4.3 the text that you would add to the path would be ;C:\Users\Dan\jflex-1.4.3\bin\ make sure to not to delete the contents of the text box and only add to them.
5. Click OK -> OK -> OK untill you are back to the desktop.

For Linux/Unix using the bash shell:
1. Open ~/.bashrc in your favorite editor (ex. nano ~/.bashrc).
2. At the end of the file add:

export PATH

Where your_path_to_jflex is your path to the folder where you installed jflex. For example my PATH line is PATH=$PATH:/home/dan/compilers/jflex-1.4.3/bin
3. Save the file.

Once you have updated the path on your system you may need to logout and back in or restart your shell before the changes take effect.

Windows users will also have to edit the jflex.bat file in jflex-1.4.3/bin and set JFLEX_HOME in the file to their correct value.

JFLEX_HOME should point to the directory where jflex is installed. For example if jflex was installed to C:\Users\Dan\jflex-1.4.3\ the line should be: set JFLEX_HOME = C:\Users\Dan\jflex-1.4.3\

Next the lines following the “only needed for JDK 1.1.x” and “for JDK 1.1.x” comments should be removed or commented out. And finally the “rem” on the last line should be removed. The file should look something like this:

@echo off
REM Please adjust the paths JFLEX_HOME and JAVA_HOME to suit your needs
REM (please do not add a trailing backslash)

set JFLEX_HOME=C:UsersDanjflex-1.4.3

REM -------------------------------------------------------------------

set CLPATH=%JAVA_HOME%libclasses.zip;%JFLEX_HOME%libJFlex.jar

REM for JDK 1.2
java -Xmx128m -jar %JFLEX_HOME%libJFlex.jar %1 %2 %3 %4 %5 %6 %7 %8 %9

Linux users may want to take a look at the jflex-1.4.3/bin/jflex script however, it should be fine by default.

Step 2: Using JFlex

Jflex can be used via it’s GUI or via the command line. To use the GUI simply type jflex on the command line/shell and the GUI should run. To pass an input file to jflex via the command line simply type jflex input_file where input_file is the name of the lexical specification file (in our case lexer.flex).

1. Click the browse button for the Lexical specification field and select your Lexical Specification file (lexer.flex).
2. If you want to output the java class in a different directory then listed in the output directory filed, click the browse button by the output field and select the new output directory.
3. Click generate.
4. Look at the Messages text box. If there are warnings or errors there is likely something wrong with the contents of your lexer.flex file, go through it and fix any errors and try to generate it again. If there are no errors or warnings your lexical analyzer should be created in the output directory as a .java file (in our case Lexer.java).

Command Line
1. Use the command line or shell to navigate to the directory with your lexical specification (lexer.flex).
2. Type in jflex input_file where input_file is the name of your specification (lexer.flex).
3. If there are warnings or errors there is likely something wrong with the contents of your lexer.flex file, go through it and fix any errors and try to generate it again.
4. If there were no errors or warnings your lexical analyzer should now be output in the same folder as a .java file (in our case Lexer.java).

For more details on install and running jflex see http://jflex.de/installing.html

Step 3: Using the Lexical Analyzer

For this assignment a Driver.java and Token.java file were given to you that contain the code to use the lexical analyzer generated as Lexer.java. To use them on the C– code provided you must first compile the java code using javac. Since Driver, Token and Lexer are all in the same package they must be in the same directory named lexer. To compile the code simple issue the following commands in your shell/command line:

javac Token.java
javac Lexer.java
javac Driver.java

If there was an error comping the Lexer.java file, there likely was a problem with your lexical specification.

If all the code complied with no errors or warnings you should be able to run the Driver program on some C– code by issuing the fallowing command:

java Driver cmm_file

Where cmm_file is the text file contain the C– code. For example if the code file is test.cmm the line should be java Driver test.cmm.

Ideally there should be not errors and the output should match the example output given (assuming you used the example input in test.cmm).

Assignment Tips

  • Make sure all your class files are in the same folder named lexer and that this folder is in the java class path.
  • There should be no need to make any changes to any of the .java files. All the work should be done in the lexer.flex file.
  • Take a look at the contents of the Token.java file, the tokens that are returned by nextToken in the scanner should be of this type.
  • Make sure to test your scanner on the given sample input/output.
  • You can find the jflex documentation here: http://jflex.de/manual.html which will help you in creating the lexer.flex specification.
  • http://www.cs.auckland.ac.nz/~bruce-h/lectures/330ChaptersPDF/ is also a good resource for using JFlex and CUP.
RMS at Lakehead University http://hackerdan.com/uncategorized/rms-at-lakehead-university/ http://hackerdan.com/uncategorized/rms-at-lakehead-university/#comments Mon, 01 Jun 2009 05:06:26 +0000 Dan http://hackerdan.com/uncategorized/rms-at-lakehead-university/ On May 30th, 2009 Richard Stallman (RNS) was awarded an honorary degree from Lakehead University in Thunder Bay Ontario and gave the convocation address to the Lakehead’s 2009 graduates. RMS’s address focused on the need for educational institutions to switch to free and open software rather then addicting there students to proprietary products from the software giants. Lakehead’s use of windows media format for there streaming video of the convocation ceremony and use of proprietary software for teaching was heavily cirtisesd provoking Dr. Gilbert, president of the university, to offer a small rebuttal after the address and agreed to consider Stallman’s challenge to adopt free software in the university.

A recording of the convocation address can be found below:

Download MPEG Copy

Screen Cast http://hackerdan.com/gsoc/screen-cast/ http://hackerdan.com/gsoc/screen-cast/#comments Thu, 18 Sep 2008 21:50:17 +0000 Dan http://hackerdan.com/gsoc/screen-cast/ After having tones of trouble with sound drivers and getting my mic to work i have finally been able to get sound in my screen cast and it uploaded.

You can view the flash version of the screen cast here: http://compsci.ca/~dan/screencast.swf

This screen cast is a demo of the first version of the Moodle Grade Book stats and visual reports witch i worked on for Google Summer of Code.

End of My Summer of Code http://hackerdan.com/gsoc/end-of-my-summer-of-code/ http://hackerdan.com/gsoc/end-of-my-summer-of-code/#comments Tue, 19 Aug 2008 04:30:50 +0000 Dan http://hackerdan.com/gsoc/end-of-my-summer-of-code/ Today is the official pencil down date for the 2008 Google Summer of Code and is the last day code can be submitted to be counted in the final evaluation. This is also the week i move back to Thunder Bay to start a new term at Lakehead University, so it has been a busy week of finishing up code and documentation, getting packed up for the move and setting up the CompSci.ca server to host a new project i will be a part of this fall.

I have committed the latest code for the project and considering this to be a first release of the report/stats and report/visual plug-ins for Moodle 2.0 dev. I have also update my test site with the newest code so any one can take a look at the plug-ins running in a Moodle install (you can login as guest). I had also hoped to have a screen cast demoing the plug-ins for today however due to some trouble getting sound working right it will probably be ready late Tuesday or early Wednesday.

Anthony Borrow has requested that i get an entry for the plug-ins added to the Moodle Modules and Plugins Database and some pages up about it on the Moodle Wiki instructing users how to use the plug-ins and install them, witch i plan to also get done this week, time and internet permitting (i may not have internet access for a few days well moving back to Thunder Bay).

You can download the plug-ins at:

report/visual: http://download.moodle.org/plugins/grade/report/visual.zip
report/stats: http://download.moodle.org/plugins/grade/report/stats.zip

GSoC 2008: Comming to an end http://hackerdan.com/gsoc/gsoc-2008-comming-to-an-end/ http://hackerdan.com/gsoc/gsoc-2008-comming-to-an-end/#comments Wed, 06 Aug 2008 23:44:58 +0000 Dan http://hackerdan.com/gsoc/gsoc-2008-comming-to-an-end/ Google Summer of Code 2008 is coming to an end with the “Suggested ‘pencils down’ date” on the 11th and the “Firm ‘pencils down’ date.” on the 18th and yet i still feel like there is so much that could be added to my project.

Whats done:

  • report/stats gradebook plug-in works and shows text based statics on a courses grades in a table format.
  • report/stats has a modular design that allows for new statics to be dropped in.
  • Printable version of report/stats.
  • Group related functions for report/stats.
  • Settings page for report/stats.
  • report/visual gradebook plug-in’s framework is done and allows for new visualization to be dropped in.
  • report/visual gradebook plug-in’s flash/flex with flare front end is in a running state and can take grade data from Moodle, a visualization’s settings in an XML format and turn them into an interactive visualization for the user.
  • Continuous Grade Distribution Visualization.
  • Grade Distribution by Item (Bar) Visualization.
  • Grade Distribution by Group (Bar) Visualization.
  • Grade Distribution (Line) Visualization.
  • Normalized Grades vs Students Visualization.
  • Ability to invert Visualization’s axes.
  • Ability to hide axes.
  • Ability to hide axes labels.
  • Ability to hide any legend item (hide a group or item).
  • UI Selector widget for changing data source of the visualization.
  • Highlighting of legend items (highly a group or item in a graph).
  • Popup detailing a nodes information/data.

What needs to be done this week:

  • Finish printer friendly version of report/visual.
  • Add in checking of users capability to see if they should be able to view a visualization or statistic.
  • Add in two or three other visualizations i was planing to get in.
  • Finish options page for report/visual.
  • Fix mode problem in report/stats where students could possibly see all grades.

What needs to be done before the 18th:

  • Add more documentation.
  • Do final testing and fix any bugs found.
  • Clean up code.

What i wanted to get in but probably will not have time for:

  • Back port to Moodle 1.9.x
  • Export functionality to other programs and document types like excel.
  • Port to flare 2008.07.29 (new major flare release that had some big changes to the API witch would require some recoding of the plug-in’s front end).
  • Stats and visuals for outcomes and outcome reports.
  • “Find me in data” - a feature i wanted to add to show a user where they are in the data being visualized.
  • More options, more controls, more functions, more cool looking animations, more visualizations, more statistics, etc.
  • Better looking graphically and more natural UI.
  • Add reports that go beyond just grades in a course. Compare diffrent courses, years, drop out trends, age of students, submission times, etc.

Overall i am rather happy with how far the project has come considering that at the start i knew nothing of Moodle, Flex, Flare, Actionscript 3, or much flash. I think the plug-ins that i have made will be use full to teachers and educators and i hope to keep supporting them and working on them in my spare time as a hobby after GSoC has come to an end.

CVS: CONTRIB-497 2/August/08 http://hackerdan.com/uncategorized/cvs-contrib-497-2august08/ http://hackerdan.com/uncategorized/cvs-contrib-497-2august08/#comments Sat, 02 Aug 2008 05:22:04 +0000 Dan http://hackerdan.com/uncategorized/cvs-contrib-497-2august08/ CONTRIB-497
*Added more visualizations
*Added selector UI Widget for flex/flare visualization
*Refactored some of flex actionscript code.
*Added defaults for selected group and items in visualizations.
*Improved removal of nodes and edges when an item or group is deselected in a legend.
*Fixed a memory leak realting to the removal and addtion of nodes.
*Added more options for and control of the flex/flare based visualization from the Moodle back end.

MODIFY plugins/grade/report/visual/ visual_settings.php   Rev. 1.2   (+105 -33 lines)
MODIFY plugins/grade/report/visual/ data.php   Rev. 1.3   (+3 -3 lines)
MODIFY plugins/grade/report/visual/ flare_visualization/bin-debug/flare_visualization.swf   Rev. 1.4   (+0 -0 lines)
MODIFY plugins/grade/report/visual/ flare_visualization/flare_visualization.as   Rev. 1.4   (+488 -178 lines)
MODIFY plugins/grade/report/visual/ flare_visualization.swf   Rev. 1.4   (+0 -0 lines)
MODIFY plugins/grade/report/visual/ visualizations/visualization.php   Rev. 1.2   (+19 -1 lines)
MODIFY plugins/grade/report/visual/ lang/en_utf8/gradereport_visual.php   Rev. 1.3   (+9 -0 lines)
MODIFY plugins/grade/report/visual/ lib.php   Rev. 1.4   (+13 -10 lines)
MODIFY plugins/grade/report/visual/ visualizations/visual_grade_distribution.php   Rev. 1.2   (+25 -8 lines)
More Visualizations and a Widget http://hackerdan.com/uncategorized/more-visualizations-and-a-widget/ http://hackerdan.com/uncategorized/more-visualizations-and-a-widget/#comments Thu, 31 Jul 2008 05:03:54 +0000 Dan http://hackerdan.com/uncategorized/more-visualizations-and-a-widget/ I have finished two more visualizations based on the grade distribution. They are:

Grade Distribution by Group in a bar graph:


Grade Distribution by Item in a bar graph:


I have also added a new user interface widget witch i call a selector that looks like a legend however only one item on it can be shown at once. When a new item is selected a request is sent to the Moodle back end to get new data based on the value of the selectors item. This allows for selectors to have many diffrent functionality that a developer can program in from the visualization class on the Moodle side of things with out having to change any action script or plug-in code.

I have also change how nodes and edges are hidden when you click on a legend item. Be for the visualization would just set the visible property of the nodes and edges to false but now it will remove the nodes and edges from the data list (tree) and put them back once requested. This allows for live scaling and resizing of the axes and layout, witch makes the char much easier to read and looks much cooler when animated.

There has also been a lot of refactoring and bug fixes to the flex/action script code i made for the front end including fixing a memory leak so things should run smoother.

I should have the new code up on the test site tonight and plan on making a commit with the new code to the CVN once i do a bit more testing on it.

Rogers DNS Vulnerability http://hackerdan.com/tech/rogers-dns-vulnerability/ http://hackerdan.com/tech/rogers-dns-vulnerability/#comments Tue, 29 Jul 2008 03:43:58 +0000 Dan http://hackerdan.com/tech/rogers-dns-vulnerability/ This post is a break form development news on the Moodle stats plug-ins to talk about a new DNS vulnerability that could affect all Rogers users in Canada (or at least Ontario).

Update: euphoracle from the #CompSci.ca IRC room called up Rogers tech support and after getting threw the first few “tiers” of teach support asking him to run virus scans got to a Rogers tech that knew about the issue and claimed that they are working on the problem but there is currently no ETA. So it seems Rogers knows about the issue but has yet to fix it.

Earlier this month news of a new DNS attack was leaked to the public with details a method to poison the cache of a DNS server and allow an attacker to redirect any domain to there own ip/site.

The implications of this are massive but i will not go in to the details as that has been talked about already on many more popular blogs and in some media sources. What i do want to talk about is Rogers (one of the largest Canadian cable ISPs).

All DNS providers (including ISPs) have had since July 8th to patch and/or fix this vulnerability but from some simple testing the #compsci.ca IRC room and my self have conducted it seems that Rogers has failed to put any kind of protection in place to stop this attack (witch is ironic as they just started hijacking there own DNS server to place ads on 404 pages).

If you are a rogers user you should immediately change your DNS settings to use a secure server such as the bell ones ( and or use OpenDNS (witch has some ads on 404 pages). I would also recommend that all Rogers customers tell Rogers to patch there system ASAP.

If you want to see if your DNS server is secure check out http://www.doxpara.com/?p=1176 (thanks to Dan Kaminsky) and click on “Check my DNS” on the right hand side. This is what we used to test Rogers and other CompSci.ca users ISPs.

CVS: CONTRIB-497 + CONTRIB-496 24/July/08 http://hackerdan.com/uncategorized/cvs-contrib-497-contrib-496-24july08/ http://hackerdan.com/uncategorized/cvs-contrib-497-contrib-496-24july08/#comments Thu, 24 Jul 2008 09:24:15 +0000 Dan http://hackerdan.com/uncategorized/cvs-contrib-497-contrib-496-24july08/ I have updated the test site with the new visualization!

*Added new visualization, Grade Distribution
*Fixed some minor bugs
*Made abstract visualization class for creating visualizations by making classes witch extend it.
*Made visual_settings.php witch takes a visualization class and truns it in to XML witch flex can read in.
*Made flex visualization application read in XML formated settings as well as tab formated data from moodle and combind them to make a custom visualization.
*Made flex visualization application read and use langue strings from moodle.
*Added printer firendly tabTODO:
*Add more visualizations
*Refactor some of the flex/actionscript code
*More douctenation
*More UI functions for the flex application

MODIFY plugins/grade/report/visual/lib.php   Rev. 1.3   (+186 -59 lines)
MODIFY plugins/grade/report/visual/flare_visualization/flare_visualization.as   Rev. 1.3   (+383 -111 lines)
ADD plugins/grade/report/visual/visualizations/visualization.php   Rev. 1.1   (+0 -0 lines)
MODIFY plugins/grade/report/visual/flare_visualization.swf   Rev. 1.3   (+0 -0 lines)
MODIFY plugins/grade/report/visual/lang/en_utf8/gradereport_visual.php   Rev. 1.2   (+27 -0 lines)
MODIFY plugins/grade/report/visual/data.php   Rev. 1.2   (+5 -4 lines)
MODIFY plugins/grade/report/visual/index.php   Rev. 1.3   (+12 -3 lines)
MODIFY plugins/grade/report/visual/flare_visualization/Button.as   Rev. 1.3   (+33 -8 lines)
ADD plugins/grade/report/visual/visualizations/visual_grade_distribution.php   Rev. 1.1   (+0 -0 lines)
MODIFY plugins/grade/report/visual/flex.php   Rev. 1.3   (+23 -57 lines)
ADD plugins/grade/report/visual/visualizations/visual_grades_vs_students.php   Rev. 1.1   (+0 -0 lines)
ADD plugins/grade/report/visual/visual_settings.php   Rev. 1.1   (+0 -0 lines)
MODIFY plugins/grade/report/visual/tabs.php   Rev. 1.3   (+5 -0 lines)
DEL plugins/grade/report/visual/flare_visualization/.settings/Attic/org.eclipse.core.resources.prefs   Rev. 1.2   (+0 -0 lines)
MODIFY plugins/grade/report/visual/flare_visualization/bin-debug/flare_visualization.swf   Rev. 1.3   (+0 -0 lines)

*Fixed a minor bug in lib.php witch caused some problems geting a list of statistics used in the plug-in.

MODIFY plugins/grade/report/stats/lib.php   Rev. 1.5   (+13 -13 lines)