Index: openacs-4/packages/evaluation/evaluation.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/evaluation.info,v diff -u -r1.7 -r1.8 --- openacs-4/packages/evaluation/evaluation.info 31 May 2004 17:04:57 -0000 1.7 +++ openacs-4/packages/evaluation/evaluation.info 7 Jun 2004 16:04:48 -0000 1.8 @@ -17,10 +17,12 @@ - + + + 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 -r1.2 -r1.3 --- openacs-4/packages/evaluation/lib/evaluations-chunk.tcl 31 May 2004 17:04:57 -0000 1.2 +++ openacs-4/packages/evaluation/lib/evaluations-chunk.tcl 7 Jun 2004 16:04:53 -0000 1.3 @@ -26,7 +26,7 @@ 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 }]] + set actions [list "Edit grades distribution of $grade_plural_name" [export_vars -base "${base_url}admin/grades/distribution-edit" { grade_id }]] } else { #student lappend elements grade \ @@ -91,7 +91,7 @@ if { ![empty_string_p $grade] } { set grade [format %.2f $grade] - set over_weight "[format %.2f $task_grade] /" + set over_weight "[format %.2f $task_grade]/" set total_grade [expr $total_grade + $task_grade] } else { set grade "Not evaluated" @@ -101,7 +101,7 @@ } else { set grade "Not available" } - set task_weight "$over_weight [format %.2f $task_weight]" + set task_weight "${over_weight}[format %.2f $task_weight]" # working with answer stuff (if it has a file/url attached) if { [empty_string_p $answer_data] } { @@ -126,8 +126,8 @@ } if { $admin_p } { - set bottom_line "Weight used in $grade_name: ${category_weight}% (of 100% of $grade_name)
- $grade_name represents ${grade_weight}% of the 100% of the class
" + set bottom_line "Weight used in $grade_plural_name: ${category_weight}% (of 100% of $grade_plural_name)
+ $grade_plural_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 -r1.1 -r1.2 --- openacs-4/packages/evaluation/lib/evaluations-chunk.xql 28 Apr 2004 11:06:40 -0000 1.1 +++ openacs-4/packages/evaluation/lib/evaluations-chunk.xql 7 Jun 2004 16:04:53 -0000 1.2 @@ -6,7 +6,7 @@ - select grade_name, weight as grade_weight from evaluation_grades where grade_id = :grade_id + select grade_plural_name, weight as grade_weight from evaluation_grades where grade_id = :grade_id 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 -r1.2 -r1.3 --- openacs-4/packages/evaluation/lib/tasks-chunk-postgresql.xql 31 May 2004 17:04:57 -0000 1.2 +++ openacs-4/packages/evaluation/lib/tasks-chunk-postgresql.xql 7 Jun 2004 16:04:53 -0000 1.3 @@ -55,10 +55,10 @@ - + - select grade_name from evaluation_grades where grade_id = :grade_id + select grade_name, grade_plural_name, grade_name from evaluation_grades where grade_id = :grade_id 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 -r1.2 -r1.3 --- openacs-4/packages/evaluation/lib/tasks-chunk.tcl 31 May 2004 17:04:57 -0000 1.2 +++ openacs-4/packages/evaluation/lib/tasks-chunk.tcl 7 Jun 2004 16:04:53 -0000 1.3 @@ -8,7 +8,7 @@ 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 grade_name [db_string grade_name { *SQL* }] +db_1row grade_names { *SQL* } set base_url [ad_conn package_url] set mode display 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 -r1.4 -r1.5 --- openacs-4/packages/evaluation/sql/postgresql/evaluation-create.sql 31 May 2004 17:04:57 -0000 1.4 +++ openacs-4/packages/evaluation/sql/postgresql/evaluation-create.sql 7 Jun 2004 16:04:53 -0000 1.5 @@ -7,6 +7,7 @@ constraint evaluation_grades_id_fk references cr_revisions(revision_id), grade_name varchar(100), + grade_plural_name varchar(100), comments text, -- percentage of this grade type in the class weight numeric @@ -70,23 +71,6 @@ 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 ( - package_id integer - constraint evaluations_tasks_cmap_cid_fk - references apm_packages, - revision_id integer - constraint evaluations_tasks_cmap_fid_fk - references cr_revisions, - constraint evaluaition_tasks_cmap_pk - primary key (package_id, revision_id) -); - create table evaluation_tasks_sols ( solution_id integer primary key, @@ -313,22 +297,23 @@ -- GRADES --------------------------------------- -create function evaluation__new_grade (integer, integer, varchar, numeric, varchar, timestamptz, integer, varchar, varchar, varchar, timestamptz, varchar, varchar) +create function evaluation__new_grade (integer, integer, varchar, varchar, 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_weight 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_description alias for $10; -- default null - p_publish_date alias for $11; - p_nls_language alias for $12; -- default null - p_mime_type alias for $13; -- default null + p_grade_plural_name 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; @@ -351,12 +336,14 @@ insert into evaluation_grades (grade_id, - grade_name, + grade_name, + grade_plural_name, comments, weight) values (v_revision_id, p_grade_name, + p_grade_plural_name, p_description, p_weight); 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 -r1.4 -r1.5 --- openacs-4/packages/evaluation/sql/postgresql/evaluation-drop.sql 31 May 2004 17:04:57 -0000 1.4 +++ openacs-4/packages/evaluation/sql/postgresql/evaluation-drop.sql 7 Jun 2004 16:04:54 -0000 1.5 @@ -149,8 +149,6 @@ drop view evaluation_answersx; drop table evaluation_answers; -drop table evaluation_tasks_class_map; - drop table evaluation_task_groups; drop view evaluation_tasksi; @@ -167,7 +165,7 @@ -- GRADES --------------------------------------- -drop function evaluation__new_grade (integer, integer, varchar, numeric, varchar, timestamptz, integer, varchar, varchar, varchar, timestamptz, varchar, varchar); +drop function evaluation__new_grade (integer, integer, varchar, varchar, numeric, varchar, timestamptz, integer, varchar, varchar, varchar, timestamptz, varchar, varchar); drop function evaluation__delete_grade (integer); 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 -r1.4 -r1.5 --- openacs-4/packages/evaluation/tcl/evaluation-procs-postgresql.xql 31 May 2004 17:04:57 -0000 1.4 +++ openacs-4/packages/evaluation/tcl/evaluation-procs-postgresql.xql 7 Jun 2004 16:05:06 -0000 1.5 @@ -33,6 +33,7 @@ :item_id, :revision_id, :name, + :plural_name, :weight, 'evaluation_grades', now(), --creation date @@ -58,6 +59,96 @@ + + + + select et.task_name, + et.number_of_members, + et.due_date, + et.weight, + et.online_p, + et.late_submit_p, + et.requires_grade_p, + crr.lob, crr.content, + crr.content_length, + crr.title, + crr.description, + crr.mime_type, + cri.storage_type + from evaluation_tasksi et, + cr_revisions crr, + cr_items cri + where task_id = :from_task_id + and et.task_id = crr.revision_id + and cri.item_id = crr.item_id + + + + + + + + select coalesce((select evaluation__new_item ( + :item_id, --item_id + :item_name, + null, --locale + :creation_user, + :to_package_id, + :creation_ip, + :task_name, + :description, + :mime_type, --mime_type + null, --nls_language + null, --text + :storage_type, --storage_type + 'content_item', -- item_subtype + 'evaluation_tasks' -- content_type + ) + where not exists (select 1 from cr_items where item_id = :item_id)),0) + + + + + + + + select evaluation__new_task ( + :item_id, + :revision_id, + :task_name, + :number_of_members, + :to_grade_id, + :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_revisions + set content = :content, + content_length = :content_length, + lob = :lob + where revision_id = :revision_id + + + + @@ -89,6 +180,7 @@ :revision_id, :name, :number_of_members, + :grade_id, :description, :weight, :due_date, @@ -459,6 +551,7 @@ select evaluation__new_grade ( :exams_item_id, :exams_revision_id, + 'Exam', 'Exams', 40, 'evaluation_grades', @@ -513,6 +606,7 @@ select evaluation__new_grade ( :projects_item_id, :projects_revision_id, + 'Project', 'Projects', 20, 'evaluation_grades', @@ -568,7 +662,8 @@ select evaluation__new_grade ( :tasks_item_id, :tasks_revision_id, - 'Tasks', + 'Task', + 'Tasks', 40, 'evaluation_grades', now(), --creation date @@ -668,5 +763,43 @@ + + + + + select evaluation__party_name(ea.party_id, ea.task_id) as party_name, + ea.title as answer_title, + ea.revision_id, + cri.storage_type + from evaluation_answersi ea, + evaluation_tasks et, + cr_items cri + where ea.task_id = et.task_id + and ea.item_id = cri.item_id + and et.task_id = :task_id + and ea.data is not null + and content_revision__is_live(ea.answer_id) = true + and not exists (select 1 from evaluation_student_evals ese where ese.party_id = ea.party_id and ese.task_id = :task_id and content_revision__is_live(ese.evaluation_id) = true) + + + + + + + + select content_revision__get_content(:revision_id) + + + + + + + + select lob + from cr_revisions + where revision_id = :revision_id + + + 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 -r1.5 -r1.6 --- openacs-4/packages/evaluation/tcl/evaluation-procs.tcl 31 May 2004 17:04:57 -0000 1.5 +++ openacs-4/packages/evaluation/tcl/evaluation-procs.tcl 7 Jun 2004 16:05:06 -0000 1.6 @@ -114,6 +114,7 @@ -description:required -weight:required -name:required + -plural_name:required } { Build a new content revision of a evaluation subtype. If new_item_p is @@ -190,6 +191,36 @@ return [eval template::util::date::create $now] } +ad_proc -public evaluation::clone_task { + -item_id:required + -from_task_id:required + -to_grade_id:required + -to_package_id:required +} { + Cone a task + + @param item_id The item to create. + @param from_task_id Task to clon. + @param to_grade_id Grade that will "own" the task +} { + + db_1row from_task_info { *SQL* } + + set creation_user [ad_conn user_id] + set creation_ip [ad_conn peeraddr] + + set item_name "${item_id}_${title}" + + set revision_id [db_nextval acs_object_id_seq] + + db_exec_plsql content_item_new { *SQL* } + + db_exec_plsql content_revision_new { *SQL* } + + db_dml clone_content { *SQL* } + return $revision_id +} + ad_proc -public evaluation::new_task { -item_id:required -content_type:required @@ -232,7 +263,7 @@ } { set package_id [ad_conn package_id] - set creation_user [ad_verify_and_get_user_id] + set creation_user [ad_conn user_id] set creation_ip [ad_conn peeraddr] if { [empty_string_p $item_name] } { @@ -243,7 +274,6 @@ if { $new_item_p } { db_exec_plsql content_item_new { *SQL* } - } db_exec_plsql content_revision_new { *SQL* } @@ -721,5 +751,74 @@ } } +ad_proc -public evaluation::get_archive_command { + {-in_file ""} + {-out_file ""} +} { + return the archive command after replacing {in_file} and {out_file} with + their respective values. +} { + set cmd [parameter::get -parameter ArchiveCommand -default "cat `find {in_file} -type f` > {out_file}"] + + regsub -all {(\W)} $in_file {\\\1} in_file + regsub -all {\\/} $in_file {/} in_file + regsub -all {\\\.} $in_file {.} in_file + + regsub -all {(\W)} $out_file {\\\1} out_file + regsub -all {\\/} $out_file {/} out_file + regsub -all {\\\.} $out_file {.} out_file + + regsub -all {{in_file}} $cmd $in_file cmd + regsub -all {{out_file}} $cmd $out_file cmd + + return $cmd +} + +ad_proc -public evaluation::public_answers_to_file_system { + -task_id:required + -path:required + -folder_name:required +} { + Writes all the answers of a given task in the file sytem. +} { + + set dir [file join ${path} ${folder_name}] + file mkdir $dir + + db_foreach get_answers_for_task { *SQL* } { + if { [string eq $storage_type "lob"] } { + # it is a file + + regsub -all {[<>:\"|/@\\\#%&+\\ ,]} $party_name {_} file_name + append file_name [file extension $answer_title] + + db_blob_get_file select_object_content { *SQL* } -file [file join ${dir} ${file_name}] + + } else { + # it is a url + + set url [db_string url { *SQL* }] + + + set file_name "${party_name}.url" + + regsub -all {[<>:\"|/@\\\#%&+\\ ,]} $file_name {_} file_name + set fp [open [file join ${dir} ${file_name}] w] + puts $fp {[InternetShortcut]} + puts $fp URL=$url + close $fp + } + } + + return $dir +} + +ad_proc -public evaluation::get_archive_extension {} { + return the archive extension that should be added to the output file of + an archive command +} { + return [parameter::get -parameter ArchiveExtension -default "txt"] +} + ad_register_proc GET /grades-sheet-csv* evaluation::generate_grades_sheet ad_register_proc POST /grades-sheet-csv* evaluation::generate_grades_sheet 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 -r1.3 -r1.4 --- openacs-4/packages/evaluation/www/answer-add-edit.tcl 31 May 2004 17:04:57 -0000 1.3 +++ openacs-4/packages/evaluation/www/answer-add-edit.tcl 7 Jun 2004 16:05:06 -0000 1.4 @@ -14,7 +14,13 @@ upload_file:trim,optional upload_file.tmpfile:tmpfile,optional return_url:notnull -} +} -validate { + late_submit { + if { ([template::util::date::compare [db_string due_date "select due_date from evaluation_tasks where task_id = :task_id"] [template::util::date::now]] < 0) } { + ad_complain "tarde manin" + } + } +} set user_id [ad_conn user_id] set party_id [db_string get_party_id { *SQL* }] @@ -56,14 +62,14 @@ 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} - } + {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 { 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 -r1.1 -r1.2 --- openacs-4/packages/evaluation/www/evaluation-list-postgresql.xql 28 Apr 2004 11:06:41 -0000 1.1 +++ openacs-4/packages/evaluation/www/evaluation-list-postgresql.xql 7 Jun 2004 16:05:07 -0000 1.2 @@ -6,13 +6,13 @@ - select eg.grade_name, + select eg.grade_plural_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 + order by grade_plural_name desc 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 -r1.1 -r1.2 --- openacs-4/packages/evaluation/www/evaluation-list.adp 28 Apr 2004 11:06:41 -0000 1.1 +++ openacs-4/packages/evaluation/www/evaluation-list.adp 7 Jun 2004 16:05:07 -0000 1.2 @@ -5,7 +5,7 @@