+ // if the primary resource is defined with multiple resource type,\r
+ // the primary resource would be replaced/appended multiple times.\r
+ // This is what we want at applying alternatives by default, but\r
+ // not when only one secondary type is chosen to apply.\r
+ // This fix is to remove the duplicates on the same primary resource.\r
+ // A dilemma of this fix is, for example, if the primary resource type\r
+ // is "text" and "visual", but\r
+ // $_SESSION['prefs']['PREF_ALT_TO_TEXT_APPEND_OR_REPLACE'] == 'replace'\r
+ // $_SESSION['prefs']['PREF_ALT_TO_VISUAL_APPEND_OR_REPLACE'] == 'append'\r
+ // so, should replace happen or append happen? With this fix, whichever\r
+ // the first in the sql return gets preserved in the array and processed.\r
+ // The further improvement is requried to keep rows based on the selected\r
+ // secondary type (http://www.atutor.ca/atutor/mantis/view.php?id=4598). \r
+ if ($only_on_secondary_type > 0) {\r
+ if (in_array($row['resource'], $primary_resource_names)) {\r
+ continue;\r
+ } else {\r
+ $primary_resource_names[] = $row['resource'];\r
+ }\r
+ }\r
+ $alternative_rows[] = $row;\r