Index: openacs-4/packages/evaluation-portlet/tcl/test/tclwebtest-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation-portlet/tcl/test/tclwebtest-procs.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/evaluation-portlet/tcl/test/tclwebtest-procs.tcl 10 Jul 2018 15:33:21 -0000 1.7 +++ openacs-4/packages/evaluation-portlet/tcl/test/tclwebtest-procs.tcl 3 Sep 2024 15:37:38 -0000 1.8 @@ -9,23 +9,23 @@ namespace eval evaluation::twt {} ad_proc -private evaluation::twt::create_file {file_name} { - + # Create a temporal file - set file_name "/tmp/$file_name" - exec touch $file_name - exec ls / >> $file_name - exec chmod 777 $file_name + set file_name "[ad_tmpdir]/$file_name" + exec [::util::which touch] $file_name + exec [::util::which ls] / >> $file_name + exec [::util::which chmod] 777 $file_name return $file_name } ad_proc -private evaluation::twt::delete_file {file_name} { - # Delete a file name + # Delete a filename file delete -force -- $file_name } ad_proc -private evaluation::twt::get_notification_ids { pretty_name } { - + # Get the notification ids : type_id, object_id and user_id set link [lindex [tclwebtest::link find ~u "(.+)request-new\?(.*)pretty(.+)name=$pretty_name\(.+)"] 7] @@ -37,11 +37,11 @@ } ad_proc -private evaluation::twt::get_task_grade_id { task_name } { - + db_1row task_id "select task_id from evaluation_tasks where task_name=:task_name" db_1row grade_item_id "select grade_item_id from evaluation_tasks where task_name=:task_name" db_1row grade_id "select grade_id from evaluation_grades where grade_item_id=:grade_item_id" - + return [list $task_id $grade_id] } @@ -53,41 +53,41 @@ ::twt::do_request $dotlrn_admin_page_url # tclwebtest::link follow "Classes" - - # Create a new class + + # Create a new class tclwebtest::link follow "Subjects" tclwebtest::link follow {New Class} - - set pretty_name [ad_generate_random_string] + + set pretty_name [ad_generate_random_string] tclwebtest::form find ~n "add_class_instance" tclwebtest::field find ~n pretty_name - tclwebtest::field fill $pretty_name + tclwebtest::field fill $pretty_name tclwebtest::field find ~n description tclwebtest::field fill [ad_generate_random_string] tclwebtest::field find ~n add_instructor tclwebtest::field select -index 1 tclwebtest::field find ~n class_instance_key tclwebtest::field fill [ad_generate_random_string] tclwebtest::form submit - aa_log "Add Class Form submited" - + aa_log "Add Class Form submitted" + tclwebtest::link follow $pretty_name - + if { [catch {tclwebtest::assert text {Class Material} } errmsg] } { - tclwebtest::link follow ~u ".*one-community-admin" + tclwebtest::link follow ~u ".*one-community-admin" tclwebtest::link follow {Manage Applets} set add_evaluation_applet_url [export_vars -base "applet-add" {{applet_key "dotlrn_evaluation"}}] ::twt::do_request $add_evaluation_applet_url - } + } tclwebtest::link follow {Class Material} set class_material_url [tclwebtest::response url] - - return $class_material_url + + return $class_material_url } ad_proc -private evaluation::twt::add_task { class_material_url task_name task_description file_name } { - + set response 0 ::twt::do_request $class_material_url @@ -101,12 +101,12 @@ tclwebtest::field find ~n "description" tclwebtest::field fill $task_description tclwebtest::form submit - aa_log "Add Task form submited" + aa_log "Add Task form submitted" set response_url [tclwebtest::response url] if { [string match $class_material_url $response_url] } { - + if { [catch {tclwebtest::link find $task_name} errmsg] } { aa_error "evaluation::twt::add_task failed $errmsg : Didn't add a New Task" } else { @@ -126,33 +126,33 @@ set response 0 ::twt::do_request $class_material_url - - # Get the task and the grade id + + # Get the task and the grade id set list_ids [evaluation::twt::get_task_grade_id $task_name] set task_id [lindex $list_ids 0] set grade_id [lindex $list_ids 1] - + # Follow Upload Solution link tclwebtest::link follow ~u "(.+)solution-add-edit\?(.*)solution(.+)mode=edit(.+)task(.+)id=$task_id\(.+)grade(.+)id=$grade_id" - + tclwebtest::form find ~n "solution" tclwebtest::field find ~n "upload_file" tclwebtest::field fill $file_name tclwebtest::form submit ~n "formbutton:ok" - aa_log "Add Task form submited" + aa_log "Add Task form submitted" set response_url [tclwebtest::response url] - + if {[string match $class_material_url $response_url] } { - + if { [catch {set true 1} errmsg] } { aa_error "evaluation::twt::upload_task_solution failed $errmsg : Didn't upload a Task Solution" } else { aa_log "a New Task Solution uploaded" set response 1 } - + } else { aa_error "evaluation::twt::upload_task_solution failed, bad response url : $response_url" } @@ -173,14 +173,14 @@ # Follow Upload Solution link tclwebtest::link follow ~u "(.+)solution-add-edit\?(.*)solution(.+)mode=display(.+)task(.+)id=$task_id\(.+)grade(.+)id=$grade_id" - + set response_url [tclwebtest::response url] if { [string match "*/classes/*/evaluation/admin/tasks/solution-add-edit*" $response_url] } { set list_words [split "$file_name" /] set short_file_name [lindex $list_words [llength $list_words]-1] - + if { [catch {tclwebtest::assert text "$short_file_name" } errmsg] } { aa_error "evaluation::twt::view_task_solution failed $errmsg : Didn't view a Task Solution" } else { @@ -211,13 +211,13 @@ tclwebtest::form find ~n "solution" tclwebtest::form submit - + tclwebtest::form find ~n "solution" tclwebtest::field find ~n "upload_file" tclwebtest::field fill $file_name tclwebtest::form submit ~n "formbutton:ok" - aa_log "Edit Task form submited" - + aa_log "Edit Task form submitted" + set response_url [tclwebtest::response url] if { [string match "$class_material_url" $response_url] } { @@ -228,7 +228,7 @@ aa_log "a Task Solution edited" set response 1 } - + } else { aa_error "evaluation::twt::edit_task_solution failed, bad response url : $response_url" } @@ -239,7 +239,7 @@ ad_proc -private evaluation::twt::view_task { class_material_url task_name task_description file_name} { set response 0 - + ::twt::do_request $class_material_url # Get the task and the grade id @@ -249,7 +249,7 @@ # Follow Upload Solution link tclwebtest::link follow ~u "(.+)task-add-edit\?(.*)mode=display(.+)task(.+)id=$task_id\(.+)grade(.+)id=$grade_id" - + set response_url [tclwebtest::response url] if {[string match "*task-add-edit*$task_id*$grade_id" $response_url] } { @@ -258,9 +258,9 @@ set short_file_name [lindex $list_words [llength $list_words]-1] if { [catch {tclwebtest::assert text "$task_name" } errmsg] || [catch {tclwebtest::assert text "$task_description" } errmsg] || [catch {tclwebtest::assert text "$short_file_name" } errmsg] } { - + aa_error "evaluation::twt::view_task failed $errmsg : Didn't view a Task" - + } else { aa_log "a Task viewed" set response 1 @@ -269,12 +269,12 @@ } else { aa_error "evaluation::twt::view_task failed, bad response url : $response_url" } - + return $response } ad_proc -private evaluation::twt::edit_task { class_material_url precedent_task_name task_name task_description file_name } { - + set response 0 ::twt::do_request $class_material_url @@ -298,18 +298,18 @@ tclwebtest::field find ~n "description" tclwebtest::field fill $task_description tclwebtest::form submit ~n "formbutton:ok" - aa_log "Edit Task form submited" + aa_log "Edit Task form submitted" set response_url [tclwebtest::response url] - + if {[string match $class_material_url $response_url] } { set list_words [split "$file_name" /] set short_file_name [lindex $list_words [llength $list_words]-1] if {[catch {tclwebtest::assert text "$task_name" } errmsg]} { aa_error "evaluation::twt::edit_task failed $errmsg : Didn't edit a Task" - + } else { aa_log "a Task edited" set response 1 @@ -327,7 +327,7 @@ set response 0 ::twt::do_request $class_material_url - + # Get the task and the grade id set list_ids [evaluation::twt::get_task_grade_id $task_name] set task_id [lindex $list_ids 0] @@ -338,7 +338,7 @@ tclwebtest::form find ~a "task-delete-2" tclwebtest::form submit {Yes, I really want to remove this task} - + set response_url [tclwebtest::response url] if {[string match "$class_material_url" $response_url] } { @@ -372,8 +372,8 @@ tclwebtest::field find ~n "description" tclwebtest::field fill $project_description tclwebtest::form submit - aa_log "Add Task form submited" - + aa_log "Add Task form submitted" + set response_url [tclwebtest::response url] if { [string match $class_material_url $response_url] } { @@ -411,7 +411,7 @@ tclwebtest::field fill $file_name tclwebtest::form submit ~n "formbutton:ok" - aa_log "Add Task form submited" + aa_log "Add Task form submitted" set response_url [tclwebtest::response url] @@ -487,7 +487,7 @@ tclwebtest::field find ~n "upload_file" tclwebtest::field fill $file_name tclwebtest::form submit ~n "formbutton:ok" - aa_log "Edit Task form submited" + aa_log "Edit Task form submitted" set response_url [tclwebtest::response url] @@ -570,7 +570,7 @@ tclwebtest::field fill $project_description tclwebtest::form submit - aa_log "Edit Task form submited" + aa_log "Edit Task form submitted" set response_url [tclwebtest::response url] @@ -643,7 +643,7 @@ tclwebtest::field find ~n "description" tclwebtest::field fill $exam_description tclwebtest::form submit - aa_log "Add Exam form submited" + aa_log "Add Exam form submitted" set response_url [tclwebtest::response url] @@ -683,7 +683,7 @@ tclwebtest::field fill $file_name tclwebtest::form submit ~n "formbutton:ok" - aa_log "Add Task form submited" + aa_log "Add Task form submitted" set response_url [tclwebtest::response url] @@ -751,15 +751,15 @@ # Follow Upload Solution link tclwebtest::link follow ~u "(.+)solution-add-edit\?(.*)solution(.+)mode=display(.+)task(.+)id=$task_id\(.+)grade(.+)id=$grade_id" - + tclwebtest::form find ~n "solution" tclwebtest::form submit tclwebtest::form find ~n "solution" tclwebtest::field find ~n "upload_file" tclwebtest::field fill $file_name tclwebtest::form submit ~n "formbutton:ok" - aa_log "Edit Task form submited" + aa_log "Edit Task form submitted" set response_url [tclwebtest::response url] @@ -821,7 +821,7 @@ set response 0 ::twt::do_request $class_material_url - + # Get the task and the grade id set list_ids [evaluation::twt::get_task_grade_id $precedent_exam_name] set task_id [lindex $list_ids 0] @@ -842,7 +842,7 @@ tclwebtest::field fill $exam_description tclwebtest::form submit - aa_log "Edit Task form submited" + aa_log "Edit Task form submitted" set response_url [tclwebtest::response url] @@ -872,7 +872,7 @@ set response 0 ::twt::do_request $class_material_url - + # Get the task and the grade id set list_ids [evaluation::twt::get_task_grade_id $exam_name] set task_id [lindex $list_ids 0] @@ -904,14 +904,14 @@ ad_proc -private evaluation::twt::request_notification_Evaluation { class_material_url } { - + set response 0 - + ::twt::do_request $class_material_url - + # Get the notification ids : type_id, object_id and user_id set list_ids [evaluation::twt::get_notification_ids "Evaluations"] - + # Follow Request Evaluation Notification link tclwebtest::link follow ~u {(.+)pretty(.+)Evaluations(.+)} tclwebtest::form find ~n "subscribe" @@ -929,7 +929,7 @@ } } else { - aa_error "evaluation::twt:::request_notification_Evaluation failed, bad response url : $response_url" + aa_error "evaluation::twt::request_notification_Evaluation failed, bad response url : $response_url" } return [lappend list_ids $response] @@ -939,7 +939,7 @@ set response 0 ::twt::do_request $class_material_url - + # Get the notification ids : type_id, object_id and user_id set list_ids [evaluation::twt::get_notification_ids "Gradebook"] @@ -960,7 +960,7 @@ } } else { - aa_error "evaluation::twt:::request_notification_GradeBook failed, bad response url : $response_url" + aa_error "evaluation::twt::request_notification_GradeBook failed, bad response url : $response_url" } return [lappend list_ids $response] @@ -991,7 +991,7 @@ } } else { - aa_error "evaluation::twt::::unsubscribe_GradeBook failed, bad response url : $response_url" + aa_error "evaluation::twt::unsubscribe_GradeBook failed, bad response url : $response_url" } return $response @@ -1020,7 +1020,7 @@ set response 1 } } else { - aa_error "evaluation::twt::::unsubscribe_Evaluation failed, bad response url : $response_url" + aa_error "evaluation::twt::unsubscribe_Evaluation failed, bad response url : $response_url" } return $response @@ -1031,39 +1031,39 @@ set response 0 ::twt::do_request $class_material_url - + #Follow Control Panel link tclwebtest::link follow ~u {/dotlrn/classes(.+)/one-community-admin} - + tclwebtest::link follow {Administer Evaluation} tclwebtest::link follow {Admin my Assignment Types} set modify_assignment_type_url [tclwebtest::response url] tclwebtest::link follow {Add assignment type} - + tclwebtest::form find ~n "grade" - tclwebtest::field find ~n grade_name + tclwebtest::field find ~n grade_name tclwebtest::field fill $assigment_type_name tclwebtest::field find ~n grade_plural_name tclwebtest::field fill "$assigment_type_name" tclwebtest::field find ~n weight - tclwebtest::field fill 30 + tclwebtest::field fill 30 tclwebtest::form submit - + set response_url [tclwebtest::response url] if { [string match $modify_assignment_type_url $response_url] } { if {[catch {tclwebtest::assert text "$assigment_type_name" } errmsg]} { - + aa_error "evaluation::twt::add_assignment_type failed $errmsg : Didn't add a new assignment type" } else { aa_log "Add a new Assignment Type" set response 1 } } else { - aa_error "evaluation::twt::::add_assignment_type failed, bad response url : $response_url" + aa_error "evaluation::twt::add_assignment_type failed, bad response url : $response_url" } return $response