Add Field "No completed /Completed" in course tools

stephanie

Hello,

I created a new course tool. This is a simple worksheet containing text and video. I want create a radio button on this worksheet. It would allow each user to indicate if they have realized the worksheet or not.

I try since three days but I can't do it. Can you help me ?

Thanks ! (and sorry for my poor english)

Profile picture for user James Aparicio
James Aparicio

Hi stephanie, This is a new tool you are creating, has nothing to do with the lessons correct? If for each course there is only 1 of these worksheets you are talking about, you have to start by creating a database table containing the userid, the id of the course and the timestamp. And create a getter and a setter for it. You have done this? Best regards
stephanie

Thank you very much for your answer. The course tools "Worksheet" enable just for administrators to create pages with text and video to the students. In fact, I create a course tools "Worksheet". I create a content type "Worksheet" too. I create a custom field (through a module) with an user id, the value entered by the user, and the default value created by drupal (entity_id, bundle, ...) through the hook "hook_field_schema()". I get the current user id, the value entered by the user and the others values. But I can't save this value in field's table of the database. I can't override the default behavior of Drupal. Ok to create your table but how can I display the radio button on the worksheet pages and save the value entered. Thanks again !
Profile picture for user James Aparicio
James Aparicio

Hi stephanie, the field user id cannot be on the node, because it will keep changing each time a user does something. If the user id stays in the node you can only store 1 user id per worksheet node. Since i see that there will be more than 1 worksheet per course, what you have to do is to create the table with the worksheet node id instead of the course id. On node view, you add the form with the radio button, and on form submit you update that table, and when loading the form you set the default value as "Done" if the user is found in the table. Best regards