0

Here is what I am trying to achieve. I have two roles Teachers and Students.

Each teacher has images of answers written by the students in an exam. After checking these papers, teacher takes an image of each answer-sheet. He names it in a certain pattern using student-id. Thus, teacher has many images (like sid-1-im1.jpg, sid-1-im2.jpg, sid-2-im1.jpg). A student can have multiple images on his name depending on how many sheets he had submitted.

I want to create a website where a teacher can create a folder for this exam, say, Economics-2017-2018. Within this folder, he can upload all images. What would be the best way to achive this folder+multi-file upload?

Next I want to programmatically assign permissions to these uploaded images based on student id of the file name. So that, a student can view only his files.

How can this programmatic feature be achieved.

There are more features such as notifying students, ability to comment on files etc. But, I think drupal can handle them easily.

I intend to use Drupal 7 or 8 for the purpose.

1
  • Do you want commenting on files etc. to be at the individual file level or the student level?
    – rooby
    Sep 30, 2017 at 1:22

1 Answer 1

1

You wouldn't actually need to write any custom code to implement something like this.

A possible solution is outlined below. It is aimed at Drupal 7. Some of the functionality mentioned may not be ready for Drupal 8 so you might need alternate modules or custom code in those cases.

  1. Create a new content type, which would be named "Exam paper" or similar. There would be one node per student per exam.
  2. Add a multiple value file field to the content type. Make sure it uses the private file system. Using the private file system will mean that only users with access to the node will be able to access the files attached to the node.
  3. You can use the file field paths and token modules to make it so that the file directory structure and file names match the pattern you want. With the tokens you can easily reference student, teacher or exam information from fields on the node in the path or file name. This has no effect on access control but might make things better for you in other ways.
  4. There are a number of ways you can handle access control as there are a variety of access control modules available for nodes, however I would be inclined to go with the node access user reference module. So you would add an entity reference field on the content type that references users with the student role. You can then set permissions so that the referenced user can access the node and other users cannot.
  5. You can use the rules module to notify the user under various circumstances.
  6. You can use Drupal core comments to have comments on exam paper nodes.
  7. Due to using nodes you can leverage the wide variety of add on modules that focus primarily on nodes.
  8. If you want to store additional data with each specific file, you can install the file entity module, which will allow you to add fields at the file level as well as the node level.
2
  • Thank you rooby for the detailed answer. I have a few questions. 1. In drupal 7, when I add a File field in Exam Paper entity, it only allows txt uploads. How can I get images? 2. Maximum allowed file per node is only 10. Can this be increased? 3. I want to provide a bulk upload facility to teacher. I am thinking of scald or filedepot modules for it. So when he selects and uploads all files related to all students at once, nodes for each student should be created automatically. Will this work with what you mention in step 3?
    – Ashish
    Oct 1, 2017 at 13:09
  • @Ashish 1. There is a field setting for file fields titled 'Allowed file extensions'. It defaults to txt but you can add any number of extensions. Also, if the field is dealing exclusively with images (not pdfs etc.) you're probably better off using an Image field type, which is an extension of the file field but with some extra image specific functionality. 2. Also in the field settings, you can set the 'Number of values' to 'Unlimited'. 3. That I'm not a sure about without research. I'm sure it would be possible but I'm not sure if you would have to do some customisation to make it work.
    – rooby
    Oct 4, 2017 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.