/** Prints the code that sets the wiki page grade 
 *  evaluation box.
 *
 * @param  Object $WS       WikiStorage
 */
function wiki_grade_print_page_evaluation_box(&$WS)
{
    global $USER;
    // evaluation box available only in view tab
    if ($WS->pageaction != 'view') {
        return;
    }
    if (!wiki_grade_got_permission($WS)) {
        return;
    }
    $wiki = get_record('wiki', 'id', $WS->cm->instance);
    if (!$wiki) {
        return;
    }
    $scale = get_record('scale', 'id', (int) $wiki->notetype);
    if (isset($scale) && $scale != false) {
        print_box_start();
        $prop = null;
        $prop->id = "form_grades";
        $prop->method = "post";
        $prop->action = 'view.php?id=' . $WS->linkid . '&page=view/' . stripslashes_safe($WS->page) . '&ver=' . $WS->ver . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id;
        wiki_form_start($prop);
        $prop = null;
        $prop->class = "evaluationbox";
        wiki_div_start($prop);
        $prop = null;
        //$prop->spacing = "40";
        $prop->padding = "2";
        //$prop->valigntd = "top";
        $prop->aligntd = "right";
        //$prop->border = 1;
        wiki_table_start($prop);
        echo '<b>' . get_string('grade') . '</b>:&nbsp;';
        wiki_change_column();
        $scale = wiki_grade_scale_box($scale, true);
        $eval_instance = wiki_grade_evaluation_exist($WS->page, $WS->dfwiki->id, $WS->groupmember->groupid, $WS->member->id, $USER->id);
        if ($scale) {
            echo '&nbsp;';
            $prop = null;
            $prop->name = 'grade_post_evaluation';
            $prop->value = get_string('set', 'wiki');
            wiki_input_submit($prop);
            echo '&nbsp;';
            $context = get_context_instance(CONTEXT_MODULE, $WS->cm->id);
            if ((has_capability('mod/wiki:authorreview', $context) || has_capability('mod/wiki:mainreview', $context)) && $eval_instance != false) {
                echo '<i>(' . get_string('eval_current', 'wiki') . ' "' . trim($scale[$eval_instance->wikigrade - 1]) . '")</i>';
            }
        } else {
            echo 'grades.lib.php: there is no wikigrade yet.';
        }
        wiki_change_row();
        echo '<b>' . get_string('eval_feedback', 'wiki') . '</b>:&nbsp';
        wiki_change_column();
        unset($prop);
        $prop->size = 60;
        $prop->value = '';
        if ($eval_instance) {
            $prop->value = $eval_instance->comment;
        }
        $prop->name = "grade_commentary";
        wiki_input_text($prop);
        $prop->align = 'right';
        wiki_change_row($prop);
        wiki_change_column();
        $prop = null;
        $prop->name = 'grade_appendtodiscussion';
        wiki_input_checkbox($prop);
        $a->link = 'view.php?id=' . $WS->cm->id . '&amp;gid=' . $WS->groupmember->groupid . '&amp;uid=' . $WS->member->id . '&amp;page=discussion/discussion:' . urlencode($WS->page);
        echo get_string('eval_append_to_disc', 'wiki', $a);
        $prop->align = 'right';
        wiki_change_row($prop);
        wiki_change_column();
        $prop = null;
        $prop->name = 'grade_anonymous';
        wiki_input_checkbox($prop);
        echo get_string('eval_anonymous', 'wiki');
        wiki_table_end();
        wiki_div_end();
        wiki_form_end();
        print_box_end();
    }
}
        $opt = '';
        foreach ($users as $key => $user) {
            unset($prop);
            $prop->value = "{$key}";
            $prop->name = "{$user}";
            if ($selecteduser == $key) {
                $prop->selected = 'selected';
            }
            $opt .= wiki_option($user, $prop, true);
        }
        unset($prop);
        $prop->id = "select_users_grades";
        $prop->name = $prop->id;
        wiki_select($opt, $prop);
    }
    $scale = wiki_grade_scale_box($scale);
    if ($scale) {
        unset($prop);
        $prop->name = 'gradebook';
        $prop->value = get_string('set', 'wiki');
        wiki_input_submit($prop);
    }
    wiki_form_end();
    wiki_div_end();
    if (!$scale) {
        echo '<br/>';
        wiki_div_start();
        echo 'grades.lib.php: setting a wiki evaluation type and defining a scale is needed before value any user.';
        wiki_div_end();
    }
} else {