Forum OpenACS Development: CR Items question

Collapse
Posted by Jose Pablo Escobedo Del Cid on

Hi,

I want to use the content repository in the package I'm doing in e-lane (IMS-LD - https://openacs.org/forums/message-view?message%5fid=301284). I already used it before but I noticed that in the assessment package it's used differently.

The difference is this:

In evaluation(grade-book) there are theese tables:

EVALUATION_ANSWERS EVALUATION_TASKS
answer_id references cr_revisions task_id references cr_revisions
task_item_id references task_item_id <---------------> task_item_id references cr_items

so, when someone edits a task, the mapped answer continues to be mapped to the task, because it's mapped to the item_id and not to the revision_id, but in assessment it's used in a different way, for instance, with theese tables:

AS_SESSIONS AS_ASSESSMENTS
session_id references cr_revisions assessment_id references cr_revisions
assessment_id references as_assessments <---^

in this case, whenever you edit an assessment, the session has to be "re mapped" to the new revision of the new assessment, and this happens with the items of a section, etc. This "re mapping" is done every time a new revision of a new assessment (section, question, etc) is created.

I asked Timo why did he use that approach and if I did it wrong in the evaluation package, but he told me that it deppends on the application, and that he did it that way because they really wanted to make sure that one can create a new revision of an item, a section etc and use that version in the current assessment, but no other assessment using an older version of that edited item, section etc should be changed until someone really want to revert to the newer version.

Maybe it's more a design decision, but I wanted to post this question and know your opinion. Also, if I use the first approach, Would it be better if I add a tablename_item_id field in every table? (and do the references/mappings to that field, because I could use the cr_items table and avoid adding that field, but every time I would like to search for the answers of a task, for instance, instead of doing something like ... where answers.task_item_id=tasks.task_item_id, I would have to do something like ... where answers.task_id=items.item_id and items.live_revision=tasks.task_id, and the reference in the answers_table would be to the cr_items table, instead of to the evaluation_tasks one, which is not as clear as the first option, IMHO)

TIA for any comment.

Regards,

Jose Pablo

Collapse
2: Re: CR Items question (response to 1)
Posted by Dave Bauer on
In general the new object subtype should refer to cr_revisions (since its a subtype of content_revision) and does not also need an excplicit item_id column. Joins won't hurt you. You are just duplicating data which can cause consistency problems.

If you want to associate an object with an item in the content repository, it is almost always correct to use the item_id to reference the item in the CR.