Rule engine coding help

I’m trying to write a workflow to check if students have passed very specific courses at any point to earn a seal. I have all the rule engines in and coded to look at the specific courses, but I’m having issues getting anything back other than a NULL when I try checking for the course and the grade. The code I’ve been trying is below.

$CourseCode$ = "8091" AND $CourseCode$ = "8092" AND $ClassGrade$ IN ("A","A-","B+","B","B-","C+","C","C-","D+","D") => "YES"

I previously had $CourseCode$ = "8062" AND $CourseCode$ = "8062" AND $ClassGrade$ IN ("A","A-","B+","B","B-","C+","C","C-","D")=> "YES" TRUE => "NO" which would give me a no at all times I believe.

The courses are all different, and each node is appending a new column, with a final column checking across the row for any “Yes”, I’m then filtering out all but that last column.

Any help would be appreciated.

It would be easier to follow if you shared your workflow and data.

Right now, it’s hard to see how $CourseCode$ = "8091" AND $CourseCode$ = "8062" can be true.
Also for integers, the quotation marks are unnecessary.

The courses are all different, and each node is appending a new column, with a final column checking across the row for any “Yes”, I’m then filtering out all but that last column.

It’s unclear to me what this means

2 Likes

It can never be true :sweat_smile:

@jdlueken84 The first AND statement is the issue here. If you were to change it to ($CourseCode$ = "8091" OR $CourseCode$ = "8092") AND... you should get a lot better results. Alternatively, you can use an IN statement here as well.

4 Likes

I will test that, in a zoom currently. Doing the ($CourseCode$ = "8091" OR $CourseCode$ = "8092") AND... or using IN, seeing as they have to have both courses with a passing grace, with either of these check that requirement?

I am not able to share the data seeing as there is sensitive information in the data set. The quotes are there because the column is coming in as a string, there are some courses that are alphanumeric.

There are 14 different course combinations that nodes are looking at, for the first line of code, it is looking if they have both of those course codes, as well as a passing grade. There is then a node looking across the row, checking if there are any “Yes” cells, giving me an overall Yes or No to earn the seal.

I posted this hastily yesterday, apologies for not being clear

Hi @jdlueken84 , from what you are saying, it sounds like you really ARE expecting the value of CourseCode to be simultaneously 8091 and 8092 which it clearly cannot be, so I think you probably need to share a sample of your data ( remove any personal details), as @elsamuel has suggested.

1 Like

Ok I’ve renamed students, changed IDs and redacted unnecessary data regarding this issue. As you can see in the file, there are different rows for each course, so I need somehow for this to check, along multiple rows if they meet the requirement of taking both classes, as well as having a passing grade for each class.

class_test_data_knime.xlsx (16.4 KB)

Hi @jdlueken84 , thanks for uploading some sample data. This will make it easier for people to help. The Rule Engine alone cannot work across multiple rows, so this is where it was not able to do what you wanted.

Right now I’m still not quite sure what form of output you are looking for, nor whether you are just dealing with two specific courses, or if your requirement is more general. Maybe you can elaborate on those aspects.

As I understand it at the moment, you are wanting to find all the students who took two particular courses, and to see if they passed both.

This to me could be broken down as
Find the set of students who took course A (Row Filter)
Find the set of students who took course B (Row Filter)
Find the intersection of those two sets (Joiner)
See if they passed both (Rule Engine)

In my example I used courses 8071 and 8072 as the course numbers you mentioned earlier don’t seem to be in the sample data.

Here is a workflow that does the above. I have also included a totally different flow which tabulates out the results for each student across the courses. I don’t know if this is also what you are trying to do, but it may be of interest anyway.

I’m sure that what I have here doesn’t fully answer your question but it might form the basis for you further stating what you are wanting (e.g if this is even close, or falls short), and further questions, and assistance from people here on the forum.

Course Tabulation.knwf (39.1 KB)

The two-course question results appear as:

The tabulated results appear as:

Maybe something here is a starting point… :wink:

3 Likes

I will look through this in more detail, thank you. The flow I’m posting here has a bit more notation about what the intent is with each of the nodes and the intent at the end of the report.

class_test_flow.knwf (44.4 KB)

Thanks for the additional workflow @jdlueken84 . I am starting to see where you are going with this but can you clarify the relationship between entityid and course code.

There will be a better way to do this than a series of rule engine nodes which aren’t suitable across multiple rows. As you have no doubt found, even if they worked that way, this solution wouldn’t scale as more and more courses get added and configuration will become a nightmare!

I’m thinking at the moment that a possible solution would be for each “rule”, there could be an aggregated list of the required set of courses, entity IDs and grades. Then for each student, the set of courses, entity IDs and grades wished could be derived and the two compared in some way to determine the achievements. I still need to think that through a bit more, but that is the direction I would currently be headed.

1 Like

Hi @jdlueken84, I took a look at your rule engines and made some assumptions about how this is supposed to work in reality.

What I have assumed is that you have a set of overall courses (which I have termed “Course Rules”) . These are the WSH-8021, WSH-8022M and so on. For each of these Course Rules, there is a set of criteria which determines if the student has attained this overall Rule based on the courses taken, and the results achieved in those courses, plus something called an “EntityId”

From the entries in your Rule Engines, I came up with the following table describing these “Course Rules”

The items shown in Red are where a course code was repeated in your rule engine, so I wasn’t sure if there was supposed to be more than one course to fulfill the rule.

So this table says that, for example, to achieve WSH-8041M, the student has to pass Courses 8041M and 8042M, have an entityid of 439 and achieve one of the grades listed (A through D) on both courses.

The attached workflow allows you to enter the above rules in a table, so they can be configured.

If my assumptions about how the rules are supposed to work is correct, then the attached workflow should give what you need, or at least be close to what you need.

The “rules” are manually entered in the Table Creator and turned into a set of “lookup tables”



becomes:


For each student, the lookup tables are joined firstly with the CourseCode to determine the possible “Course Rule” to be matched, and then using the Course Rule code, matches to required entities and required grades

There is a rule engine, but the rule engine works on row individually and simply asks the question has the requirements been met for a single course on the overall rule to be considered “passed”

Once it has collected all the individual courses taken by each student for each “course rule” it determines whether any student has passed all the courses required to satisfy a “course rule”. It then tabulates the result.

Finally it brings the tabulated columns back into the original “student course results” table and I have added back in your Column Filter and Table View for the final results

At the end you will see that I make use of one “home grown” component at the end, which is the “Selected Column Alphanumeric Resorter”.

This is used to sort the Course columns into alphabetical order without having to manually do this. The standard Column Resorter node cannot do this easily without having some prior knowledge of the column names.

It can be found here:

Course Tabulation - configurable rules.knwf (152.7 KB)

Here is the workflow. I hope it helps get towards where you are trying to go. I don’t imagine I’ve covered everything as there are things I cannot be sure about and so there are assumptions made as noted above.

4 Likes

This was, far and beyond what I had expected. There was a couple of tweaks to the Table Creator node, some classes they need both or all 3, the first 4 rows they need any one of them. I also filled in what entities they are required at. Those are our internal IDs for each school, this allowed me to exclude classes where they do not apply. We have this in a google doc, I just never thought to build a more comprehensive table like this.

image

I’ll need to add a step after this, to reference a list of students who already have earned the seal. So we don’t allocate it twice, the only downside to doing so is processing time, cleanup, and server space. It will only print once on their transcript.

If at all possible @takbb I’d like to buy you a coffee or beverage of your choice. This has been immensely helpful.

3 Likes

Hi @jdlueken84 , you are welcome and I’m pleased with the way it turned out and that it has helped. I hope you can continue to adapt it to your needs.

Thank you for the kind offer of a drink! I really appreciate that but there is no need. If you want, then maybe instead you have a local charity or cause that assists people (students perhaps?) in need, who could benefit from a small donation. But that is entirely up to you. Good luck and if you need any further help, we’ll be here on the forum. :slightly_smiling_face:

4 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.