Skip to content

Commit

Permalink
MDL-17361 Problems with the question category editing forms.
Browse files Browse the repository at this point in the history
When editing an existing category, the logic should have been to prevent you from moving the category if it was the last remaining top-level category in its context.

When creating a new category as part of creating a random question, there should be no restriction.
  • Loading branch information
tjhunt committed Nov 26, 2008
1 parent cc2c457 commit 1e69a65
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
6 changes: 5 additions & 1 deletion question/category_form.php
Expand Up @@ -16,11 +16,15 @@ function definition() {
$questioncategoryel = $mform->addElement('questioncategory', 'parent', get_string('parent', 'quiz'),
array('contexts'=>$contexts, 'top'=>true, 'currentcat'=>$currentcat, 'nochildrenof'=>$currentcat));
$mform->setType('parent', PARAM_SEQUENCE);
// This next test is actually looking to see if $currentcat is the id of
// a category that already exists, and is the only top-level category in
// it context. If so, we stop it from being moved.
if (1 == $DB->count_records_sql("SELECT count(*)
FROM {question_categories} c1,
{question_categories} c2
WHERE c2.id = ?
AND c1.contextid = c2.contextid", array($currentcat))){
AND c1.contextid = c2.contextid
AND c1.parent = 0 AND c2.parent = 0", array($currentcat))){
$mform->hardFreeze('parent');
}
$mform->setHelpButton('parent', array('categoryparent', get_string('parent', 'quiz'), 'question'));
Expand Down
10 changes: 0 additions & 10 deletions question/category_form_randomquestion.php
Expand Up @@ -16,16 +16,6 @@ function definition() {
$questioncategoryel = $mform->addElement('questioncategory', 'parent', get_string('parentcategory', 'quiz'),
array('contexts'=>$contexts, 'top'=>true, 'currentcat'=>$currentcat, 'nochildrenof'=>$currentcat));
$mform->setType('parent', PARAM_SEQUENCE);
if (1 == $DB->count_records_sql("SELECT count(*)
FROM {question_categories} c1,
{question_categories} c2
WHERE c2.id = ?
AND c1.contextid = c2.contextid", array($currentcat))){
//TODO: Tim? why does the above evaluate true, breaking the form?
// and more importantly, if this is a valid situation, how should we react,
// that is, what does this mean?
//$mform->hardFreeze('parent');
}
$mform->setHelpButton('parent', array('categoryparent', get_string('parent', 'quiz'), 'question'));

$mform->addElement('text','name', get_string('name'),'maxlength="254" size="50"');
Expand Down

0 comments on commit 1e69a65

Please sign in to comment.