Index: openacs-4/packages/evaluation/evaluation.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/evaluation.info,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/evaluation.info 28 Apr 2004 11:06:40 -0000 1.1
@@ -0,0 +1,27 @@
+
+
+
+
+ Evaluation
+ Evaluations
+ f
+ f
+
+
+ Jose Pablo Escobedo Del Cid
+ This package allows the users (professors and students) to use the system to submit and grade the tasks.
+ This package allows the professors and TAs to assign tasks to the students and to grade them, and to the students to upload their answers and see their grades.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: openacs-4/packages/evaluation/lib/audit-chunk-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/lib/audit-chunk-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/lib/audit-chunk-postgresql.xql 28 Apr 2004 11:06:40 -0000 1.1
@@ -0,0 +1,23 @@
+
+
+
+ postgresql 7.4
+
+
+
+
+ select to_char(ese.last_modified, 'MM-DD-YYYY HH24:MI:SS') as last_modified,
+ ese.modifying_user,
+ ese.modifying_ip,
+ ese.description as comments,
+ ese.grade as task_grade,
+ content_revision__is_live(evaluation_id) as is_live
+ from evaluation_student_evalsx ese
+ where ese.task_id = :task_id
+ and ese.party_id = :party_id
+ order by evaluation__party_name(party_id,task_id), ese.evaluation_id desc
+
+
+
+
+
Index: openacs-4/packages/evaluation/lib/audit-chunk.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/lib/audit-chunk.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/lib/audit-chunk.adp 28 Apr 2004 11:06:40 -0000 1.1
@@ -0,0 +1,4 @@
+
+
+
+
Index: openacs-4/packages/evaluation/lib/audit-chunk.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/lib/audit-chunk.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/lib/audit-chunk.tcl 28 Apr 2004 11:06:40 -0000 1.1
@@ -0,0 +1,45 @@
+ad_page_contract {
+
+ Audit chunk for displaying audit info
+
+}
+
+set user_id [ad_conn user_id]
+
+template::list::create \
+ -name grade_tasks \
+ -multirow grade_tasks \
+ -key task_name \
+ -pass_properties { return_url } \
+ -elements {
+ task_grade {
+ label "Name"
+ orderby_asc {task_grade asc}
+ orderby_desc {task_grade desc}
+ }
+ last_modified {
+ label "Last Modified"
+ orderby_asc {last_modified asc}
+ orderby_desc {last_modified desc}
+ }
+ modifying_user {
+ label "Modifying User"
+ orderby_asc {modifying_user asc}
+ orderby_desc {modifying_user desc}
+ }
+ comments {
+ label "Comments"
+ orderby_asc {comments asc}
+ orderby_desc {comments desc}
+ }
+ is_live {
+ label "Is live?"
+ orderby_asc {comments asc}
+ orderby_desc {comments desc}
+ }
+ }
+
+
+db_multirow grade_tasks get_task_audit_info { *SQL* } {
+}
+
Index: openacs-4/packages/evaluation/lib/confirm-delete-form.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/lib/confirm-delete-form.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/lib/confirm-delete-form.adp 28 Apr 2004 11:06:40 -0000 1.1
@@ -0,0 +1,16 @@
+
Index: openacs-4/packages/evaluation/lib/evaluations-chunk-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/lib/Attic/evaluations-chunk-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/lib/evaluations-chunk-postgresql.xql 28 Apr 2004 11:06:40 -0000 1.1
@@ -0,0 +1,55 @@
+
+
+
+ postgresql 7.4
+
+
+
+
+ select et.task_name, et.weight as task_weight,
+ et.task_id
+ from evaluation_tasksi et
+ where grade_id = :grade_id
+ and content_revision__is_live(et.task_id) = true
+ $orderby
+
+
+
+
+
+
+
+ select et.task_name,
+ ese.grade,
+ ese.description as comments,
+ (et.weight*eg.weight)/100 as task_weight,
+ (ese.grade*et.weight*eg.weight)/10000 as task_grade,
+ et.number_of_members,
+ et.task_id,
+ ea.data as answer_data,
+ ea.title as answer_title,
+ ea.answer_id
+ from evaluation_grades eg,
+ evaluation_tasks et2 left outer join evaluation_student_evalsi ese on (ese.task_id = et2.task_id and content_revision__is_live(ese.evaluation_id) = true
+ and ese.party_id = evaluation__party_id(:user_id,et2.task_id)),
+ evaluation_tasks et left outer join evaluation_answersi ea on (ea.task_id = et.task_id and content_revision__is_live(ea.answer_id) = true
+ and ea.party_id = evaluation__party_id(:user_id,et.task_id))
+ where eg.grade_id = :grade_id
+ and eg.grade_id = et.grade_id
+ and et.task_id = et2.task_id
+ and content_revision__is_live(et.task_id) = true
+ and content_revision__is_live(eg.grade_id) = true
+ $orderby
+
+
+
+
+
+
+
+ select evaluation__party_id(:user_id,:task_id)
+
+
+
+
+
Index: openacs-4/packages/evaluation/lib/evaluations-chunk.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/lib/evaluations-chunk.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/lib/evaluations-chunk.adp 28 Apr 2004 11:06:40 -0000 1.1
@@ -0,0 +1,4 @@
+
+
+ @bottom_line;noquote@
+
Index: openacs-4/packages/evaluation/lib/evaluations-chunk.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/lib/evaluations-chunk.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/lib/evaluations-chunk.tcl 28 Apr 2004 11:06:40 -0000 1.1
@@ -0,0 +1,120 @@
+ad_page_contract {
+
+ evaluations chunk to be displayed in the index page
+
+}
+
+set package_id [ad_conn package_id]
+set user_id [ad_verify_and_get_user_id]
+set admin_p [permission::permission_p -party_id $user_id -object_id $package_id -privilege admin]
+#set admin_p 1
+
+set base_url [ad_conn package_url]
+
+db_1row get_grade_info { *SQL* }
+
+set elements [list task_name \
+ [list label "Name" \
+ link_url_col task_url \
+ orderby_asc {task_name asc} \
+ orderby_desc {task_name desc}] \
+ ]
+if { $admin_p } {
+ #admin
+ lappend elements task_weight \
+ [list label "Weight" \
+ display_template { @grade_tasks_admin.task_weight@% } \
+ orderby_asc {task_weight asc} \
+ orderby_desc {task_weight desc}]
+ set multirow_name grade_tasks_admin
+ set actions [list "Edit grades distribution of $grade_name" [export_vars -base "${base_url}admin/grades/distribution-edit" { grade_id }]]
+} else {
+ #student
+ lappend elements grade \
+ [list label "Grade over 100" \
+ display_template { @grade_tasks.grade@ } \
+ orderby_asc {grade asc} \
+ orderby_desc {grade desc}]
+ lappend elements comments \
+ [list label "Comments" \
+ link_url_col comments_url \
+ link_html { title "View evaluation comments" }]
+ lappend elements task_weight \
+ [list label "Weight over 100% of class grade" \
+ display_template { @grade_tasks.task_weight@% } \
+ orderby_asc {task_weight asc} \
+ orderby_desc {task_weight desc}]
+ lappend elements answer \
+ [list label "" \
+ link_url_col answer_url \
+ link_html { title "View my answer" }]
+ set multirow_name grade_tasks
+ set actions ""
+}
+
+set total_grade 0.00
+set max_grade 0.00
+
+template::list::create \
+ -name grade_tasks \
+ -multirow $multirow_name \
+ -actions $actions \
+ -key task_id \
+ -pass_properties { return_url mode base_url } \
+ -filters { grade_id } \
+ -elements $elements
+
+
+set orderby [template::list::orderby_clause -orderby -name grade_tasks]
+
+if { [string equal $orderby ""] } {
+ set orderby " order by task_name asc"
+}
+
+db_multirow -extend { task_url } grade_tasks_admin get_tasks_admin { *SQL* } {
+ set task_url [export_vars -base "${base_url}admin/evaluations/student-list" { task_id grade_id }]
+}
+
+db_multirow -extend { comments comments_url answer answer_url } grade_tasks get_grade_tasks { *SQL* } {
+ if { ![empty_string_p $comments] } {
+ set comments "View comments"
+ set comments_url evaluation_view
+ }
+
+ if { ![empty_string_p $grade] } {
+ set grade [format %.2f $grade]
+ set total_grade [expr $total_grade + $task_grade]
+ } else {
+ set grade "Not evaluated"
+ }
+
+ set task_weight [format %.2f $task_weight]
+ set max_grade [expr $task_weight + $max_grade]
+
+ # working with answer stuff (if it has a file/url attached)
+ if { [empty_string_p $answer_data] } {
+ set answer_url ""
+ set answer ""
+ } elseif { [regexp "http://" $answer_data] } {
+ set answer_url "[export_vars -base "$answer_data" { }]"
+ set answer "View my answer"
+ } else {
+ # we assume it's a file
+ set answer_url "[export_vars -base "${base_url}view/$answer_title" { }]"
+ set answer "View my answer"
+ }
+
+ if { $number_of_members > 1 && [string eq [db_string get_group_id { *SQL* }] 0] } {
+ set answer ""
+ set answer_url ""
+ set grade "No group for task"
+ }
+
+}
+
+if { $admin_p } {
+ set bottom_line "$grade_name represents $grade_weight % of the 100% of the class"
+} else {
+ set bottom_line "Total points in this category: $total_grade / $max_grade
+ This grade category represents the $grade_weight% of the 100% of the class"
+}
Index: openacs-4/packages/evaluation/lib/evaluations-chunk.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/lib/evaluations-chunk.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/lib/evaluations-chunk.xql 28 Apr 2004 11:06:40 -0000 1.1
@@ -0,0 +1,14 @@
+
+
+
+ postgresql 7.4
+
+
+
+
+ select grade_name, weight as grade_weight from evaluation_grades where grade_id = :grade_id
+
+
+
+
+
Index: openacs-4/packages/evaluation/lib/grades-chunk.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/lib/Attic/grades-chunk.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/lib/grades-chunk.adp 28 Apr 2004 11:06:40 -0000 1.1
@@ -0,0 +1 @@
+jk
Index: openacs-4/packages/evaluation/lib/grades-chunk.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/lib/Attic/grades-chunk.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/lib/grades-chunk.tcl 28 Apr 2004 11:06:40 -0000 1.1
@@ -0,0 +1,5 @@
+ad_page_contract {
+
+
+
+}
Index: openacs-4/packages/evaluation/lib/tasks-chunk-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/lib/Attic/tasks-chunk-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/lib/tasks-chunk-postgresql.xql 28 Apr 2004 11:06:40 -0000 1.1
@@ -0,0 +1,66 @@
+
+
+
+ postgresql 7.4
+
+
+
+
+ select et.task_name, et.number_of_members, et.task_id,
+ to_char(et.due_date,'Month DD YYYY') as pretty_due_date, et.online_p, et.late_submit_p, et.item_id,
+ et.requires_grade_p, et.description, et.grade_id,
+ cr.content_length,
+ et.data as task_data,
+ et.title as task_title,
+ et.task_id as revision_id,
+ ets.solution_id as solution_id
+ from cr_revisions cr,
+ evaluation_tasksi et left outer join evaluation_tasks_solsi ets on (ets.task_id = et.task_id and content_revision__is_live(ets.solution_id) = true)
+ where cr.revision_id = et.revision_id
+ and grade_id = :grade_id
+ and content_revision__is_live(et.task_id) = true
+ $orderby
+
+
+
+
+
+
+
+ select et.task_name, et.number_of_members, et.task_id,
+ to_char(et.due_date,'Month DD YYYY') as pretty_due_date, et.online_p, et.late_submit_p, et.item_id,
+ et.due_date,
+ et.requires_grade_p, et.description, et.grade_id,
+ et.title as task_title,
+ et.data as task_data,
+ et.task_id as revision_id,
+ cr.content_length,
+ ea.answer_id as answer_id
+ from cr_revisions cr,
+ evaluation_tasksi et left outer join evaluation_answersi ea on (ea.task_id = et.task_id and content_revision__is_live(ea.answer_id) = true
+ and ea.party_id = evaluation__party_id(:user_id,et.task_id))
+ where cr.revision_id = et.revision_id
+ and grade_id = :grade_id
+ and content_revision__is_live(et.task_id) = true
+ $orderby
+
+
+
+
+
+
+
+ select evaluation__party_id(:user_id,:task_id)
+
+
+
+
+
+
+
+ select grade_name from evaluation_grades where grade_id = :grade_id
+
+
+
+
+
Index: openacs-4/packages/evaluation/lib/tasks-chunk.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/lib/tasks-chunk.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/lib/tasks-chunk.adp 28 Apr 2004 11:06:40 -0000 1.1
@@ -0,0 +1,3 @@
+
+
+
Index: openacs-4/packages/evaluation/lib/tasks-chunk.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/lib/tasks-chunk.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/lib/tasks-chunk.tcl 28 Apr 2004 11:06:40 -0000 1.1
@@ -0,0 +1,175 @@
+ad_page_contract {
+
+ task chunk to be displayed in the index page
+
+}
+
+set package_id [ad_conn package_id]
+set user_id [ad_verify_and_get_user_id]
+set admin_p [permission::permission_p -party_id $user_id -object_id $package_id -privilege admin]
+# set admin_p 1
+
+set grade_name [db_string grade_name { *SQL* }]
+set base_url [ad_conn package_url]
+
+set mode display
+set return_url "[ad_conn url]?[export_vars { grade_id }]"
+
+set elements [list task_name \
+ [list label "Name" \
+ link_url_col task_url \
+ orderby_asc {task_name asc} \
+ orderby_desc {task_name desc}] \
+ pretty_due_date \
+ [list label "Due date" \
+ orderby_asc {pretty_due_date asc} \
+ orderby_desc {pretty_due_date desc}] \
+ ]
+
+if { $admin_p } {
+ #admin
+ lappend elements solution \
+ [list label "" \
+ link_url_col solution_url \
+ link_html { title "Add/edit solution" }]
+ lappend elements audit_info \
+ [list label "" \
+ link_url_col audit_info_url \
+ link_html { title "Audit info" }]
+ lappend elements groups_admin \
+ [list label "" \
+ link_url_col groups_admin_url \
+ link_html { title "Groups administration" }]
+ lappend elements view \
+ [list label "" \
+ sub_class narrow \
+ display_template { } \
+ link_url_eval {[export_vars -base "${base_url}admin/tasks/task-add-edit" { grade_id task_id return_url mode }]} \
+ link_html { title "View task" }]
+ lappend elements edit \
+ [list label "" \
+ sub_class narrow \
+ display_template { } \
+ link_url_eval {[export_vars -base "${base_url}admin/tasks/task-add-edit" { return_url item_id grade_id task_id }]} \
+ link_html { title "Edit task" }]
+ lappend elements delete \
+ [list label "" \
+ sub_class narrow \
+ display_template { } \
+ link_url_eval {[export_vars -base "${base_url}admin/tasks/task-delete" { grade_id task_id return_url }]} \
+ link_html { title "Delete task" }]
+
+ set multirow_name tasks_admin
+ set actions [list "Add $grade_name" [export_vars -base "${base_url}admin/tasks/task-add-edit" { return_url grade_id }] ]
+} else {
+ #student
+ lappend elements answer \
+ [list label "" \
+ link_url_col answer_url \
+ link_html { title "Add/edit answer" }]
+ lappend elements view \
+ [list label "" \
+ sub_class narrow \
+ display_template { } \
+ link_url_eval {[export_vars -base "${base_url}task-view" { grade_id task_id return_url }]} \
+ link_html { title "View task" }]
+ set multirow_name tasks
+ set actions ""
+}
+
+template::list::create \
+ -name tasks \
+ -multirow $multirow_name \
+ -actions $actions \
+ -key task_id \
+ -pass_properties { return_url mode base_url } \
+ -filters { grade_id {} } \
+ -elements $elements
+
+
+set orderby [template::list::orderby_clause -orderby -name tasks]
+
+if {[string equal $orderby ""]} {
+ set orderby " order by task_name asc"
+}
+
+db_multirow -extend { solution_url solution solution_mode task_url audit_info audit_info_url groups_admin groups_admin_url } tasks_admin get_tasks_admin { *SQL* } {
+ # working with task stuff (if it has a file/url attached)
+ if { [empty_string_p $task_data] } {
+ set task_url "[export_vars -base "${base_url}task-view" { grade_id task_id return_url }]"
+ set task_name "$task_name (No data)"
+ } elseif { [regexp "http://" $task_data] } {
+ set task_url "[export_vars -base "$task_data" { }]"
+ set task_name "$task_name (URL)"
+ } else {
+ # we assume it's a file
+ set task_url "[export_vars -base "${base_url}view/$task_title" { revision_id }]"
+ set task_name "$task_name ([format %.0f [expr ($content_length/1024)]] Kb)"
+ }
+
+ if { ![empty_string_p $solution_id] } {
+ set solution_mode display
+ set solution_url "[export_vars -base "${base_url}admin/tasks/solution-add-edit" { grade_id task_id solution_id return_url solution_mode }]"
+ set solution "View/Edit Solution"
+ } else {
+ set solution_mode edit
+ set solution_url "[export_vars -base "${base_url}admin/tasks/solution-add-edit" { grade_id task_id return_url solution_mode }]"
+ set solution "Upload Solution"
+ }
+
+ set audit_info_url "[export_vars -base "${base_url}admin/evaluations/audit-info" { grade_id task_id }]"
+ set audit_info "Audit Info."
+
+ if { ![string eq $number_of_members 1] } {
+ set groups_admin_url "[export_vars -base "${base_url}admin/groups/one-task" { grade_id task_id }]"
+ set groups_admin "Groups Admin."
+ }
+
+}
+
+db_multirow -extend { task_url solution_url solution solution_mode answer answer_url } tasks get_tasks { *SQL* } {
+ set answer_mode display
+
+ # working with task stuff (if it has a file/url attached)
+ if { [empty_string_p $task_data] } {
+ set task_url "[export_vars -base "${base_url}task-view" { grade_id task_id return_url }]"
+ set task_name "$task_name (No data)"
+ } elseif { [regexp "http://" $task_data] } {
+ set task_url "[export_vars -base "$task_data" { }]"
+ set task_name "$task_name (URL)"
+ } else {
+ # we assume it's a file
+ set task_url "[export_vars -base "${base_url}view/$task_title" { revision_id }]"
+ set task_name "$task_name ([format %.0f [expr ($content_length/1024)]] Kb)"
+ }
+
+ if { [string eq $online_p "t"] } {
+ if { ([template::util::date::compare $due_date [template::util::date::now]] > 0) } {
+ if { [empty_string_p $answer_id] } {
+ set answer "turn in"
+ set answer_mode edit
+ set answer_url "[export_vars -base "${base_url}answer-add-edit" { grade_id task_id return_url answer_mode }]"
+ } else {
+ set answer "turn in again"
+ set answer_mode display
+ set answer_url "[export_vars -base "${base_url}answer-add-edit" { grade_id task_id answer_id return_url answer_mode }]"
+ }
+ } elseif { [string eq $turn_in_late_p "t"] } {
+ if { [empty_string_p $answer_id] } {
+ set answer "turn in "
+ set answer_mode edit
+ set answer_url "[export_vars -base "${base_url}answer-add-edit" { grade_id task_id return_url answer_mode }]"
+ } else {
+ set answer "turn in again"
+ set answer_mode display
+ set answer_url "[export_vars -base "${base_url}admin/tasks/solution-add-edit" { grade_id task_id answer_id return_url solution_mode }]"
+ }
+ }
+ if { $number_of_members > 1 && [string eq [db_string get_group_id { *SQL* }] 0] } {
+ set answer ""
+ set answer_url ""
+ }
+ }
+
+}
+
Index: openacs-4/packages/evaluation/sql/postgresql/evaluation-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/sql/postgresql/evaluation-create.sql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/sql/postgresql/evaluation-create.sql 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,1168 @@
+-- jopez@galileo.edu
+
+create table evaluation_grades (
+ grade_id integer
+ constraint evaluation_grades_id_pk
+ primary key
+ constraint evaluation_grades_id_fk
+ references cr_revisions(revision_id),
+ grade_name varchar(100),
+ class_id integer
+ constraint evaluation_grades_cid_nn
+ not null
+ constraint evaluation_grades_cid_fk
+ references groups,
+ comments text,
+ -- percentage of this grade type in the class
+ weight numeric
+ constraint evaluation_grades_w_ck
+ check (weight between 0 and 100)
+);
+
+create index evalutaion_grades_cid_index on evaluation_grades(class_id);
+
+select content_type__create_type (
+ 'evaluation_grades', -- content_type
+ 'content_revision', -- super_type
+ 'Evaluation Grade', -- pretty_name
+ 'Evaluation Grades', -- pretty_plural
+ 'evaluation_grades', -- table_name
+ 'grade_id', -- id_column
+ null -- name_method
+);
+
+create table evaluation_tasks (
+ task_id integer
+ constraint evaluation_tasks_pk
+ primary key
+ constraint evaluation_tasks_fk
+ references cr_revisions(revision_id),
+ task_name varchar
+ constraint evaluation_tasks_tn_nn
+ not null,
+ -- we need to know if the task is in groups or not
+ number_of_members integer
+ constraint evaluation_tasks_nom_nn
+ not null
+ constraint evaluation_tasks_nom_df
+ default 1,
+ due_date timestamp,
+ grade_id integer
+ constraint evaluation_tasks_gid_fk
+ references evaluation_grades,
+ -- percentage of the grade of the course
+ weight integer,
+ -- the task will be submitted on line
+ online_p char(1)
+ constraint evaluation_tasks_onp_ck
+ check(online_p in ('t','f')),
+ -- will the students be able to submit late their answers?
+ late_submit_p char(1)
+ constraint evaluations_tasks_lsp_ck
+ check(late_submit_p in ('t','f')),
+ requires_grade_p char(1)
+ constraint evaluations_tasks_rgp_ck
+ check(late_submit_p in ('t','f'))
+);
+
+create index evalutaion_tasks_gid_index on evaluation_tasks(grade_id);
+
+select content_type__create_type (
+ 'evaluation_tasks', -- content_type
+ 'content_revision', -- super_type
+ 'Evaluation Task', -- pretty_name
+ 'Evaluation Tasks', -- pretty_plural
+ 'evaluation_tasks', -- table_name
+ 'task_id', -- id_column
+ null -- name_method
+);
+
+
+-- We need a way to group tasks because there may be the case when a professor/TA
+-- would want to assign a task to more than one class, and the task must be
+-- associated with the tasks of the other classes.
+
+
+create table evaluation_tasks_class_map (
+ class_id integer
+ constraint evaluations_tasks_cmap_cid_fk
+ references groups,
+ revision_id integer
+ constraint evaluations_tasks_cmap_fid_fk
+ references cr_revisions,
+ constraint evaluaition_tasks_cmap_pk
+ primary key (class_id, revision_id)
+);
+
+
+create table evaluation_tasks_sols (
+ solution_id integer
+ primary key,
+ task_id integer
+ constraint evaluation_tsols_tid_fk
+ references evaluation_tasks
+);
+
+-- crear indice para cada cosa que sea referenciada por otras tablas
+create index evalutaion_tasks_sols_tid_index on evaluation_tasks_sols(task_id);
+
+select content_type__create_type (
+ 'evaluation_tasks_sols', -- content_type
+ 'content_revision', -- super_type
+ 'Evaluation Task Solution', -- pretty_name
+ 'Evaluation Tasks Solutions', -- pretty_plural
+ 'evaluation_tasks_sols', -- table_name
+ 'solution_id', -- id_column
+ null -- name_method
+);
+
+create table evaluation_answers (
+ answer_id integer
+ primary key
+ references cr_revisions,
+ -- person/group to wich the answer belongs
+ party_id integer
+ constraint evaluation_sans_pid_nn
+ not null
+ constraint evaluation_sans_pid_fk
+ references parties(party_id),
+ task_id integer
+ constraint evaluation_sans_tid_fk
+ references evaluation_tasks
+);
+
+-- cada vez que se crea una constraint como unique compuestos, se crea un indice para cada cosa que va en el unique y si por ejemplo el indice es (a,b,c) se puede usar ese index para a, ab, abc, pero no para b ni c ni bc.
+create index evaluation_answers_tid_index on evaluation_answers(party_id,task_id);
+
+select content_type__create_type (
+ 'evaluation_answers', -- content_type
+ 'content_revision', -- super_type
+ 'Student Answer', -- pretty_name
+ 'Student Answers', -- pretty_plural
+ 'evaluation_answers', -- table_name
+ 'answer_id', -- id_column
+ null -- name_method
+);
+
+
+create table evaluation_student_evals (
+ evaluation_id integer
+ constraint evaluation_stu_evals_pk
+ primary key
+ constraint evaluation_stu_evals_fk
+ references acs_objects(object_id),
+ task_id integer
+ constraint evaluation_stu_evals_tid_nn
+ not null
+ constraint evaluation_stu_evals_tid_fk
+ references evaluation_tasks,
+ -- must have student_id or team_id
+ party_id integer
+ constraint evaluation_stu_evals_pid_nn
+ not null
+ constraint evaluation_stu_evals_pid_fk
+ references parties(party_id),
+ grade numeric,
+ show_student_p char(1)
+ constraint evaluation_stu_evals_ssp_df
+ default 't'
+ constraint evaluation_stu_evals_ssp_ck
+ check (show_student_p in ('t','f'))
+);
+
+create index evaluation_student_evals_tid_index on evaluation_student_evals(task_id);
+create index evaluation_student_evals_pid_index on evaluation_student_evals(party_id);
+
+select content_type__create_type (
+ 'evaluation_student_evals', -- content_type
+ 'content_revision', -- super_type
+ 'Student Evaluation', -- pretty_name
+ 'Student Evaluations', -- pretty_plural
+ 'evaluation_student_evals', -- table_name
+ 'evaluation_id', -- id_column
+ null -- name_method
+);
+
+-- creating group_type and the table where we are going to store the information about evaluation groups for tasks in groups
+
+create table evaluation_task_groups (
+ group_id integer
+ constraint evaluation_task_groups_pk
+ primary key
+ constraint evaluation_task_groups_fk
+ references groups(group_id),
+ task_id integer
+ constraint evaluation_task_groups_tid_nn
+ not null
+ constraint evaluation_task_groups_tid_fk
+ references evaluation_tasks(task_id)
+);
+
+create index evaluation_task_groups_tid_index on evaluation_task_groups(task_id);
+
+select acs_object_type__create_type (
+ 'evaluation_task_groups', --object type
+ 'Task Group', --pretty name
+ 'Tasks Groups', --pretty prural
+ 'acs_object', --supertype
+ 'evaluation_task_groups', --table_name
+ 'group_id', --id_column
+ null, --package_name
+ 'f', --abstract_p
+ null, --type_extension_table
+ null --name_method
+);
+
+insert into group_types (group_type) values ('evaluation_task_groups');
+
+insert into acs_object_type_tables
+ (object_type, table_name, id_column)
+ values
+ ('evaluation_task_groups', 'evaluation_task_groups', 'group_id');
+
+select acs_attribute__create_attribute (
+ 'evaluation_task_groups', --object_type
+ 'task_id', --oattribute_name
+ 'integer', --datatype
+ 'Task id', --pretty_name
+ 'Task ids', --pretty_plural
+ 'evaluation_task_groups', --table_name
+ 'task_id', --column_name
+ null, --default_value
+ 1, --min_n_values
+ 1, --max_n_values
+ null, --sort_order
+ 'type_specific', --storage
+ 'f' --static_p
+);
+
+create function evaluation__new_item (integer,varchar,varchar,integer,integer,varchar,varchar,text,varchar,varchar,text,varchar,varchar,varchar)
+returns integer as '
+declare
+ p_item_id alias for $1;
+ p_name alias for $2;
+ p_locale alias for $3;
+ p_creation_user alias for $4;
+ p_package_id alias for $5;
+ p_creation_ip alias for $6;
+ p_title alias for $7;
+ p_description alias for $8;
+ p_mime_type alias for $9;
+ p_nls_language alias for $10;
+ p_text alias for $11;
+ p_storage_type alias for $12;
+ p_item_subtype alias for $13;
+ p_content_type alias for $14;
+
+ v_item_id integer;
+ v_parent_id integer;
+ v_id integer;
+begin
+
+ select content_item__get_id(p_content_type||''_''||p_package_id,null,''f'')
+ into v_parent_id
+ from dual;
+ --
+ -- this will be used for 2xClick protection
+ if p_item_id is null then
+ select acs_object_id_seq.nextval
+ into v_id
+ from dual;
+ else
+ v_id := p_item_id;
+ end if;
+
+ v_item_id := content_item__new(
+ p_name, -- name
+ v_parent_id, -- parent_id
+ v_id, -- item_id
+ p_locale, -- locale
+ current_timestamp, -- creation_date
+ p_creation_user, -- creation_user
+ p_package_id, -- context_id
+ p_creation_ip, -- creation_ip
+ p_item_subtype, -- item_subtype
+ p_content_type, -- content_type
+ p_title, -- title
+ p_description, -- description
+ p_mime_type, -- mime_type
+ p_nls_language, -- nls_language
+ p_text, -- text
+ p_storage_type -- storage_type
+ );
+
+ return v_item_id;
+end;
+' language 'plpgsql';
+
+---------------------------------------
+-- GRADES
+---------------------------------------
+
+create function evaluation__new_grade (integer, integer, varchar, integer, numeric, varchar, timestamptz, integer, varchar, varchar, varchar, timestamptz, varchar, varchar)
+returns integer as '
+declare
+ p_item_id alias for $1;
+ p_revision_id alias for $2;
+ p_grade_name alias for $3;
+ p_class_id alias for $4;
+ p_weight alias for $5;
+ p_object_type alias for $6;
+ p_creation_date alias for $7;
+ p_creation_user alias for $8;
+ p_creation_ip alias for $9;
+ p_title alias for $10; -- default null
+ p_description alias for $11; -- default null
+ p_publish_date alias for $12;
+ p_nls_language alias for $13; -- default null
+ p_mime_type alias for $14; -- default null
+
+ v_revision_id integer;
+
+begin
+
+ v_revision_id := content_revision__new(
+ p_title, -- title
+ p_description, -- description
+ p_publish_date, -- publish_date
+ p_mime_type, -- mime_type
+ p_nls_language, -- nls_language
+ null, -- data
+ p_item_id, -- item_id
+ p_revision_id, -- revision_id
+ current_timestamp, -- creation_date
+ p_creation_user, -- creation_user
+ p_creation_ip, -- creation_ip
+ null -- content length
+ );
+
+ insert into evaluation_grades
+ (grade_id,
+ grade_name,
+ class_id,
+ comments,
+ weight)
+ values
+ (v_revision_id,
+ p_grade_name,
+ p_class_id,
+ p_description,
+ p_weight);
+
+ return v_revision_id;
+end;
+' language 'plpgsql';
+
+create function evaluation__delete_grade (integer)
+returns integer as '
+declare
+ p_grade_id alias for $1;
+ del_rec record;
+begin
+
+ FOR del_rec IN
+ select task_id
+ from evaluation_tasks
+ where grade_id = p_grade_id
+ LOOP
+ delete from evaluation_student_evals where task_id = del_rec.task_id;
+ delete from evaluation_answers where task_id = del_rec.task_id;
+ delete from evaluation_tasks_sols where task_id = del_rec.task_id;
+ END LOOP;
+
+ delete from evaluation_tasks where grade_id = p_grade_id;
+ delete from evaluation_grades where grade_id = p_grade_id;
+
+ PERFORM content_revision__delete(p_grade_id);
+
+ return 0;
+
+end;' language 'plpgsql';
+
+create function grade__name(integer)
+returns varchar as '
+declare
+ p_grade_id alias for $1;
+ v_grade_name evaluation_grades.grade_name%TYPE;
+begin
+ select grade_name into v_grade_name
+ from evaluation_grades
+ where grade_id = p_grade_id;
+
+ return v_grade_name;
+end;
+' language 'plpgsql';
+
+---------------------------------------
+-- TASKS
+---------------------------------------
+
+create function evaluation__new_task (integer, integer, varchar, integer, integer, varchar, numeric, timestamptz, char, char, char, varchar, timestamptz, integer, varchar, varchar, timestamptz, varchar, varchar)
+returns integer as '
+declare
+ p_item_id alias for $1;
+ p_revision_id alias for $2;
+ p_task_name alias for $3;
+ p_number_of_members alias for $4;
+ p_grade_id alias for $5;
+ p_description alias for $6;
+ p_weight alias for $7;
+ p_due_date alias for $8;
+ p_late_submit_p alias for $9;
+ p_online_p alias for $10;
+ p_requires_grade_p alias for $11;
+ p_object_type alias for $12;
+ p_creation_date alias for $13;
+ p_creation_user alias for $14;
+ p_creation_ip alias for $15;
+ p_title alias for $16; -- default null
+ p_publish_date alias for $17;
+ p_nls_language alias for $18; -- default null
+ p_mime_type alias for $19; -- default null
+
+ v_revision_id integer;
+
+begin
+
+ v_revision_id := content_revision__new(
+ p_title, -- title
+ p_description, -- description
+ p_publish_date, -- publish_date
+ p_mime_type, -- mime_type
+ p_nls_language, -- nls_language
+ null, -- data
+ p_item_id, -- item_id
+ p_revision_id, -- revision_id
+ current_timestamp, -- creation_date
+ p_creation_user, -- creation_user
+ p_creation_ip, -- creation_ip
+ null -- content length
+ );
+
+ insert into evaluation_tasks
+ (task_id,
+ task_name,
+ number_of_members,
+ due_date,
+ grade_id,
+ weight,
+ online_p,
+ late_submit_p,
+ requires_grade_p)
+ values
+ (v_revision_id,
+ p_task_name,
+ p_number_of_members,
+ p_due_date,
+ p_grade_id,
+ p_weight,
+ p_online_p,
+ p_late_submit_p,
+ p_requires_grade_p);
+
+ return v_revision_id;
+end;
+' language 'plpgsql';
+
+create function evaluation__delete_task (integer)
+returns integer as '
+declare
+ p_task_id alias for $1;
+ del_rec record;
+begin
+
+ delete from evaluation_student_evals where task_id = p_task_id;
+ delete from evaluation_answers where task_id = p_task_id;
+ delete from evaluation_tasks_sols where task_id = p_task_id;
+ delete from evaluation_tasks where task_id = p_task_id;
+
+ PERFORM content_revision__delete(p_task_id);
+
+ return 0;
+
+end;' language 'plpgsql';
+
+create function task__name(integer)
+returns varchar as '
+declare
+ p_task_id alias for $1;
+ v_task_name evaluations_tasks.task_name%TYPE;
+begin
+ select task_name into v_task_name
+ from evaluation_tasks
+ where task_id = p_task_id;
+
+ return v_task_name;
+end;
+' language 'plpgsql';
+
+---------------------------------------
+-- TASKS SOLUTIONS
+---------------------------------------
+
+create function evaluation__new_task_sol (integer, integer, integer, varchar, timestamptz, integer, varchar, varchar, timestamptz, varchar, varchar)
+returns integer as '
+declare
+ p_item_id alias for $1;
+ p_revision_id alias for $2;
+ p_task_id alias for $3;
+ p_object_type alias for $4;
+ p_creation_date alias for $5;
+ p_creation_user alias for $6;
+ p_creation_ip alias for $7;
+ p_title alias for $8; -- default null
+ p_publish_date alias for $9;
+ p_nls_language alias for $10; -- default null
+ p_mime_type alias for $11; -- default null
+
+ v_revision_id integer;
+
+begin
+
+ v_revision_id := content_revision__new(
+ p_title, -- title
+ ''task solution'', -- description
+ p_publish_date, -- publish_date
+ p_mime_type, -- mime_type
+ p_nls_language, -- nls_language
+ null, -- data
+ p_item_id, -- item_id
+ p_revision_id, -- revision_id
+ current_timestamp, -- creation_date
+ p_creation_user, -- creation_user
+ p_creation_ip, -- creation_ip
+ null -- content length
+ );
+
+ insert into evaluation_tasks_sols
+ (solution_id,
+ task_id)
+ values
+ (v_revision_id,
+ p_task_id);
+
+ return v_revision_id;
+end;
+' language 'plpgsql';
+
+create function evaluation__delete_task_sol (integer)
+returns integer as '
+declare
+ p_solution_id alias for $1;
+begin
+
+ delete from evaluation_tasks_sols where solution_id = p_solution_id;
+
+ PERFORM content_revision__delete(p_solution_id);
+
+ return 0;
+
+end;' language 'plpgsql';
+
+
+---------------------------------------
+-- STUDENT ANSWERS
+---------------------------------------
+
+
+create function evaluation__new_answer (integer, integer, integer, integer, varchar, timestamptz, integer, varchar, varchar, timestamptz, varchar, varchar)
+returns integer as '
+declare
+ p_item_id alias for $1;
+ p_revision_id alias for $2;
+ p_task_id alias for $3;
+ p_party_id alias for $4;
+ p_object_type alias for $5;
+ p_creation_date alias for $6;
+ p_creation_user alias for $7;
+ p_creation_ip alias for $8;
+ p_title alias for $9; -- default null
+ p_publish_date alias for $10;
+ p_nls_language alias for $11; -- default null
+ p_mime_type alias for $12; -- default null
+
+ v_revision_id integer;
+
+begin
+
+ v_revision_id := content_revision__new(
+ p_title, -- title
+ ''evaluation answer'', -- description
+ p_publish_date, -- publish_date
+ p_mime_type, -- mime_type
+ p_nls_language, -- nls_language
+ null, -- data
+ p_item_id, -- item_id
+ p_revision_id, -- revision_id
+ current_timestamp, -- creation_date
+ p_creation_user, -- creation_user
+ p_creation_ip, -- creation_ip
+ null -- content length
+ );
+
+ insert into evaluation_answers
+ (answer_id,
+ task_id,
+ party_id)
+ values
+ (v_revision_id,
+ p_task_id,
+ p_party_id);
+
+ return v_revision_id;
+end;
+' language 'plpgsql';
+
+
+create function evaluation__delete_answer (integer)
+returns integer as '
+declare
+ p_answer_id alias for $1;
+begin
+
+ delete from evaluation_answers where answer_id = p_answer_id;
+
+ PERFORM content_revision__delete(p_answer_id);
+
+ return 0;
+
+end;' language 'plpgsql';
+
+---------------------------------------
+-- STUDENT EVALUATIONS
+---------------------------------------
+
+create function evaluation__new_student_eval (integer, integer, integer, integer, numeric, char, text, varchar, timestamptz, integer, varchar, varchar, timestamptz, varchar, varchar)
+returns integer as '
+declare
+ p_item_id alias for $1;
+ p_revision_id alias for $2;
+ p_task_id alias for $3;
+ p_party_id alias for $4;
+ p_grade alias for $5;
+ p_show_student_p alias for $6;
+ p_description alias for $7;
+ p_object_type alias for $8;
+ p_creation_date alias for $9;
+ p_creation_user alias for $10;
+ p_creation_ip alias for $11;
+ p_title alias for $12; -- default null
+ p_publish_date alias for $13;
+ p_nls_language alias for $14; -- default null
+ p_mime_type alias for $15; -- default null
+
+ v_revision_id integer;
+
+begin
+
+ v_revision_id := content_revision__new(
+ p_title, -- title
+ p_description, -- description
+ p_publish_date, -- publish_date
+ p_mime_type, -- mime_type
+ p_nls_language, -- nls_language
+ null, -- data
+ p_item_id, -- item_id
+ p_revision_id, -- revision_id
+ current_timestamp, -- creation_date
+ p_creation_user, -- creation_user
+ p_creation_ip, -- creation_ip
+ null -- content length
+ );
+
+ insert into evaluation_student_evals
+ (evaluation_id,
+ task_id,
+ party_id,
+ grade,
+ show_student_p)
+ values
+ (v_revision_id,
+ p_task_id,
+ p_party_id,
+ p_grade,
+ p_show_student_p);
+
+ return v_revision_id;
+end;
+' language 'plpgsql';
+
+create function evaluation__delete_student_eval (integer)
+returns integer as '
+declare
+ p_evaluation_id alias for $1;
+begin
+
+ delete from evaluation_student_evals where evaluation_id = p_evaluation_id;
+
+ PERFORM content_revision__delete(p_evaluation_id);
+
+ return 0;
+
+end;' language 'plpgsql';
+
+---------------------------------------
+-- EVALUATION TASK GROUPS
+---------------------------------------
+
+create function evaluation__new_evaluation_task_group(integer,varchar,varchar,timestamptz,integer,varchar,integer,integer)
+returns integer as '
+declare
+ p_task_group_id alias for $1;
+ p_task_group_name alias for $2;
+ p_join_policy alias for $3;
+ p_creation_date alias for $4;
+ p_creation_user alias for $5;
+ p_creation_ip alias for $6;
+ p_context_id alias for $7;
+ p_task_id alias for $8;
+
+ v_group_id integer;
+
+begin
+
+ v_group_id := acs_group__new (
+ p_task_group_id,
+ ''evaluation_task_groups'',
+ p_creation_date,
+ p_creation_user,
+ p_creation_ip,
+ null,
+ null,
+ p_task_group_name,
+ p_join_policy,
+ p_context_id
+ );
+
+ insert into evaluation_task_groups
+ (group_id,
+ task_id)
+ values
+ (v_group_id,
+ p_task_id);
+
+ return v_group_id;
+end;
+' language 'plpgsql';
+
+
+create function evaluation__delete_evaluation_task_group(integer)
+returns integer as '
+declare
+ p_task_group_id alias for $1;
+ del_rec record;
+begin
+
+ for del_rec in select evaluation_id from evaluation_student_evals where party_id = p_task_group_id
+ loop
+ PERFORM content_revision__delete(del_rec.evaluation_id);
+ end loop;
+
+ for del_rec in select answer_id from evaluation_answers where party_id = p_task_group_id
+ loop
+ PERFORM content_revision__delete(del_rec.answer_id);
+ end loop;
+
+ for del_rec in select rel_id from acs_rels where object_id_one = p_task_group_id
+ loop
+ PERFORM acs_rel__delete(del_rec.rel_id);
+ end loop;
+
+ delete from evaluation_task_groups
+ where group_id = p_task_group_id;
+
+ delete from groups where group_id = p_task_group_id;
+
+ delete from parties where party_id = p_task_group_id;
+
+ PERFORM acs_group__delete(p_task_group_id);
+
+ return 0;
+end;
+' language 'plpgsql';
+
+create table evaluation_user_profile_rels (
+ rel_id integer
+ constraint evaluation_user_profile_rels_pk
+ primary key
+);
+
+select acs_rel_type__create_type(
+ 'evaluation_task_group_rel',
+ 'Evaluation Task Group Member',
+ 'Evaluation Task Group Members',
+ 'membership_rel',
+ 'evaluation_user_profile_rels',
+ 'rel_id',
+ 'evaluations',
+ 'evaluation_task_groups',
+ null,
+ 0,
+ null,
+ 'user',
+ null,
+ 0,
+ 1
+ );
+
+---------------------------------------
+-- GRADE FUNCTIONS
+---------------------------------------
+
+create function evaluation__task_grade (integer, integer)
+returns numeric as '
+declare
+
+ p_user_id alias for $1;
+ p_task_id alias for $2;
+
+ v_grade evaluation_student_evals.grade%TYPE;
+
+begin
+
+ select (ese.grade*et.weight*eg.weight)/10000 into v_grade
+ from evaluation_student_evals ese, evaluation_tasks et, evaluation_grades eg
+ where party_id = evaluation__party_id(p_user_id, ese.task_id)
+ and ese.task_id = p_task_id
+ and ese.task_id = et.task_id
+ and et.grade_id = eg.grade_id;
+
+ if v_grade is null then
+ return 0.00;
+ else
+ return v_grade;
+ end if;
+end;' language 'plpgsql';
+
+create function evaluation__grade_total_grade (integer, integer)
+returns numeric as '
+declare
+
+ p_user_id alias for $1;
+ p_grade_id alias for $2;
+
+ v_grade evaluation_student_evals.grade%TYPE;
+ v_grades_cursor RECORD;
+
+begin
+
+ v_grade := 0;
+ FOR v_grades_cursor IN
+ select (ese.grade*et.weight*eg.weight)/10000 as grade
+ from evaluation_grades eg, evaluation_tasks et, evaluation_student_evalsi ese
+ where et.task_id = ese.task_id
+ and et.grade_id = eg.grade_id
+ and et.grade_id = p_grade_id
+ and ese.party_id = evaluation__party_id(p_user_id,ese.task_id)
+ and content_revision__is_live(ese.evaluation_id) = true
+ and content_revision__is_live(et.task_id) = true
+ LOOP
+ v_grade := v_grade + v_grades_cursor.grade;
+ END LOOP;
+
+ return v_grade;
+end;' language 'plpgsql';
+
+create function evaluation__class_total_grade (integer, integer)
+returns numeric as '
+declare
+
+ p_user_id alias for $1;
+ p_package_id alias for $2;
+
+ v_grade evaluation_student_evals.grade%TYPE;
+ v_grades_cursor RECORD;
+
+begin
+
+ v_grade := 0;
+ FOR v_grades_cursor IN
+ select (ese.grade*et.weight*eg.weight)/10000 as grade
+ from evaluation_gradesx eg, evaluation_tasks et, evaluation_student_evalsi ese, acs_objects ao
+ where et.task_id = ese.task_id
+ and et.grade_id = eg.grade_id
+ and eg.item_id = ao.object_id
+ and ao.context_id = p_package_id
+ and ese.party_id = evaluation__party_id(p_user_id,ese.task_id)
+ and content_revision__is_live(ese.evaluation_id) = true
+ and content_revision__is_live(eg.grade_id) = true
+ and content_revision__is_live(et.task_id) = true
+ LOOP
+ v_grade := v_grade + v_grades_cursor.grade;
+ END LOOP;
+
+ return v_grade;
+end;' language 'plpgsql';
+
+---------------------------------------
+-- OTHER FUNCTIONS
+---------------------------------------
+
+create function evaluation__party_name (integer,integer)
+returns varchar as '
+declare
+ p_party_id alias for $1;
+ p_task_id alias for $2;
+
+ v_number_of_members evaluation_tasks.number_of_members%TYPE;
+begin
+
+ select number_of_members into v_number_of_members
+ from evaluation_tasks
+ where task_id = p_task_id;
+
+ if v_number_of_members = 1 then
+ return person__last_name(p_party_id)||'', ''||person__first_names(p_party_id);
+ else
+ return acs_group__name(p_party_id);
+ end if;
+
+end;' language 'plpgsql';
+
+create function evaluation__party_id (integer,integer)
+returns varchar as '
+declare
+ p_user_id alias for $1;
+ p_task_id alias for $2;
+
+ v_number_of_members evaluation_tasks.number_of_members%TYPE;
+begin
+
+ select number_of_members into v_number_of_members
+ from evaluation_tasks
+ where task_id = p_task_id;
+
+ if v_number_of_members = 1 then
+ return p_user_id;
+ else
+ return coalesce((select etg.group_id from evaluation_task_groups etg, acs_rels map
+ where map.object_id_one = etg.group_id
+ and map.object_id_two = p_user_id
+ and etg.task_id = p_task_id),0);
+ end if;
+
+end;' language 'plpgsql';
+
+create function evaluation__new_folder (varchar,varchar,text,integer,varchar)
+returns varchar as '
+declare
+ p_name alias for $1;
+ p_label alias for $2;
+ p_description alias for $3;
+ p_parent_id alias for $4;
+ p_content_type alias for $5;
+
+ v_folder_id cr_folders.folder_id%TYPE;
+
+begin
+
+ v_folder_id := content_folder__new(
+ p_name, -- name
+ p_label, -- label
+ p_description, -- description
+ p_parent_id -- parent_id
+ );
+ -- associate content types with the folder
+ PERFORM content_folder__register_content_type (
+ v_folder_id, -- folder_id
+ ''evaluation_grades'', -- content_type
+ ''t'' -- include_subtypes
+ );
+ PERFORM content_folder__register_content_type (
+ v_folder_id, -- folder_id
+ p_content_type, -- content_type
+ ''t'' -- include_subtypes
+ );
+
+ return v_folder_id;
+end;' language 'plpgsql';
+
+create function evaluation__delete_contents (integer)
+returns integer as '
+declare
+
+ p_package_id alias for $1;
+
+ v_item_id cr_items.item_id%TYPE;
+ v_item_cursor RECORD;
+
+begin
+
+ -- delete all contents
+ FOR v_item_cursor IN
+ select eg.grade_id
+ from evaluation_gradesi eg, acs_objects ao
+ where eg.item_id = ao.object_id
+ and ao.context_id = p_package_id
+ LOOP
+ PERFORM evaluation__delete_grade(v_item_cursor.grade_id);
+ END LOOP;
+
+ -- delete all contents
+ FOR v_item_cursor IN
+ select ea.answer_id
+ from evaluation_answersi ea, acs_objects ao
+ where ea.item_id = ao.object_id
+ and ao.context_id = p_package_id
+ LOOP
+ PERFORM evaluation__delete_answer(v_item_cursor.answer_id);
+ END LOOP;
+
+ -- delete all contents
+ FOR v_item_cursor IN
+ select ets.solution_id
+ from evaluation_tasks_solsi ets, acs_objects ao
+ where ets.item_id = ao.object_id
+ and ao.context_id = p_package_id
+ LOOP
+ PERFORM evaluation__delete_task_sol(v_item_cursor.solution_id);
+ END LOOP;
+
+ -- delete all contents
+ FOR v_item_cursor IN
+ select etg.group_id
+ from evaluation_tasksi et, acs_objects ao, evaluation_task_groups etg
+ where et.item_id = ao.object_id
+ and etg.task_id = et.task_id
+ and ao.context_id = p_package_id
+ LOOP
+ PERFORM evaluation__delete_evaluation_task_group(v_item_cursor.group_id);
+ END LOOP;
+
+ -- delete all contents
+ FOR v_item_cursor IN
+ select ese.evaluation_id
+ from evaluation_student_evalsi ese, acs_objects ao
+ where ese.item_id = ao.object_id
+ and ao.context_id = p_package_id
+ LOOP
+ PERFORM evaluation__delete_student_eval(v_item_cursor.evaluation_id);
+ END LOOP;
+
+ -- delete all contents
+ FOR v_item_cursor IN
+ select et.task_id
+ from evaluation_tasksi et, acs_objects ao
+ where et.item_id = ao.object_id
+ and ao.context_id = p_package_id
+ LOOP
+ PERFORM evaluation__delete_task(v_item_cursor.task_id);
+ END LOOP;
+
+ return 0;
+end;' language 'plpgsql';
+
+create function evaluation__delete_folder (integer,varchar)
+returns integer as '
+declare
+ p_folder_id alias for $1;
+ p_content_type alias for $2;
+
+ v_item_cursor RECORD;
+
+begin
+
+ FOR v_item_cursor IN
+ select item_id
+ from cr_items
+ where parent_id = p_folder_id
+ LOOP
+ PERFORM content_item__delete(v_item_cursor.item_id);
+ END LOOP;
+
+ -- unregister_content_types
+ PERFORM content_folder__unregister_content_type (
+ p_folder_id, -- folder_id
+ ''content_revision'', -- content_type
+ ''t'' -- include_subtypes
+ );
+ PERFORM content_folder__unregister_content_type (
+ p_folder_id, -- folder_id
+ p_content_type, -- content_type
+ ''t'' -- include_subtypes
+ );
+
+ delete from cr_folder_type_map where content_type = p_content_type;
+
+ -- delete folder
+ PERFORM content_folder__delete(p_folder_id);
+
+ return 0;
+end;' language 'plpgsql';
+
+---------------------------------------
+-- TEMPLATES
+---------------------------------------
+
+create or replace function inline_0 ()
+returns integer as'
+declare
+ template_id integer;
+begin
+
+ -- Create the (default) content type template
+
+ template_id := content_template__new(
+ ''evaluation-tasks-default'', -- name
+ ''
+@title;noquote@
+@context;noquote@
+@text;noquote@'', -- text
+ true -- is_live
+ );
+
+ -- Register the template for the content type
+
+ perform content_type__register_template(
+ ''evaluation_tasks'', -- content_type
+ template_id, -- template_id
+ ''public'', -- use_context
+ ''t'' -- is_default
+ );
+
+ -- Create the (default) content type template
+
+ template_id := content_template__new(
+ ''evaluation-tasks-sols-default'', -- name
+ ''
+@title;noquote@
+@context;noquote@
+@text;noquote@'', -- text
+ true -- is_live
+ );
+
+ -- Register the template for the content type
+
+ perform content_type__register_template(
+ ''evaluation_tasks_sols'', -- content_type
+ template_id, -- template_id
+ ''public'', -- use_context
+ ''t'' -- is_default
+ );
+
+ -- Create the (default) content type template
+
+ template_id := content_template__new(
+ ''evaluation-answers-default'', -- name
+ ''
+@title;noquote@
+@context;noquote@
+@text;noquote@'', -- text
+ true -- is_live
+ );
+
+ -- Register the template for the content type
+
+ perform content_type__register_template(
+ ''evaluation_answers'', -- content_type
+ template_id, -- template_id
+ ''public'', -- use_context
+ ''t'' -- is_default
+ );
+
+ return null;
+end;' language 'plpgsql';
+
+select inline_0();
+drop function inline_0();
+
Index: openacs-4/packages/evaluation/sql/postgresql/evaluation-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/sql/postgresql/evaluation-drop.sql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/sql/postgresql/evaluation-drop.sql 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,237 @@
+-- jopez@galileo.edu
+
+
+-- Unregister the content template
+select content_type__unregister_template (
+ 'evaluation_tasks',
+ content_type__get_template('evaluation_tasks','public'),
+ 'public'
+);
+-- Unregister the content template
+select content_type__unregister_template (
+ 'evaluation_tasks_sols',
+ content_type__get_template('evaluation_tasks_sols','public'),
+ 'public'
+);
+-- Unregister the content template
+select content_type__unregister_template (
+ 'evaluation_answers',
+ content_type__get_template('evaluation_answers','public'),
+ 'public'
+);
+
+-- deleting templates
+create function inline_0 ()
+returns integer as '
+declare
+ v_template_id cr_templates.template_id%TYPE;
+ v_item_cursor RECORD;
+
+begin
+
+ FOR v_item_cursor IN
+ select template_id
+ from cr_templates, cr_items
+ where name=''evaluation-tasks-default''
+ LOOP
+ PERFORM content_template__delete(v_item_cursor.template_id);
+ END LOOP;
+
+ FOR v_item_cursor IN
+ select template_id
+ from cr_templates, cr_items
+ where name=''evaluation-tasks-sols-default''
+ LOOP
+ PERFORM content_template__delete(v_item_cursor.template_id);
+ END LOOP;
+
+ FOR v_item_cursor IN
+ select template_id
+ from cr_templates, cr_items
+ where name=''evaluation-answers-default''
+ LOOP
+ PERFORM content_template__delete(v_item_cursor.template_id);
+ END LOOP;
+
+ return 0;
+end;
+' language 'plpgsql';
+
+select inline_0 ();
+drop function inline_0 ();
+
+
+create function inline_0 ()
+returns integer as'
+declare
+ del_rec record;
+begin
+ for del_rec in select item_id from cr_items
+ where content_type in (''evaluation_grades'', ''evaluation_tasks'', ''evaluation_tasks_sols'', ''evaluation_answers'', ''evaluation_student_evals'')
+ loop
+ PERFORM content_item__delete(del_rec.item_id);
+ end loop;
+return 0;
+end;' language 'plpgsql';
+select inline_0 ();
+drop function inline_0 ();
+
+create function inline_0 ()
+returns integer as'
+declare
+ del_rec record;
+begin
+ for del_rec in select item_id from cr_items
+ where content_type in (''evaluation_grades'', ''evaluation_tasks'', ''evaluation_tasks_sols'', ''evaluation_answers'', ''evaluation_student_evals'')
+ loop
+ PERFORM content_item__delete(del_rec.item_id);
+ end loop;
+return 0;
+end;' language 'plpgsql';
+select inline_0 ();
+drop function inline_0 ();
+
+delete from acs_objects where object_type = 'evaluation_grades';
+delete from acs_objects where object_type = 'evaluation_tasks';
+delete from acs_objects where object_type = 'evaluation_tasks_sols';
+delete from acs_objects where object_type = 'evaluation_answers';
+delete from acs_objects where object_type = 'evaluation_student_evals';
+delete from acs_objects where object_type = 'evaluation_task_groups';
+delete from acs_objects where object_type = 'evaluation_task_group_rel';
+
+delete from acs_attributes where object_type = 'evaluation_task_groups';
+delete from acs_object_type_tables where object_type = 'evaluation_task_groups';
+delete from group_types where group_type = 'evaluation_task_groups';
+
+select acs_object_type__drop_type('evaluation_task_group','f');
+select acs_rel_type__drop_type('evaluation_task_group_rel','t');
+
+create function inline_1 ()
+returns integer as'
+begin
+PERFORM acs_object_type__drop_type(''evaluation_grades'',''f'');
+PERFORM acs_object_type__drop_type(''evaluation_tasks'',''f'');
+PERFORM acs_object_type__drop_type(''evaluation_tasks_sols'',''f'');
+PERFORM acs_object_type__drop_type(''evaluation_answers'',''f'');
+PERFORM acs_object_type__drop_type(''evaluation_student_evals'',''f'');
+PERFORM acs_object_type__drop_type(''evaluation_task_groups'',''f'');
+
+return 0;
+end;' language 'plpgsql';
+select inline_1 ();
+drop function inline_1 ();
+
+drop index evalutaion_tasks_sols_tid_index;
+drop view evaluation_tasks_solsi;
+drop view evaluation_tasks_solsx;
+drop table evaluation_tasks_sols;
+
+drop index evaluation_student_evals_tid_index;
+drop index evaluation_student_evals_pid_index;
+drop view evaluation_student_evalsi;
+drop view evaluation_student_evalsx;
+drop table evaluation_student_evals;
+
+drop view evaluation_answersi;
+drop view evaluation_answersx;
+drop table evaluation_answers;
+
+drop table evaluation_tasks_class_map;
+
+drop table evaluation_task_groups;
+
+drop view evaluation_tasksi;
+drop view evaluation_tasksx;
+drop table evaluation_tasks;
+
+drop view evaluation_gradesi;
+drop view evaluation_gradesx;
+drop table evaluation_grades;
+
+drop function evaluation__new_item (integer,varchar,varchar,integer,integer,varchar,varchar,text,varchar,varchar,text,varchar,varchar,varchar);
+
+---------------------------------------
+-- GRADES
+---------------------------------------
+
+drop function evaluation__new_grade (integer, integer, varchar, integer, numeric, varchar, timestamptz, integer, varchar, varchar, varchar, timestamptz, varchar, varchar);
+
+drop function evaluation__delete_grade (integer);
+
+drop function grade__name(integer);
+
+---------------------------------------
+-- TASKS
+---------------------------------------
+
+drop function evaluation__new_task (integer, integer, varchar, integer, integer, varchar, numeric, timestamptz, char, char, char, varchar, timestamptz, integer, varchar, varchar, timestamptz, varchar, varchar);
+
+drop function evaluation__delete_task (integer);
+
+drop function task__name(integer);
+
+---------------------------------------
+-- TASKS SOLUTIONS
+---------------------------------------
+
+drop function evaluation__new_task_sol (integer, integer, integer, varchar, timestamptz, integer, varchar, varchar, timestamptz, varchar, varchar);
+
+drop function evaluation__delete_task_sol (integer);
+
+---------------------------------------
+-- STUDENT ANSWERS
+---------------------------------------
+
+drop function evaluation__new_answer (integer, integer, integer, integer, varchar, timestamptz, integer, varchar, varchar, timestamptz, varchar, varchar);
+
+drop function evaluation__delete_answer (integer);
+
+---------------------------------------
+-- STUDENT EVALUATIONS
+---------------------------------------
+
+drop function evaluation__new_student_eval (integer, integer, integer, integer, numeric, char, text, varchar, timestamptz, integer, varchar, varchar, timestamptz, varchar, varchar);
+
+drop function evaluation__delete_student_eval (integer);
+
+---------------------------------------
+-- EVALUATION TASK GROUPS
+---------------------------------------
+
+drop function evaluation__new_evaluation_task_group(integer,varchar,varchar,timestamptz,integer,varchar,integer,integer);
+
+drop function evaluation__delete_evaluation_task_group(integer);
+
+delete from acs_rels where rel_type = 'evaluation_task_group_rel';
+
+drop table evaluation_user_profile_rels;
+
+select acs_rel_type__drop_type('evaluation_task_group_rel','t');
+
+select acs_object_type__drop_type('evaluation_task_group_rel','f');
+
+---------------------------------------
+-- GRADE FUNCIONS
+---------------------------------------
+
+drop function evaluation__task_grade (integer, integer);
+
+drop function evaluation__grade_total_grade (integer, integer);
+
+drop function evaluation__class_total_grade (integer, integer);
+
+---------------------------------------
+-- OTHER FUNCIONS
+---------------------------------------
+
+drop function evaluation__party_name (integer,integer);
+
+drop function evaluation__party_id (integer,integer);
+
+drop function evaluation__new_folder (varchar,varchar,text,integer,varchar);
+
+drop function evaluation__delete_contents (integer);
+
+drop function evaluation__delete_folder (integer,varchar);
+
+
Index: openacs-4/packages/evaluation/tcl/apm-callback-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/tcl/apm-callback-procs.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/tcl/apm-callback-procs.tcl 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,269 @@
+# /packages/evaluation/tcl/apm-callback-procs.tcl
+
+ad_library {
+
+ Evaluations Package APM callbacks library
+
+ Procedures that deal with installing, instantiating, mounting.
+
+ @creation-date Apr 2004
+ @author jopez@galileo.edu
+ @cvs-id $Id: apm-callback-procs.tcl,v 1.1 2004/04/28 11:06:41 rocaelh Exp $
+}
+
+namespace eval evaluation::apm_callbacks {}
+
+ad_proc -private evaluation::apm_callbacks::package_instantiate {
+ -package_id:required
+} {
+
+ Define Evaluation folders
+
+} {
+
+ set creation_user [ad_verify_and_get_user_id]
+ set creation_ip [ad_conn peeraddr]
+
+ db_transaction {
+ db_exec_plsql create_evaluation_folders {
+ select evaluation__new_folder (
+ 'evaluation_grades_'||:package_id,
+ 'evaluation_grades_'||:package_id,
+ 'Evaluation grades folder',
+ null,
+ 'evaluation_grades'
+ );
+
+ select evaluation__new_folder (
+ 'evaluation_tasks_'||:package_id,
+ 'evaluation_tasks_'||:package_id,
+ 'Evaluation tasks folder',
+ null,
+ 'evaluation_tasks'
+ );
+
+ select evaluation__new_folder (
+ 'evaluation_tasks_sols_'||:package_id,
+ 'evaluation_tasks_sols_'||:package_id,
+ 'Evaluation tasks solutions folder',
+ null,
+ 'evaluation_tasks_sols'
+ );
+
+ select evaluation__new_folder (
+ 'evaluation_answers_'||:package_id,
+ 'evaluation_answers_'||:package_id,
+ 'Evaluation answers folder',
+ null,
+ 'evaluation_answers'
+ );
+
+ select evaluation__new_folder (
+ 'evaluation_student_evals_'||:package_id,
+ 'evaluation_student_evals_'||:package_id,
+ 'Evaluation student evaluations folder',
+ null,
+ 'evaluation_student_evals'
+ );
+ }
+
+ set creation_user [ad_verify_and_get_user_id]
+ set creation_ip [ad_conn peeraddr]
+
+ set exams_item_id [db_nextval acs_object_id_seq]
+ set exams_item_name "evaluation_grades_${exams_item_id}"
+ set exams_revision_id [db_nextval acs_object_id_seq]
+ set exams_revision_name "evaluation_grades_${exams_revision_id}"
+
+ db_exec_plsql exams_item_new {
+ select evaluation__new_item (
+ :exams_item_id, --item_id
+ :exams_item_name,
+ null,
+ :creation_user,
+ :package_id,
+ :creation_ip,
+ 'Exams',
+ 'Exams for students',
+ 'text/plain',
+ null,
+ null,
+ 'text',
+ 'content_item', -- item_subtype
+ 'evaluation_grades' -- content_type
+ );
+ }
+
+ db_exec_plsql exams_revision_new {
+ select evaluation__new_grade (
+ :exams_item_id,
+ :exams_revision_id,
+ 'Exams',
+ -1, -- class_id temporal
+ 40,
+ 'evaluation_grades',
+ now(), --creation date
+ :creation_user,
+ :creation_ip,
+ :exams_revision_name,
+ 'Exams for students',
+ now(), --publish date
+ null, --nls_language
+ 'text/plain' --mime_type
+ );
+ }
+
+ db_exec_plsql exams_live_revision {
+ select content_item__set_live_revision (
+ :exams_revision_id
+ );
+ }
+
+ set projects_item_id [db_nextval acs_object_id_seq]
+ set projects_item_name "evaluation_grades_${projects_item_id}"
+ set projects_revision_id [db_nextval acs_object_id_seq]
+ set projects_revision_name "evaluation_grades_${projects_revision_id}"
+
+ db_exec_plsql projects_item_new {
+ select evaluation__new_item (
+ :projects_item_id, --item_id
+ :projects_item_name,
+ null,
+ :creation_user,
+ :package_id,
+ :creation_ip,
+ 'Projects',
+ 'Projects for students',
+ 'text/plain',
+ null,
+ null,
+ 'text',
+ 'content_item', -- item_subtype
+ 'evaluation_grades' -- content_type
+ );
+ }
+
+ db_exec_plsql projects_revision_new {
+ select evaluation__new_grade (
+ :projects_item_id,
+ :projects_revision_id,
+ 'Projects',
+ -1, -- class_id temporal
+ 40,
+ 'evaluation_grades',
+ now(), --creation date
+ :creation_user,
+ :creation_ip,
+ :projects_revision_name,
+ 'Projects for students',
+ now(), --publish date
+ null, --nls_language
+ 'text/plain' --mime_type
+ );
+ }
+
+ db_exec_plsql projects_live_revision {
+ select content_item__set_live_revision (
+ :projects_revision_id
+ );
+ }
+
+ set tasks_item_id [db_nextval acs_object_id_seq]
+ set tasks_item_name "evaluation_grades_${tasks_item_id}"
+ set tasks_revision_id [db_nextval acs_object_id_seq]
+ set tasks_revision_name "evaluation_grades_${tasks_revision_id}"
+
+ db_exec_plsql tasks_item_new {
+ select evaluation__new_item (
+ :tasks_item_id, --item_id
+ :tasks_item_name,
+ null,
+ :creation_user,
+ :package_id,
+ :creation_ip,
+ 'Tasks',
+ 'Tasks for students',
+ 'text/plain',
+ null,
+ null,
+ 'text',
+ 'content_item', -- item_subtype
+ 'evaluation_grades' -- content_type
+ );
+ }
+
+ db_exec_plsql tasks_revision_new {
+ select evaluation__new_grade (
+ :tasks_item_id,
+ :tasks_revision_id,
+ 'Tasks',
+ -1, -- class_id temporal
+ 40,
+ 'evaluation_grades',
+ now(), --creation date
+ :creation_user,
+ :creation_ip,
+ :tasks_revision_name,
+ 'Tasks for students',
+ now(), --publish date
+ null, --nls_language
+ 'text/plain' --mime_type
+ );
+ }
+
+ db_exec_plsql tasks_live_revision {
+ select content_item__set_live_revision (
+ :tasks_revision_id
+ );
+ }
+ }
+}
+
+
+ad_proc -private evaluation::apm_callbacks::package_uninstantiate {
+ -package_id:required
+} {
+
+ Delete Evaluation stuff
+
+} {
+
+ set ev_grades_fid [db_string get_f_id "select content_item__get_id('evaluation_grades_'||:package_id,null,'f')"]
+ set ev_tasks_fid [db_string get_f_id "select content_item__get_id('evaluation_tasks_'||:package_id,null,'f')"]
+ set ev_tasks_sols_fid [db_string get_f_id "select content_item__get_id('evaluation_tasks_sols_'||:package_id,null,'f')"]
+ set ev_answers_fid [db_string get_f_id "select content_item__get_id('evaluation_answers_'||:package_id,null,'f')"]
+ set ev_student_evals_fid [db_string get_f_id "select content_item__get_id('evaluation_student_evals_'||:package_id,null,'f')"]
+
+ db_transaction {
+ db_exec_plsql delte_evaluation_folders {
+ select evaluation__delete_contents (
+ :package_id
+ );
+
+ select evaluation__delete_folder (
+ :ev_grades_fid,
+ 'evaluation_grades'
+ );
+
+ select evaluation__delete_folder (
+ :ev_tasks_fid,
+ 'evaluation_tasks'
+ );
+
+ select evaluation__delete_folder (
+ :ev_tasks_sols_fid,
+ 'evaluation_tasks_sols'
+ );
+
+ select evaluation__delete_folder (
+ :ev_answers_fid,
+ 'evaluation_answers'
+ );
+
+ select evaluation__delete_folder (
+ :ev_student_evals_fid,
+ 'evaluation_student_evals'
+ );
+ }
+ }
+}
Index: openacs-4/packages/evaluation/tcl/evaluation-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/tcl/evaluation-procs-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/tcl/evaluation-procs-postgresql.xql 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,305 @@
+
+
+
+ postgresql 7.4
+
+
+
+
+ select evaluation__new_item (
+ :item_id, --item_id
+ :item_name,
+ null,
+ :creation_user,
+ :package_id,
+ :creation_ip,
+ :name,
+ :description,
+ 'text/plain',
+ null,
+ null,
+ 'text',
+ 'content_item', -- item_subtype
+ 'evaluation_grades' -- content_type
+ );
+
+
+
+
+
+
+
+ select evaluation__new_grade (
+ :item_id,
+ :revision_id,
+ :name,
+ -1, -- class_id temporal
+ :weight,
+ 'evaluation_grades',
+ now(), --creation date
+ :creation_user,
+ :creation_ip,
+ :revision_name,
+ :description,
+ now(), --publish date
+ null, --nls_language
+ 'text/plain' --mime_type
+ );
+
+
+
+
+
+
+
+ select content_item__set_live_revision (
+ :revision_id
+ );
+
+
+
+
+
+
+
+ select evaluation__new_item (
+ :item_id, --item_id
+ :item_name,
+ null, --locale
+ :creation_user,
+ :package_id,
+ :creation_ip,
+ :name,
+ :description,
+ :mime_type, --mime_type
+ null, --nls_language
+ null, --text
+ :storage_type, --storage_type
+ 'content_item', -- item_subtype
+ 'evaluation_tasks' -- content_type
+ );
+
+
+
+
+
+
+
+ select evaluation__new_task (
+ :item_id,
+ :revision_id,
+ :name,
+ :number_of_members,
+ :grade_id, -- class_id temporal
+ :description,
+ :weight,
+ :due_date,
+ :late_submit_p,
+ :online_p,
+ :requires_grade_p,
+ 'evaluation_tasks',
+ now(), --creation date
+ :creation_user,
+ :creation_ip,
+ :item_name,
+ now(), --publish date
+ null, -- nls_language
+ :mime_type --mime_type
+ );
+
+
+
+
+
+
+
+ update cr_items
+ set name = :item_name,
+ storage_type = :storage_type
+ where item_id = :item_id
+
+
+
+
+
+
+
+ select evaluation__new_item (
+ :item_id, --item_id
+ :item_name,
+ null, --locale
+ :creation_user,
+ :package_id,
+ :creation_ip,
+ :title,
+ 'task solution',
+ :mime_type, --mime_type
+ null, --nls_language
+ null, --text
+ :storage_type, --storage_type
+ 'content_item', -- item_subtype
+ 'evaluation_tasks_sols' -- content_type
+ );
+
+
+
+
+
+
+
+ select evaluation__new_task_sol (
+ :item_id,
+ :revision_id,
+ :task_id,
+ 'evaluation_tasks_sols',
+ now(), --creation date
+ :creation_user,
+ :creation_ip,
+ :item_name,
+ now(), --publish date
+ null, -- nls_language
+ :mime_type --mime_type
+ );
+
+
+
+
+
+
+
+ update cr_items
+ set name = :item_name,
+ storage_type = :storage_type
+ where item_id = :item_id
+
+
+
+
+
+
+
+ select evaluation__new_item (
+ :item_id, --item_id
+ :item_name,
+ null, --locale
+ :creation_user,
+ :package_id,
+ :creation_ip,
+ :title,
+ 'evaluation answer',
+ :mime_type, --mime_type
+ null, --nls_language
+ null, --text
+ :storage_type, --storage_type
+ 'content_item', -- item_subtype
+ 'evaluation_answers' -- content_type
+ );
+
+
+
+
+
+
+
+ select evaluation__new_answer (
+ :item_id,
+ :revision_id,
+ :task_id,
+ :party_id,
+ 'evaluation_answers',
+ now(), --creation date
+ :creation_user,
+ :creation_ip,
+ :item_name,
+ now(), --publish date
+ null, -- nls_language
+ :mime_type --mime_type
+ );
+
+
+
+
+
+
+
+ update cr_items
+ set name = :item_name,
+ storage_type = :storage_type
+ where item_id = :item_id
+
+
+
+
+
+
+
+ select evaluation__new_item (
+ :item_id, --item_id
+ :item_name,
+ null, --locale
+ :creation_user,
+ :package_id,
+ :creation_ip,
+ :title,
+ 'student evaluation',
+ :mime_type, --mime_type
+ null, --nls_language
+ null, --text
+ :storage_type, --storage_type
+ 'content_item', -- item_subtype
+ 'evaluation_student_evals' -- content_type
+ ) where not exists (select 1 from cr_items where item_id = :item_id);
+
+
+
+
+
+
+
+ select evaluation__new_student_eval (
+ :item_id,
+ :revision_id,
+ :task_id,
+ :party_id,
+ :grade,
+ :show_student_p,
+ :description,
+ 'evaluation_student_evals',
+ now(), --creation date
+ :creation_user,
+ :creation_ip,
+ :item_name, --title
+ now(), --publish date
+ null, -- nls_language
+ :mime_type --mime_type
+ );
+
+
+
+
+
+
+
+ select evaluation__new_evaluation_task_group (
+ :group_id,
+ :group_name,
+ 'closed',
+ now(),
+ :creation_user,
+ :creation_ip,
+ :context,
+ :task_id
+ );
+
+
+
+
+
+
+
+ select acs_group__name(:group_id) as group_name
+
+
+
+
+
Index: openacs-4/packages/evaluation/tcl/evaluation-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/tcl/evaluation-procs.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/tcl/evaluation-procs.tcl 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,390 @@
+ad_library {
+ Procedures in the evaluation namespace.
+
+ @creation-date Feb 2004
+ @author jopez@galileo.edu
+ @cvs-id $Id: evaluation-procs.tcl,v 1.1 2004/04/28 11:06:41 rocaelh Exp $
+}
+
+namespace eval evaluation {}
+
+#####
+#
+# evaluation namespace
+#
+#####
+
+
+ad_proc -public evaluation::package_key {} {
+ return "evaluation"
+}
+
+
+ad_proc -public evaluation::make_url {
+ -file_name_from_db:required
+} {
+ if { [regexp "view" $file_name_from_db] } {
+ return $file_name_from_db
+ } elseif { [regexp "http://" $file_name_from_db] } {
+ return $file_name_from_db
+ } else {
+ return $file_name_from_db
+ }
+}
+
+
+ad_proc -public evaluation::new_grade {
+ -item_id:required
+ -content_type:required
+ -content_table:required
+ -content_id:required
+ -new_item_p:required
+ -description:required
+ -weight:required
+ -name:required
+} {
+
+ Build a new content revision of a evaluation subtype. If new_item_p is
+ set true then a new item is first created, otherwise a new revision is created for
+ the item indicated by item_id.
+
+ @param item_id The item to update or create.
+ @param content_type The type to make
+ @param content_table
+ @param new_item_p If true make a new item using item_id
+
+} {
+
+ set package_id [ad_conn package_id]
+ set creation_user [ad_verify_and_get_user_id]
+ set creation_ip [ad_conn peeraddr]
+
+ set item_name "${content_type}_${item_id}"
+
+ set revision_id [db_nextval acs_object_id_seq]
+ set revision_name "${content_type}_${revision_id}"
+
+ if { $new_item_p } {
+ db_exec_plsql content_item_new { *SQL* }
+
+ }
+
+ db_exec_plsql content_revision_new { *SQL* }
+
+ return $revision_id
+}
+
+
+ad_proc -public evaluation::set_live {
+ -revision_id:required
+} {
+
+ Makes a live revision of the revision_id provided.
+
+ @param revision_id The revision to set live.
+} {
+ db_exec_plsql content_set_live_revision { *SQL* }
+ return
+}
+
+
+
+ad_proc -private evaluation::export_entire_form_except { args } {
+ Exports all but part of a form
+} {
+ # exports entire form except the variables specified in args
+ set hidden ""
+ set the_form [ns_getform]
+ if {![empty_string_p $the_form]} {
+ for {set i 0} {$i<[ns_set size $the_form]} {incr i} {
+ set varname [ns_set key $the_form $i]
+ if { [lsearch -exact $args $varname] == -1 } {
+ set varvalue [ns_set value $the_form $i]
+ append hidden " \n"
+ }
+ }
+ }
+ return $hidden
+}
+
+
+ad_proc -private evaluation::now_plus_days { -ndays } {
+ Create a new Date object for the current date and time
+ plus the number of days given
+ with the default interval for minutes
+
+ @author jopez@galileo.edu
+ @creation-date Mar 2004
+} {
+ set now [list]
+ foreach v [clock format [clock seconds] -format "%Y %m %d %H %M %S"] {
+ lappend now [template::util::leadingTrim $v]
+ }
+
+ set day [lindex $now 2]
+ set month [lindex $now 1]
+ set interval_def [template::util::date::defaultInterval day]
+ for { set i [lindex $interval_def 0] } { $i <= 15 } { incr i 1 } {
+ incr day
+ if { [expr $day + $i] >= [lindex $interval_def 1] } {
+ incr month 1
+ set day 1
+ }
+ }
+
+ # replace the hour and minute values in the now list with new values
+ set now [lreplace $now 2 2 $day]
+ set now [lreplace $now 1 1 $month]
+
+ return [eval template::util::date::create $now]
+}
+
+ad_proc -public evaluation::new_task {
+ -item_id:required
+ -content_type:required
+ -content_table:required
+ -content_id:required
+ -new_item_p:required
+ -name:required
+ -grade_id:required
+ -number_of_members:required
+ -requires_grade_p:required
+ -storage_type:required
+ {-online_p ""}
+ {-due_date ""}
+ {-weight:required ""}
+ {-late_submit_p ""}
+ {-description ""}
+ {-title ""}
+ {-mime_type "text/plain"}
+ {-item_name ""}
+} {
+
+ Build a new content revision of a task. If new_item_p is
+ set true then a new item is first created, otherwise a new revision is created for
+ the item indicated by item_id.
+
+ @param item_id The item to update or create.
+ @param content_type The type to make
+ @param content_table
+ @param new_item_p If true make a new item using item_id
+ @param grade_id Grade type where the task belongs
+ @param name The name of the task
+ @number_of_members If the task is in groups this parameter must be > 1
+ @param online_p If the task will be submited online
+ @due_date Due date of the task
+ @weight Weight of the task in the grade type
+ @late_submit_p If the students will be able to submit the task after due date
+ @description Description of the task
+ @storage_type File or text, depending on what are we going to store
+
+} {
+
+ set package_id [ad_conn package_id]
+ set creation_user [ad_verify_and_get_user_id]
+ set creation_ip [ad_conn peeraddr]
+
+ if { [empty_string_p $item_name] } {
+ set item_name "${item_id}_${title}"
+ }
+
+ set revision_id [db_nextval acs_object_id_seq]
+
+ if { $new_item_p } {
+ db_exec_plsql content_item_new { *SQL* }
+
+ }
+
+ db_exec_plsql content_revision_new { *SQL* }
+
+ # in order to find the file we have to set the name in cr_items the same that in cr_revisions
+ db_dml update_item_name { *SQL* }
+ return $revision_id
+}
+
+
+ad_proc -public evaluation::new_solution {
+ -item_id:required
+ -content_type:required
+ -content_table:required
+ -content_id:required
+ -new_item_p:required
+ -task_id:required
+ -storage_type:required
+ -title:required
+ {-mime_type "text/plain"}
+} {
+
+ Build a new content revision of a task solution. If new_item_p is
+ set true then a new item is first created, otherwise a new revision is created for
+ the item indicated by item_id.
+
+ @param item_id The item to update or create.
+ @param content_type The type to make
+ @param content_table
+ @param new_item_p If true make a new item using item_id
+ @param task_id Task which "owns" the solution
+ @param title The name of the task solution
+ @param storage_type lob or text, depending on what are we going to store
+
+} {
+
+ set package_id [ad_conn package_id]
+ set creation_user [ad_verify_and_get_user_id]
+ set creation_ip [ad_conn peeraddr]
+
+ set item_name "${item_id}_${title}"
+
+ set revision_id [db_nextval acs_object_id_seq]
+
+ if { $new_item_p } {
+ db_exec_plsql content_item_new { *SQL* }
+ }
+
+ db_exec_plsql content_revision_new { *SQL* }
+
+ # in order to find the file we have to set the name in cr_items the same that in cr_revisions
+ db_dml update_item_name { *SQL* }
+ return $revision_id
+}
+
+
+ad_proc -public evaluation::new_answer {
+ -item_id:required
+ -content_type:required
+ -content_table:required
+ -content_id:required
+ -new_item_p:required
+ -task_id:required
+ -storage_type:required
+ -title:required
+ -party_id:required
+ {-mime_type "text/plain"}
+} {
+
+ Build a new content revision of an answer. If new_item_p is
+ set true then a new item is first created, otherwise a new revision is created for
+ the item indicated by item_id.
+
+ @param item_id The item to update or create.
+ @param content_type The type to make
+ @param content_table
+ @param new_item_p If true make a new item using item_id
+ @param task_id Task which "owns" the answer
+ @param title The name of the task solution
+ @param storage_type lob or text, depending on what are we going to store
+ @param party_id Group or user_id thaw owns the anser
+} {
+
+ set package_id [ad_conn package_id]
+ set creation_user [ad_verify_and_get_user_id]
+ set creation_ip [ad_conn peeraddr]
+
+ set item_name "${item_id}_${title}"
+
+ set revision_id [db_nextval acs_object_id_seq]
+
+ if { $new_item_p } {
+ db_exec_plsql content_item_new { *SQL* }
+ }
+
+ db_exec_plsql content_revision_new { *SQL* }
+
+ # in order to find the file we have to set the name in cr_items the same that in cr_revisions
+ db_dml update_item_name { *SQL* }
+ return $revision_id
+}
+
+ad_proc -public evaluation::new_evaluation {
+ -item_id:required
+ -content_type:required
+ -content_table:required
+ -content_id:required
+ -new_item_p:required
+ -party_id:required
+ -task_id:required
+ -grade:required
+ {-title "evaluation"}
+ {-show_student_p "t"}
+ {-storage_type "text"}
+ {-description ""}
+ {-mime_type "text/plain"}
+} {
+
+ Build a new content revision of an evaluation. If new_item_p is
+ set true then a new item is first created, otherwise a new revision is created for
+ the item indicated by item_id.
+
+ @param item_id The item to update or create.
+ @param content_type The type to make
+ @param content_table
+ @param new_item_p If true make a new item using item_id
+ @param task_id Task been evaluated
+ @param party_id Party been evaluated
+ @param grade Grade of the evaluation
+ @param show_student_p If the student(s) will be able to see the grade
+ @param storage_type lob or text, depending on what are we going to store
+ @param description Comments on the evaluation
+ @param mime_type Mime type of the evaluation.
+} {
+
+ set package_id [ad_conn package_id]
+ set creation_user [ad_verify_and_get_user_id]
+ set creation_ip [ad_conn peeraddr]
+
+ set item_name "${item_id}_${title}"
+
+ set revision_id [db_nextval acs_object_id_seq]
+
+ if { $new_item_p } {
+ db_exec_plsql content_item_new { *SQL* }
+ }
+
+ db_exec_plsql content_revision_new { *SQL* }
+
+}
+
+ad_proc -public evaluation::new_evaluation_group {
+ -group_id:required
+ -group_name:required
+ -task_id:required
+ {-context ""}
+} {
+
+ Build a new group of type evlaution_groups for the tasks.
+ This procedure is just a wrapper for the pl/sql function evaluation.new_evalatuion_group
+ which uses the acs_group.new funcion.
+
+ @param group_id The group_id that will be created.
+ @param group_key Key for the group.
+ @param pretty_name
+ @param task_id The task that will be done by the group.
+ @param context_id If not provided, it will be the package_id.
+
+} {
+
+ if { [empty_string_p $context] } {
+ set context [ad_conn package_id]
+ }
+ set creation_user [ad_verify_and_get_user_id]
+ set creation_ip [ad_conn peeraddr]
+
+ db_exec_plsql evaluation_group_new { *SQL* }
+
+ return $group_id
+}
+
+ad_proc -public evaluation::evaluation_group_name {
+ -group_id:required
+} {
+
+ @param group_id
+
+} {
+
+ return [db_exec_plsql evaluation_group_name { *SQL* }]
+
+}
+
+
Index: openacs-4/packages/evaluation/www/answer-add-edit-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/answer-add-edit-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/answer-add-edit-postgresql.xql 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,45 @@
+
+
+
+ postgresql 7.4
+
+
+
+
+ select evaluation__party_id(:user_id,:task_id)
+
+
+
+
+
+
+
+ select crr.title, crr.item_id
+ from evaluation_answers ea, cr_revisions crr
+ where ea.answer_id = :answer_id
+ and crr.revision_id = ea.answer_id
+
+
+
+
+
+
+
+ update cr_revisions
+ set lob = [set __lob_id [db_string get_lob_id "select empty_lob()"]]
+ where revision_id = :revision_id
+
+
+
+
+
+
+
+ update cr_revisions
+ set content = :url
+ where revision_id = :revision_id
+
+
+
+
+
Index: openacs-4/packages/evaluation/www/answer-add-edit.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/answer-add-edit.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/answer-add-edit.adp 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,5 @@
+
+ @page_title;noquote@
+ @context;noquote@
+
+
Index: openacs-4/packages/evaluation/www/answer-add-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/answer-add-edit.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/answer-add-edit.tcl 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,120 @@
+# /packages/evaluation/www/answer-add-edit.tcl
+
+ad_page_contract {
+ Page for editing and adding answers.
+
+ @author jopez@galileo.edu
+ @creation-date Mar 2004
+ @cvs-id $Id: answer-add-edit.tcl,v 1.1 2004/04/28 11:06:41 rocaelh Exp $
+} {
+ task_id:integer,notnull
+ grade_id:integer,notnull
+ answer_id:integer,notnull,optional
+ item_id:integer,notnull,optional
+ upload_file:trim,optional
+ upload_file.tmpfile:tmpfile,optional
+}
+
+set user_id [ad_conn user_id]
+set party_id [db_string get_party_id { *SQL* }]
+
+set package_id [ad_conn package_id]
+set return_url "task-list?[export_vars { grade_id }]"
+
+if { [ad_form_new_p -key answer_id] } {
+ set page_title "Upload Answer"
+} else {
+ set page_title "Change Answer"
+ db_1row item_data { *SQL* }
+
+}
+
+set context [list $page_title]
+
+ad_form -html { enctype multipart/form-data } -name answer -cancel_url $return_url -export { item_id grade_id task_id attached_p } -form {
+
+ answer_id:key
+
+}
+
+ad_form -extend -name answer -form {
+
+ {upload_file:file,optional
+ {label "File"}
+ {html "size 30"}
+ }
+ {url:text(text),optional
+ {label "URL"}
+ {value "http://"}
+ }
+}
+
+ad_form -extend -name answer -form {
+
+} -edit_request {
+
+ db_1row item_data { *SQL* }
+
+} -validate {
+ {url
+ { ([string eq $url "http://"] && ![empty_string_p $upload_file]) || (![string eq $url "http://"] && [empty_string_p $upload_file]) || (![string eq $url "http://"] && [util_url_valid_p $url]) }
+ {Upload a file OR a valid url, and not both }
+ }
+ {upload_file
+ { ([string eq $url "http://"] && ![empty_string_p $upload_file]) || (![string eq $url "http://"] && [empty_string_p $upload_file]) }
+ {Upload a file OR a url, and not both}
+ }
+} -on_submit {
+
+ db_transaction {
+
+ set mime_type "text/plain"
+ set title ""
+ set storage_type text
+ if { ![empty_string_p $upload_file] } {
+
+ # Get the filename part of the upload file
+ if { ![regexp {[^//\\]+$} $upload_file filename] } {
+ # no match
+ set filename $upload_file
+ }
+
+ set title [template::util::file::get_property filename $upload_file]
+ set mime_type [cr_filename_to_mime_type -create $title]
+
+ set storage_type lob
+ } elseif { ![string eq $url "http://"] } {
+ set mime_type "text/plain"
+ set title "link"
+ set storage_type text
+ }
+
+ if { [ad_form_new_p -key answer_id] } {
+ set item_id $answer_id
+ }
+
+ set revision_id [evaluation::new_answer -new_item_p [ad_form_new_p -key answer_id] -item_id $item_id -content_type evaluation_answers \
+ -content_table evaluation_answers -content_id answer_id -storage_type $storage_type -task_id $task_id \
+ -title $title -mime_type $mime_type -party_id $party_id]
+
+ evaluation::set_live -revision_id $revision_id
+
+ if { ![empty_string_p $upload_file] } {
+
+ set tmp_file [template::util::file::get_property tmp_filename $upload_file]
+
+ # create the new item
+ db_dml lob_content { *SQL* } -blob_files [list $tmp_file]
+
+ } elseif { ![string eq $url "http://"] } {
+
+ db_dml link_content { *SQL* }
+
+ }
+ }
+
+ ad_returnredirect "$return_url"
+ ad_script_abort
+}
+
+ad_return_template
Index: openacs-4/packages/evaluation/www/evaluation-list-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/evaluation-list-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/evaluation-list-postgresql.xql 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,43 @@
+
+
+
+ postgresql 7.4
+
+
+
+
+ select eg.grade_name,
+ eg.grade_id
+ from evaluation_gradesx eg, acs_objects ao
+ where content_revision__is_live(eg.grade_id) = true
+ and eg.item_id = ao.object_id
+ and ao.context_id = :package_id
+ order by grade_name desc
+
+
+
+
+
+
+
+
+ select evaluation__class_total_grade(:user_id,:package_id)
+
+
+
+
+
+
+
+ select sum(et.weight*eg.weight)/100
+ from evaluation_gradesi eg, evaluation_tasks et, acs_objects ao
+ where eg.grade_id = et.grade_id
+ and eg.item_id = ao.object_id
+ and ao.context_id = :package_id
+ and content_revision__is_live(eg.grade_id) = true
+ and content_revision__is_live(et.task_id) = true
+
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/evaluation/www/evaluation-list.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/evaluation-list.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/evaluation-list.adp 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,13 @@
+
+@page_title;noquote@
+@context;noquote@
+
+
+
+
+ @grades.grade_name@
+
+
+
+
+@actions;noquote@
Index: openacs-4/packages/evaluation/www/evaluation-list.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/evaluation-list.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/evaluation-list.tcl 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,32 @@
+# /packages/evaluation/www/task-list.tcl
+
+ad_page_contract {
+
+ Display the evaluations for the group
+
+ @author jopez@galileo.edu
+ @creation-date Mar 2004
+ @cvs-id $Id: evaluation-list.tcl,v 1.1 2004/04/28 11:06:41 rocaelh Exp $
+
+} -query {
+ {orderby:optional}
+}
+
+set package_id [ad_conn package_id]
+set user_id [ad_conn user_id]
+set admin_p [permission::permission_p -party_id $user_id -object_id $package_id -privilege admin]
+#set admin_p 0
+
+if { $admin_p } {
+ set actions "Grade Distribution "
+} else {
+ set actions "Total current grade: [format %.2f [db_string total_grade { *SQL* }]] / [format %.2f [db_string max_grade { *SQL* }]]"
+}
+
+set page_title "Evaluations List"
+set context "Evaluations List"
+
+db_multirow grades get_grades { *SQL* } {
+}
+
+
Index: openacs-4/packages/evaluation/www/index-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/index-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/index-postgresql.xql 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,20 @@
+
+
+
+ postgresql 7.4
+
+
+
+
+ select eg.grade_name,
+ eg.grade_id
+ from evaluation_gradesx eg, acs_objects ao
+ where content_revision__is_live(eg.grade_id) = true
+ and eg.item_id = ao.object_id
+ and ao.context_id = :package_id
+ order by grade_name desc
+
+
+
+
+
Index: openacs-4/packages/evaluation/www/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/index.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/index.adp 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,34 @@
+
+@page_title;noquote@
+@context;noquote@
+
+
+ Evaluations Admin
+
+
+Tasks
+
+
+There are no tasks for this package.
+
+
+ @grades.grade_name@
+
+
+
+
+
+
+Evaluations
+
+
+There are no tasks to evaluate for this package.
+
+
+ @grades.grade_name@
+
+
+
+
+
+
Index: openacs-4/packages/evaluation/www/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/index.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/index.tcl 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,26 @@
+# /package/evaluation/www/index.tcl
+
+ad_page_contract {
+
+ Index page for evaluation package
+
+ @author jopez@galileo.edu
+ @creation-date Mar 2004
+ @cvs-id $Id: index.tcl,v 1.1 2004/04/28 11:06:41 rocaelh Exp $
+
+}
+
+set page_title "Evaluation Index"
+set context {}
+set package_id [ad_conn package_id]
+set user_id [ad_conn user_id]
+
+set admin_p [permission::permission_p -party_id $user_id -object_id $package_id -privilege admin]
+
+set package_id [ad_conn package_id]
+
+db_multirow grades get_grades { *SQL* } {
+
+}
+
+ad_return_template
\ No newline at end of file
Index: openacs-4/packages/evaluation/www/task-list-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/task-list-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/task-list-postgresql.xql 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,20 @@
+
+
+
+ postgresql 7.4
+
+
+
+
+ select eg.grade_name,
+ eg.grade_id
+ from evaluation_gradesx eg, acs_objects ao
+ where content_revision__is_live(eg.grade_id) = true
+ and eg.item_id = ao.object_id
+ and ao.context_id = :package_id
+ order by grade_name desc
+
+
+
+
+
Index: openacs-4/packages/evaluation/www/task-list.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/task-list.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/task-list.adp 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,13 @@
+
+@page_title;noquote@
+@context;noquote@
+
+
+
+
+ @grades.grade_name@
+
+
+
+
+
Index: openacs-4/packages/evaluation/www/task-list.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/task-list.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/task-list.tcl 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,30 @@
+# /packages/evaluation/www/task-list.tcl
+
+ad_page_contract {
+
+ Displays the tasks with different options depending on the user's role
+
+ @author jopez@galileo.edu
+ @creation-date Mar 2004
+ @cvs-id $Id: task-list.tcl,v 1.1 2004/04/28 11:06:41 rocaelh Exp $
+
+} -query {
+ {orderby:optional}
+}
+
+set package_id [ad_conn package_id]
+# [permission::permission_p -party_id $user_id -object_id $package_id -privilege read]
+
+db_multirow grades get_grades { *SQL* } {
+
+}
+
+set page_title "Tasks List"
+set context "Tasks List"
+
+
+ad_return_template
+
+
+
+
Index: openacs-4/packages/evaluation/www/task-view-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/task-view-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/task-view-postgresql.xql 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,26 @@
+
+
+
+ postgresql 7.4
+
+
+
+
+ select et.task_name, et.number_of_members,
+ et.due_date, et.weight, et.online_p,
+ et.late_submit_p, et.requires_grade_p,
+ et.description,
+ et.title as task_title,
+ et.data as task_data,
+ ets.title as solution_title,
+ ets.data as solution_data,
+ eg.grade_name, eg.weight as grade_weight
+ from evaluation_grades eg, evaluation_tasksi et
+ left outer join evaluation_tasks_solsi ets on (ets.task_id = et.task_id and content_revision__is_live(ets.solution_id) = true)
+ where et.task_id = :task_id
+ and et.grade_id = eg.grade_id
+
+
+
+
+
Index: openacs-4/packages/evaluation/www/task-view.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/task-view.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/task-view.adp 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,50 @@
+
+@page_title;noquote@
+@context;noquote@
+
+
+
+ Task Name
+ @task_name@
+
+
+ Description
+ @description;noquote@
+
+
+ Due Date
+ @due_date@
+
+
+ File/url associated
+ @task_url@
+
+
+ Number of Integrants
+ @number_of_members@
+
+
+ Weight
+ @weight@%
+
+
+ Grades Category
+ @grade_name@ - @grade_weight@%
+
+
+ Will this task be submitted on line?
+ @online_p@
+
+
+ Will the students be able to submit their answers after due date?
+ @late_submit_p@
+
+
+ Task Solution
+ @solution_url;noquote@
+
+
+
+
+
+
Index: openacs-4/packages/evaluation/www/task-view.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/task-view.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/task-view.tcl 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,58 @@
+# /packages/evaluation/www/task-view.tcl
+
+ad_page_contract {
+ Page for viewing tasks.
+
+ @author jopez@galileo.edu
+ @creation-date Mar 2004
+ @cvs-id $Id: task-view.tcl,v 1.1 2004/04/28 11:06:41 rocaelh Exp $
+} {
+ grade_id:integer,notnull
+ task_id:integer,notnull,optional
+ item_id:integer,notnull,optional
+}
+
+set package_id [ad_conn package_id]
+set return_url "task-list?[export_vars { grade_id }]"
+set page_title "View Task"
+
+db_1row get_grade_info { *SQL* }
+
+set context [list $page_title]
+
+db_1row get_task_info { *SQL* }
+
+if { [string eq $online_p "1"] || [string eq $online_p "t"] } {
+ set online_p "Yes"
+} else {
+ set online_p "No"
+}
+
+if { [string eq $late_submit_p "1"] || [string eq $late_submit_p "t"]} {
+ set late_submit_p "Yes"
+} else {
+ set late_submit_p "No"
+}
+
+#set description [template::util::richtext::get_property contents $description]
+# working with task stuff (if it has a file/url attached)
+if { [empty_string_p $task_data] } {
+ set task_url "No file/url associated with this task"
+} elseif { [regexp "http://" $task_data] } {
+ set task_url "$task_data "
+} else {
+ # we assume it's a file
+ set task_url "$task_title "
+}
+
+# working with task soluiton stuff (if it has a file/url attached)
+if { [empty_string_p $solution_data] } {
+ set solution_url "No file/url associated with this task solution"
+} elseif { [regexp "http://" $solution_data] } {
+ set solution_url "$solution_data "
+} else {
+ # we assume it's a file
+ set solution_url "$solution_title "
+}
+
+ad_return_template
Index: openacs-4/packages/evaluation/www/task-view.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/task-view.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/task-view.xql 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,14 @@
+
+
+
+ postgresql 7.4
+
+
+
+
+ select grade_name, weight as grade_weight from evaluation_grades where grade_id = :grade_id
+
+
+
+
+
Index: openacs-4/packages/evaluation/www/admin/index-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/admin/index-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/admin/index-postgresql.xql 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,20 @@
+
+
+
+ postgresql 7.4
+
+
+
+
+ select eg.grade_name,
+ eg.grade_id
+ from evaluation_gradesx eg, acs_objects ao
+ where content_revision__is_live(eg.grade_id) = true
+ and eg.item_id = ao.object_id
+ and ao.context_id = :package_id
+ order by grade_name desc
+
+
+
+
+
Index: openacs-4/packages/evaluation/www/admin/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/admin/index.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/admin/index.adp 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,39 @@
+
+@page_title;noquote@
+@context;noquote@
+
+Assignment Types
+
+
+Tasks
+
+
+There are no tasks for this package.
+
+
+ @grades.grade_name@
+
+
+
+
+
+
+Evaluations
+
+
+There are no tasks to evaluate for this package.
+
+
+ @grades.grade_name@
+
+
+
+
+
+
+Grades Reports
+
\ No newline at end of file
Index: openacs-4/packages/evaluation/www/admin/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/admin/index.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/admin/index.tcl 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,23 @@
+# /package/evaluation/www/index.tcl
+
+ad_page_contract {
+
+ Index page for evaluation package
+
+ @author jopez@galileo.edu
+ @creation-date Mar 2004
+ @cvs-id $Id: index.tcl,v 1.1 2004/04/28 11:06:41 rocaelh Exp $
+
+}
+
+set page_title "Evaluation Index"
+set context {}
+
+set package_id [ad_conn package_id]
+# [permission::permission_p -party_id $user_id -object_id $package_id -privilege read]
+
+db_multirow grades get_grades { *SQL* } {
+
+}
+
+ad_return_template
\ No newline at end of file
Index: openacs-4/packages/evaluation/www/admin/evaluations/audit-info-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/admin/evaluations/audit-info-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/admin/evaluations/audit-info-postgresql.xql 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,18 @@
+
+
+
+ postgresql 7.4
+
+
+
+
+ select evaluation__party_name(ese.party_id,ese.task_id) as party_name,
+ ese.party_id
+ from evaluation_student_evals ese
+ where content_revision__is_live(ese.evaluation_id) = true
+ and ese.task_id = :task_id
+
+
+
+
+
Index: openacs-4/packages/evaluation/www/admin/evaluations/audit-info.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/admin/evaluations/audit-info.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/admin/evaluations/audit-info.adp 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,16 @@
+
+@page_title;noquote@
+@context;noquote@
+
+Audit info for task "@task_name@"
+
+
+
+ @parties.party_name@
+
+
+
+
+
+
+
Index: openacs-4/packages/evaluation/www/admin/evaluations/audit-info.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/admin/evaluations/audit-info.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/admin/evaluations/audit-info.tcl 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,24 @@
+# /packages/evaluation/www/admin/evaluations/audit-info.tcl
+
+ad_page_contract {
+
+ Shows the audit info for a given task
+
+ @author jopez
+ @creation-date Apr 2004
+ @cvs-id $Id: audit-info.tcl,v 1.1 2004/04/28 11:06:41 rocaelh Exp $
+
+} {
+ task_id:integer,notnull
+}
+
+db_1row get_task_info { *SQL* }
+set page_title "Audit info for task"
+set context [list "Audit Info"]
+
+db_multirow parties get_parties { *SQL* } {
+
+
+}
+
+ad_return_template
Index: openacs-4/packages/evaluation/www/admin/evaluations/audit-info.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/admin/evaluations/audit-info.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/admin/evaluations/audit-info.xql 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,14 @@
+
+
+
+ postgresql 7.4
+
+
+
+
+ select task_name from evaluation_tasks where task_id = :task_id
+
+
+
+
+
Index: openacs-4/packages/evaluation/www/admin/evaluations/evaluate-students-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/admin/evaluations/evaluate-students-2.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/admin/evaluations/evaluate-students-2.tcl 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,150 @@
+# /packages/evaluation/www/admin/evaluations/evaluate-students-2.tcl
+
+ad_page_contract {
+ This page asks for an evaluation confirmation
+
+ @author jopez@galileo.edu
+ @creation-date Mar 2004
+} {
+ task_id:integer,notnull
+ grade_id:integer,notnull,optional
+ max_grade:integer,notnull,optional
+ item_ids:array,integer,optional
+ item_to_edit_ids:array,optional
+
+ grades_to_edit:array,optional
+ reasons_to_edit:array,optional
+ show_student_to_edit:array,optional
+
+ grades_wa:array,optional
+ comments_wa:array,optional
+ show_student_wa:array,optional
+
+ grades_na:array,optional
+ comments_na:array,optional
+ show_student_na:array,optional
+
+ {return_url "student-list?[export_vars -url { task_id }]"}
+} -validate {
+ valid_grades_wa {
+ set counter 0
+ foreach party_id [array names grades_wa] {
+ if { [info exists grades_wa($party_id)] && ![empty_string_p $grades_wa($party_id)] } {
+ incr counter
+ if { ![ad_var_type_check_number_p $grades_wa($party_id)] } {
+ ad_complain "The grade most be a valid number ($grades_wa($party_id))"
+ }
+ }
+ }
+ if { !$counter && ([array size show_student_wa] > 0) } {
+ ad_complain "There must be at least one grade to work with"
+ }
+ }
+ valid_grades_na {
+ set counter 0
+ foreach party_id [array names grades_na] {
+ if { [info exists grades_na($party_id)] && ![empty_string_p $grades_na($party_id)]} {
+ incr counter
+ if { ![ad_var_type_check_number_p $grades_na($party_id)] } {
+ ad_complain "The grade most be a valid number ($grades_na($party_id))"
+ }
+ }
+ }
+ if { !$counter && ([array size show_student_na] > 0) } {
+ ad_complain "There must be at least one grade to work with"
+ }
+ }
+ valid_grades {
+ set counter 0
+ foreach party_id [array names grades_to_edit] {
+ if { [info exists grades_to_edit($party_id)] && ![empty_string_p $grades_to_edit($party_id)] } {
+ incr counter
+ if { ![ad_var_type_check_number_p $grades_to_edit($party_id)] } {
+ ad_complain "The grade most be a valid number ($grades_to_edit($party_id))"
+ }
+ }
+ }
+ if { !$counter && ([array size show_student_to_edit] > 0) } {
+ ad_complain "There must be at least one grade to work with"
+ }
+ }
+ valid_data {
+ foreach party_id [array names comments_wa] {
+ if { [info exists comments_wa($party_id)] && ![info exists grades_wa($party_id)] } {
+ ad_complain "There is a comment for a grade not realized ($comments_wa($party_id))"
+ }
+ if { [info exists comments_wa($party_id)] && ([string length $comments_wa($party_id)] > 400) } {
+ ad_complain "There is a comment larger than we can handle. ($comments_wa($party_id))"
+ }
+ }
+ foreach party_id [array names comments_na] {
+ if { [info exists comments_na($party_id)] && ![info exists grades_na($party_id)] } {
+ ad_complain "There is a comment for a grade not realized ($comments_na($party_id))"
+ }
+ if { [info exists comments_na($party_id)] && ([string length $comments_na($party_id)] > 400) } {
+ ad_complain "There is a comment larger than we can handle. ($comments_na($party_id))"
+ }
+ }
+ foreach party_id [array names reasons_to_edit] {
+ if { [info exists reasons_to_edit($party_id)] && ![info exists grades_to_edit($party_id)] } {
+ ad_complain "There is an edit reason for a grade not realized ($reasons_to_edit($party_id))"
+ }
+ if { [info exists reasons_to_edit($party_id)] && ([string length $reasons_to_edit($party_id)] > 400) } {
+ ad_complain "There is an edit reason larger than we can handle. ($reasons_to_edit($party_id))"
+ }
+ }
+ }
+}
+
+db_transaction {
+ foreach party_id [array names grades_wa] {
+ if { ![info exists comments_wa($party_id)] } {
+ set comments_wa($party_id) ""
+ } else {
+ set comments_wa($party_id) [DoubleApos $comments_wa($party_id)]
+ }
+
+ if { [info exists grades_wa($party_id)] && ![empty_string_p $grades_wa($party_id)] } {
+ set grades_wa($party_id) [expr ($grades_wa($party_id)*100)/$max_grade.0]
+ set revision_id [evaluation::new_evaluation -new_item_p 1 -item_id $item_ids($party_id) -content_type evaluation_student_evals \
+ -content_table evaluation_student_evals -content_id evaluation_id -description $comments_wa($party_id) \
+ -show_student_p $show_student_wa($party_id) -grade $grades_wa($party_id) -task_id $task_id -party_id $party_id]
+
+ evaluation::set_live -revision_id $revision_id
+ }
+ }
+}
+
+db_transaction {
+ foreach party_id [array names grades_na] {
+ if { ![info exists comments_na($party_id)] } {
+ set comments_na($party_id) ""
+ } else {
+ set comments_na($party_id) [DoubleApos $comments_na($party_id)]
+ }
+ if { [info exists grades_na($party_id)] && ![empty_string_p $grades_na($party_id)] } {
+ set grades_na($party_id) [expr ($grades_na($party_id)*100)/$max_grade.0]
+ set revision_id [evaluation::new_evaluation -new_item_p 1 -item_id $item_ids($party_id) -content_type evaluation_student_evals \
+ -content_table evaluation_student_evals -content_id evaluation_id -description $comments_na($party_id) \
+ -show_student_p $show_student_na($party_id) -grade $grades_na($party_id) -task_id $task_id -party_id $party_id]
+
+ evaluation::set_live -revision_id $revision_id
+ }
+ }
+}
+
+db_transaction {
+ foreach party_id [array names grades_to_edit] {
+ if { [info exists grades_to_edit($party_id)] && ![empty_string_p $grades_to_edit($party_id)] } {
+ set grades_to_edit($party_id) [expr ($grades_to_edit($party_id)*100)/$max_grade.0]
+ set revision_id [evaluation::new_evaluation -new_item_p 0 -item_id $item_to_edit_ids($party_id) -content_type evaluation_student_evals \
+ -content_table evaluation_student_evals -content_id evaluation_id -description $reasons_to_edit($party_id) \
+ -show_student_p $show_student_to_edit($party_id) -grade $grades_to_edit($party_id) -task_id $task_id -party_id $party_id]
+
+ evaluation::set_live -revision_id $revision_id
+ }
+ }
+}
+
+ad_returnredirect "$return_url"
+
Index: openacs-4/packages/evaluation/www/admin/evaluations/evaluate-students-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/admin/evaluations/evaluate-students-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/admin/evaluations/evaluate-students-postgresql.xql 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,14 @@
+
+
+
+ postgresql 7.4
+
+
+
+
+ select evaluation__party_name(:party_id,:task_id)
+
+
+
+
+
Index: openacs-4/packages/evaluation/www/admin/evaluations/evaluate-students.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/admin/evaluations/evaluate-students.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/evaluation/www/admin/evaluations/evaluate-students.adp 28 Apr 2004 11:06:41 -0000 1.1
@@ -0,0 +1,78 @@
+
+@page_title;noquote@
+@context;noquote@
+
+Confirm your evaluation(s) on "@task_name@"
+
+
+