Commit 1fc827b0 authored by Robert Lyon's avatar Robert Lyon

Bug 1621247: Allowing the substandards to be properly hierarchical

This patch:
 - removes the need to set priority value in .matrix file
   they are worked out now based on the array generated
 - changes the way you indicate parent/child relationships by adding a
   'uniqueid' to the parent and change 'parent' value for its children
   to the value of the uniqueid
 - stopped an element showing the dot on the matrix if it has children
 - added indentation for the name (1st) column on matrix page so we
   can see how things relate to each other better

behatnotneeded

Change-Id: I434c495aa58e41f9f2e55da8d6f70b9c1da37038
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 5f70a878
......@@ -339,12 +339,13 @@ class Framework {
}
}
// update standards
$standardsvars = array('shortname','name','description','priority');
$standardsvars = array('shortname','name','description');
if (isset($this->standards) && is_array($this->standards)) {
foreach ($this->standards['standards'] as $standard) {
foreach ($this->standards['standards'] as $key => $standard) {
$sfordb = new StdClass;
$sfordb->framework = $this->id;
$sfordb->mtime = db_format_timestamp(time());
$sfordb->priority = $key;
foreach ($standardsvars as $v) {
$sfordb->{$v} = isset($standard->{$v}) ? $standard->{$v} : null;
}
......@@ -360,23 +361,38 @@ class Framework {
$standard->options = $standard->standardelement;
}
if ($sid && isset($standard->options) && is_array($standard->options)) {
$prevoption = 0;
$uniqueids = array();
$priority = 0;
foreach ($standard->options as $option) {
$priority++;
$sofordb = new StdClass;
$sofordb->standard = $sid;
$sofordb->mtime = db_format_timestamp(time());
foreach ($standardsvars as $ov) {
$sofordb->{$ov} = isset($option->{$ov}) ? $option->{$ov} : null;
}
// set priority based on the order the array is passed in
$sofordb->priority = $priority;
if (!empty($option->id)) {
$sofordb->id = $option->id;
$prevoption = $option->id;
if (!empty($option->elementid)) {
$uniqueids[$option->id] = $option->elementid;
}
if (($index = array_search($option->parentelementid, $uniqueids)) !== false) {
$option->parentelementid = $index;
}
update_record('framework_standard', $sofordb, 'id');
}
else {
$sofordb->ctime = db_format_timestamp(time());
$sofordb->parent = ($option->parent && $prevoption) ? $prevoption : null;
$prevoption = insert_record('framework_standard_element', $sofordb, 'id', true);
if (isset($option->parentelementid) && ($index = array_search($option->parentelementid, $uniqueids)) !== false) {
$option->parentelementid = $index;
}
$sofordb->parent = !empty($option->parentelementid) ? $option->parentelementid : null;
$inserted = insert_record('framework_standard_element', $sofordb, 'id', true);
if (!empty($option->elementid)) {
$uniqueids[$inserted] = $option->elementid;
}
}
}
}
......@@ -407,21 +423,44 @@ class Framework {
if (!empty($result)) {
if ($options) {
// get all options relating to the standards
$sql = "SELECT id, standard, shortname, name, description, priority, parent, ctime, mtime
FROM {framework_standard_element}
$sql = "SELECT id, standard, shortname, name, description, priority, parent, ctime, mtime,
CASE WHEN fse.id > 0 THEN (
SELECT COUNT(parent) FROM {framework_standard_element}
WHERE parent = fse.id
) END AS children
FROM {framework_standard_element} fse
WHERE standard IN (" . join(',', array_map('intval', array_keys($result))) . ")
ORDER BY priority, shortname, name, ctime";
ORDER BY standard, priority, shortname, name, ctime";
$optresult = get_records_sql_assoc($sql, array());
$indents = array();
if ($optresult) {
$currentlevel = 0;
foreach ($optresult as $opt) {
if (!isset($result[$opt->standard]->options)) {
$result[$opt->standard]->options = array();
}
$result[$opt->standard]->options[] = $opt;
$opt->level = 0;
if ($opt->children) {
$indents[$opt->id] = $opt->children;
$currentlevel ++;
}
if (isset($indents[$opt->parent]) && $indents[$opt->parent] > 0) {
$opt->level = $currentlevel;
if (!empty($opt->children) && !empty($opt->parent)) {
$opt->level --;
}
$indents[$opt->parent] --;
if ($indents[$opt->parent] === 0) {
unset($indents[$opt->parent]);
$currentlevel --;
}
}
}
}
}
$standards = array(
'standards' => array_values($result),
'count' => count($result),
......
{"framework":
{"institution":"all",
"name":"Career Readiness",
"description":"NACE (National Association of Colleges and Employers) in the U.S.A. identified seven competencies associated with career readiness. Source: http://www.naceweb.org/knowledge/career-readiness-competencies.aspx",
"description":"NACE (National Association of Colleges and Employers) in the U.S.A. identified seven competencies associated with career readiness. <a href=\"http://www.naceweb.org/knowledge/career-readiness-competencies.aspx\">Source</a>",
"selfassess":false,
"evidencestatuses":
[
{"begun":"Ready for assessment"},
{"incomplete":"Doesn't meet the criterium"},
{"partialcomplete":"Partially meets the criterium"},
{"completed":"Meets the criterium"}
{"incomplete":"Doesn't meet the competency"},
{"partialcomplete":"Partially meets the competency"},
{"completed":"Meets the competency"}
],
"standards":
[
[
{
"shortname":"Career Readiness",
"name":"Career Readiness Competencies",
"description":"Career readiness is the attainment and demonstration of requisite competencies that broadly prepare college graduates for a successful transition into the workplace.",
"priority":1,
"standardelement":
[
{
"shortname":"Critical Thinking",
"name":"Critical Thinking/Problem Solving",
"description":"Exercise sound reasoning to analyze issues, make decisions, and overcome problems. The individual is able to obtain, interpret, and use knowledge, facts, and data in this process, and may demonstrate originality and inventiveness.",
"priority":1,
"parent":false
},
{
"shortname":"Communication",
"name":"Oral/Written Communications",
"description":"Articulate thoughts and ideas clearly and effectively in written and oral forms to persons inside and outside of the organization. The individual has public speaking skills; is able to express ideas to others; and can write/edit memos, letters, and complex technical reports clearly and effectively.",
"priority":2,
"parent":false
},
{
"shortname":"Teamwork",
"name":"Teamwork/Collaboration",
"description":"Build collaborative relationships with colleagues and customers representing diverse cultures, races, ages, genders, religions, lifestyles, and viewpoints. The individual is able to work within a team structure, and can negotiate and manage conflict.",
"priority":3,
"parent":false
},
{
"shortname":"Info Tech",
"name":"Information Technology Application",
"description":"Select and use appropriate technology to accomplish a given task. The individual is also able to apply computing skills to solve problems.",
"priority":4,
"parent":false
},
{
"shortname":"Leadership",
"name":"Leadership",
"description":"Leverage the strengths of others to achieve common goals, and use interpersonal skills to coach and develop others. The individual is able to assess and manage his/her emotions and those of others; use empathetic skills to guide and motivate; and organize, prioritize, and delegate work.",
"priority":5,
"parent":false
},
{
"shortname":"Professionalism",
"name":"Professionalism/Work Ethics",
"description":"Demonstrate personal accountability and effective work habits, e.g., punctuality, working productively with others, and time workload management, and understand the impact of non-verbal communication on professional work image. The individual demonstrates integrity and ethical behavior, acts responsibly with the interests of the larger community in mind, and is able to learn from his/her mistakes.",
"priority":6,
"parent":false
},
{
"shortname":"Career Management",
"name":"Career Management",
"description":"Identify and articulate one's skills, strengths, knowledge, and experiences relevant to the position desired and career goals, and identify areas necessary for professional growth. The individual is able to navigate and explore job options, understands and can take the steps necessary to pursue opportunities, and understands how to self-advocate for opportunities in the workplace.",
"priority":3,
"parent":false
}
]
}
]
}
}
"standardid":1
}
],
"standardelements":
[
{
"shortname":"Critical Thinking",
"name":"Critical Thinking/Problem Solving",
"description":"Exercise sound reasoning to analyze issues, make decisions, and overcome problems. The individual is able to obtain, interpret, and use knowledge, facts, and data in this process, and may demonstrate originality and inventiveness.",
"standardid":1,
"elementid": "1.0"
},
{
"shortname":"Communication",
"name":"Oral/Written Communications",
"description":"Articulate thoughts and ideas clearly and effectively in written and oral forms to persons inside and outside of the organization. The individual has public speaking skills; is able to express ideas to others; and can write/edit memos, letters, and complex technical reports clearly and effectively.",
"standardid":1,
"elementid": "2.0"
},
{
"shortname":"Teamwork",
"name":"Teamwork/Collaboration",
"description":"Build collaborative relationships with colleagues and customers representing diverse cultures, races, ages, genders, religions, lifestyles, and viewpoints. The individual is able to work within a team structure, and can negotiate and manage conflict.",
"standardid":1,
"elementid": "3.0"
},
{
"shortname":"Info Tech",
"name":"Information Technology Application",
"description":"Select and use appropriate technology to accomplish a given task. The individual is also able to apply computing skills to solve problems.",
"standardid":1,
"elementid": "4.0"
},
{
"shortname":"Leadership",
"name":"Leadership",
"description":"Leverage the strengths of others to achieve common goals, and use interpersonal skills to coach and develop others. The individual is able to assess and manage his/her emotions and those of others; use empathetic skills to guide and motivate; and organize, prioritize, and delegate work.",
"standardid":1,
"elementid": "5.0"
},
{
"shortname":"Professionalism",
"name":"Professionalism/Work Ethics",
"description":"Demonstrate personal accountability and effective work habits, e.g., punctuality, working productively with others, and time workload management, and understand the impact of non-verbal communication on professional work image. The individual demonstrates integrity and ethical behavior, acts responsibly with the interests of the larger community in mind, and is able to learn from his/her mistakes.",
"standardid":1,
"elementid": "6.0"
},
{
"shortname":"Career Management",
"name":"Career Management",
"description":"Identify and articulate one's skills, strengths, knowledge, and experiences relevant to the position desired and career goals, and identify areas necessary for professional growth. The individual is able to navigate and explore job options, understands and can take the steps necessary to pursue opportunities, and understands how to self-advocate for opportunities in the workplace.",
"standardid":1,
"elementid": "7.0"
}
]
}
}
......@@ -38,9 +38,9 @@
<tr class="standard">
<td colspan="{$viewcount + 2}">
<div class="shortname-container">
{$standard->name}
<h3>{$standard->name}</h3>
<div class="matrixtooltip popover hidden">
<h3 class="popover-title">{$standard->shortname}</h3>
<h3 class="popover-title">{$standard->name}</h3>
<div class="popover-content">
{$standard->description|clean_html|safe}
</div>
......@@ -50,10 +50,33 @@
</tr>
{if $standard->options}
{foreach from=$standard->options key=ok item=option}
<tr{if $option->parent} class="sub"{/if}>
{if $option->children}
<tr class="matrixlevel{$option->level}">
<td colspan="{$viewcount + 2}" class="code">
<div class="shortname-container">
{for name=foo from=0 to=$option->level step=1}
{if $dwoo.for.foo.index != $option->level}
<span class="matrixindent"></span>
{/if}
{/for} {$option->name}
<div class="matrixtooltip popover hidden">
<h3 class="popover-title">{$option->name}</h3>
<div class="popover-content">
{$option->description|clean_html|safe}
</div>
</div>
</div>
</td>
</tr>
{else}
<tr class="matrixlevel{$option->level}">
<td class="code">
<div class="shortname-container">
{$option->shortname}
{for name=foo2 from=0 to=$option->level step=1}
{if $dwoo.for.foo2.index != $option->level}
<span class="matrixindent"></span>
{/if}
{/for}{$option->shortname}
<div class="matrixtooltip popover hidden">
<h3 class="popover-title">{$option->name}</h3>
<div class="popover-content">
......@@ -74,6 +97,7 @@
</td>
{/foreach}
</tr>
{/if}
{/foreach}
{/if}
{/foreach}
......
.tablematrix {
position: relative;
tr.standard {
background: darken($table-bg-accent, 2%) !important;
tr {
&.standard {
background: darken($table-bg-accent, 2%) !important;
}
}
tr.table-pager,
......@@ -117,4 +119,8 @@
}
}
}
span.matrixindent {
display: inline-block;
width: 5px;
}
}
\ No newline at end of file
......@@ -48,7 +48,7 @@ Scenario: Installing framework module and activating for an institution
# Check that we have new framework
And I choose "SmartEvidence" in "Extensions"
Then I should see "SmartEvidence example"
Then I should see "Title of your framework"
# Activate smartevidence in an institution
And I choose "Institutions" in "Institutions"
......@@ -61,7 +61,7 @@ Scenario: Installing framework module and activating for an institution
And I follow "Return to site"
And I choose "Collections" in "Portfolio"
And I follow "Edit title and description"
And I select "SmartEvidence example" from "SmartEvidence framework"
And I select "Title of your framework" from "SmartEvidence framework"
And I press "Save"
Then I should see "Collection saved successfully."
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment