示例#1
0
if ($action == "delete") {
    // Getting record to delete.
    $DB->delete_records('emarking_predefined_comment', array('id' => $commentid));
    echo $OUTPUT->notification(get_string('changessaved', 'mod_emarking'), 'notifysuccess');
    $action = "list";
}
// Action on edit.
if ($action == "edit") {
    // Geting previous data, so we can reuse it.
    if (!($editingcomment = $DB->get_record('emarking_predefined_comment', array('id' => $commentid)))) {
        print_error(get_string('invalidid', 'mod_emarking'));
    }
    // Creating new form and giving the var it needs to pass.
    $editcommentform = new EditCommentForm(null, array('text' => $editingcomment->text, 'cmid' => $cm->id, 'commentid' => $commentid));
    // Condition of form cancelation.
    if ($editcommentform->is_cancelled()) {
        $action = "list";
    } else {
        if ($fromform = $editcommentform->get_data()) {
            // Setup of var record to update record in moodle DB.
            $editingcomment->text = $fromform->comment['text'];
            $editingcomment->markerid = $USER->id;
            // Updating the record.
            $DB->update_record('emarking_predefined_comment', $editingcomment);
            echo $OUTPUT->notification(get_string('changessaved', 'mod_emarking'), 'notifysuccess');
            $action = "list";
        } else {
            $editcommentform->display();
        }
    }
}
示例#2
0
if ($action == "edit") {
    echo $OUTPUT->heading(get_string('editcomment', 'mod_emarking'));
    //getting record to edit
    $comment_edition = $DB->get_record('emarking_predefined_comment', array('id' => $deleteid));
    //creating a var which contains the message to adit
    $comment_var = $comment_edition->text;
    //Creating new form and giving the var it needs to pass
    $newcommentform = new EditCommentForm(null, array('text' => $comment_var, 'id' => $cm->id, 'deleteid' => $deleteid));
    //Dislay of the form
    $newcommentform->display();
}
if ($action == "edited") {
    //Creating new form and giving the var it needs to pass
    $newcommentform = new EditCommentForm(null, array('text' => "", 'id' => $cm->id, 'deleteid' => $deleteid));
    //condition of form cancelation
    if ($newcommentform->is_cancelled()) {
        $action = "list";
    } elseif ($fromform = $newcommentform->get_data()) {
        $record = new stdClass();
        //geting previous data, so we can reuse it
        $comment_setup = $DB->get_record('emarking_predefined_comment', array('id' => $fromform->delete));
        //setup of var record to update record in moodle DB
        $record->id = $comment_setup->id;
        $record->emarkingid = $comment_setup->emarkingid;
        $record->text = $fromform->comment['text'];
        $record->markerid = $USER->id;
        //updating the record
        $DB->update_record('emarking_predefined_comment', $record);
        $action = "list";
    }
}