summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdownload.inc12
-rw-r--r--experiments_list.inc29
-rwxr-xr-xlab_details.inc8
-rwxr-xr-xlab_migration.module20
-rwxr-xr-xmanage_proposal.inc5
-rwxr-xr-xproposal.inc81
-rwxr-xr-xrun.inc151
-rwxr-xr-xsettings.inc36
-rwxr-xr-xupload_code.inc49
9 files changed, 222 insertions, 169 deletions
diff --git a/download.inc b/download.inc
index f16cf0f..821025b 100755
--- a/download.inc
+++ b/download.inc
@@ -18,6 +18,18 @@ function lab_migration_download_solution_file()
header('Content-Length: ' . filesize($root_path . $solution_file_data->directory_name . '/' . $solution_file_data->filepath));
readfile($root_path . $solution_file_data->directory_name . '/' . $solution_file_data->filepath);
}
+ function lab_migration_download_problem_statement()
+ {
+ $proposal_id = arg(3);
+ $root_path = lab_migration_path();
+ $proposal_q = db_query("SELECT lmp.* FROM lab_migration_proposal lmp WHERE lmp.id = :proposal_id LIMIT 1", array(':proposal_id' => $proposal_id));
+ $proposal_data = $proposal_q->fetchObject();
+ header('Content-Type: doc');
+ //header('Content-Type: application/octet-stram');
+ header('Content-disposition: attachment; filename="' . str_replace(' ', '_', ($proposal_data->problem_statement_file)) . '"');
+ header('Content-Length: ' . filesize($root_path . $proposal_data->directory_name . '/' . $proposal_data->problem_statement_file));
+ readfile($root_path . $proposal_data->directory_name . '/' . $proposal_data->problem_statement_file);
+ }
function lab_migration_download_dependency_file()
{
$dependency_file_id = arg(3);
diff --git a/experiments_list.inc b/experiments_list.inc
index df152ec..7d63fea 100644
--- a/experiments_list.inc
+++ b/experiments_list.inc
@@ -25,7 +25,7 @@ function lab_migration_experiments_list($form, &$form_state)
'#options' => _list_of_labs(),
'#default_value' => $selected,
'#ajax' => array(
- 'callback' => 'ajax_experiment_list_callback'
+ 'callback' => 'ajax_experiments_list_callback'
)
);
if (!$url_lab_id)
@@ -49,7 +49,7 @@ function lab_migration_experiments_list($form, &$form_state)
$form['lab_experiment_list'] = array(
'#type' => 'item',
'#title' => t('Title of the experiment'),
- '#options' => _ajax_get_experiments_list($selected),
+ '#markup' => _ajax_get_experiments_list($selected),
//'#default_value' => isset($form_state['values']['lab_experiment_list']) ? $form_state['values']['lab_experiment_list'] : '',s
'#prefix' => '<div id="ajax_selected_experiment">',
'#suffix' => '</div>',
@@ -88,11 +88,11 @@ function lab_migration_experiments_list($form, &$form_state)
$form['lab_experiment_list'] = array(
'#type' => 'item',
'#title' => t('Titile of the experiment'),
- '#options' => _ajax_get_experiments_list($selected),
- '#markup' => '<div id="ajax_selected_experiment">' . _ajax_get_experiments_list($lab_default_value) . '</div>',
- // '#default_value' => isset($form_state['values']['lab_experiment_list']) ? $form_state['values']['lab_experiment_list'] : '',
- /* '#prefix' => '<div id="ajax_selected_experiment">',
- '#suffix' => '</div>',*/
+ //'#options' => _ajax_get_experiments_list($selected),
+ '#markup' => _ajax_get_experiments_list($lab_default_value),
+ // '#default_value' => isset($form_state['values']['lab_experiment_list']) ? //$form_state['values']['lab_experiment_list'] : '',
+ '#prefix' => '<div id="ajax_selected_experiment">',
+ '#suffix' => '</div>',
'#states' => array(
'invisible' => array(
':input[name="lab"]' => array(
@@ -120,7 +120,7 @@ function lab_migration_experiments_list($form, &$form_state)
);*/
return $form;
}
-function ajax_experiment_list_callback($form, $form_state)
+function ajax_experiments_list_callback($form, $form_state)
{
$commands = array();
$lab_default_value = $form_state['values']['lab'];
@@ -146,17 +146,12 @@ function ajax_experiment_list_callback($form, $form_state)
$commands[] = ajax_command_html('#ajax_selected_lab_cfd', '');
}
$commands[] = ajax_command_html('#ajax_lab_details', _lab_details($lab_default_value));
- $form['lab_experiment_list']['#options'] = _ajax_get_experiments_list($lab_default_value);
+ $form['lab_experiment_list']['#markup'] = _ajax_get_experiments_list($lab_default_value);
$commands[] = ajax_command_replace('#ajax_selected_experiment', drupal_render($form['lab_experiment_list']));
- $commands[] = ajax_command_html('#ajax_selected_solution', '');
- $commands[] = ajax_command_html('#ajax_solution_files', '');
- $commands[] = ajax_command_html('#ajax_download_experiment_solution', '');
- $commands[] = ajax_command_html('#ajax_edit_experiment_solution', '');
- $commands[] = ajax_command_html('#ajax_download_experiments', '');
}
else
{
- $form['lab_experiment_list']['#options'] = _ajax_get_experiments_list();
+ $form['lab_experiment_list']['#markup'] = _ajax_get_experiments_list();
$commands[] = ajax_command_replace('#ajax_selected_experiment', drupal_render($form['lab_experiment_list']));
$commands[] = ajax_command_html('#ajax_lab_details', '');
$commands[] = ajax_command_html('#ajax_selected_lab', '');
@@ -371,16 +366,12 @@ function _ajax_get_experiments_list($lab_default_value = '')
$pending_solution_rows[] = array(
$lab_titles_data->lab_title,
$experiments_data->title,
- $lab_titles_data->name,
- $solution_provider_user_name,
l('View Solution', 'lab-migration/lab-migration-run/' . $lab_titles_data->id . '/' . $experiments_data->id)
);
}
$header = array(
'Title of the Lab',
'Experiment',
- 'Proposer',
- 'Solution Provider',
'Actions'
);
//$output = theme_table($header, $pending_solution_rows);
diff --git a/lab_details.inc b/lab_details.inc
index 16edc5e..bd270f7 100755
--- a/lab_details.inc
+++ b/lab_details.inc
@@ -20,10 +20,17 @@ function lab_migration_completed_labs_all()
while ($row = $result->fetchObject())
{
$approval_date = date("Y", $row->approval_date);
+ if($row->problem_statement_file == ''){
+ $problem_statement_file = "NA";
+ }
+ else{
+ $problem_statement_file = l('View', 'lab-migration/download/problem-statement/' . $row->id);
+ }
$preference_rows[] = array(
$i,
$row->university,
l($row->lab_title, "lab-migration/experiments-list/" . $row->id),
+ $problem_statement_file,
$approval_date
);
$i--;
@@ -32,6 +39,7 @@ function lab_migration_completed_labs_all()
'No',
'Institute',
'Lab',
+ 'Problem Statement',
'Year'
);
$output .= theme('table', array(
diff --git a/lab_migration.module b/lab_migration.module
index ef77bdc..68d849f 100755
--- a/lab_migration.module
+++ b/lab_migration.module
@@ -341,14 +341,16 @@ function lab_migration_menu()
'type' => MENU_CALLBACK,
'file' => 'download.inc'
);
- /*$items['lab_migration/download/dependency'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'lab_migration_download_dependency_file',
- 'access arguments' => array('lab migration download code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'download.inc',
- );*/
+ $items['lab-migration/download/problem-statement'] = array(
+ 'title' => 'Download Problem Statement',
+ 'description' => 'Download Problem Statement',
+ 'page callback' => 'lab_migration_download_problem_statement',
+ 'access arguments' => array(
+ 'lab migration download code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc'
+ );
$items['lab-migration/download/solution'] = array(
'title' => 'Code Download',
'description' => 'Code Download',
@@ -727,7 +729,7 @@ function lab_migration_ajax()
/*************************** VALIDATION FUNCTIONS *****************************/
function lab_migration_check_valid_filename($file_name)
{
- if (!preg_match('/^[0-9a-zA-Z\.]+$/', $file_name))
+ if (!preg_match('/^[0-9a-zA-Z_\.]+$/', $file_name))
return FALSE;
else if (substr_count($file_name, ".") > 1)
return FALSE;
diff --git a/manage_proposal.inc b/manage_proposal.inc
index 6df058c..411c24e 100755
--- a/manage_proposal.inc
+++ b/manage_proposal.inc
@@ -297,6 +297,11 @@ function lab_migration_proposal_approval_form($form, $form_state)
'#title' => t('Do you want to provide the solution'),
'#markup' => $solution_provider
);
+ $form['problem_statement_file'] = array(
+ '#type' => 'item',
+ '#title' => t('Problem statement file uploaded by the proposer'),
+ '#markup' => l('View', 'lab-migration/download/problem-statement/' . $proposal_data->id)
+ );
/* $form['solution_display'] = array(
'#type' => 'item',
'#title' => t('Do you want to display the solution on the www.dwsim.fossee.in website'),
diff --git a/proposal.inc b/proposal.inc
index 720d1a7..0bed1bf 100755
--- a/proposal.inc
+++ b/proposal.inc
@@ -232,12 +232,13 @@ function lab_migration_proposal_form($form, &$form_state)
$first_experiemnt = TRUE;
for ($counter = 1; $counter <= 15; $counter++)
{
- if ($counter <= 5)
+ if ($counter <= 1)
{
$form['lab_experiment-' . $counter] = array(
'#type' => 'textfield',
'#title' => t('Title of the Experiment ') . $counter,
'#size' => 50,
+ '#required' => TRUE
);
$namefield = "lab_experiment-" . $counter;
$form['lab_experiment_description-' . $counter] = array(
@@ -308,6 +309,19 @@ function lab_migration_proposal_form($form, &$form_state)
'#description' => 'If yes, solutions will be made available to everyone for downloading.',
'#disabled' => FALSE
);
+ $form['problem_statement'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Problem statement for the proposed lab<span style="color:red">*</span>'),
+ '#collapsible' => FALSE,
+ '#collapsed' => FALSE,
+ );
+ $form['problem_statement']['ps_file'] = array(
+ '#type' => 'file',
+ '#title' => t('<span style="color:red;font-weight:bold">NOTE: </span>Please upload a Problem Statement for each experiment proposed in a document format. To view the template of the document please click <a href="https://cfd.fossee.in/sites/default/files/Problem_Statement_Template.doc" target="_blank">here</a>'),
+ '#size' => 48,
+ '#description' => t('Only alphabets and numbers are allowed as a valid filename.') . '<br />' .
+ t('Allowed file extensions: ') . variable_get('lab_migration_problem_statement_extensions', ''),
+ );
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit')
@@ -387,10 +401,35 @@ function lab_migration_proposal_form_validate($form, &$form_state)
form_set_error('older', t('Please provide valid version'));
}
}
+ if (isset($_FILES['files']))
+ {
+ /* check if atleast one source or result file is uploaded */
+ if (!($_FILES['files']['name']['ps_file']))
+ form_set_error('ps_file', t('Please upload file with the problem statement.'));
+ /* check for valid filename extensions */
+ foreach ($_FILES['files']['name'] as $file_form_name => $file_name)
+ {
+ if ($file_name)
+ {
+ $allowed_extensions_str = variable_get('lab_migration_problem_statement_extensions', '');
+ $allowed_extensions = explode(',', $allowed_extensions_str);
+ $fnames = explode('.', strtolower($_FILES['files']['name'][$file_form_name]));
+ $temp_extension = end($fnames);
+ if (!in_array($temp_extension, $allowed_extensions))
+ form_set_error($file_form_name, t('Only file with ' . $allowed_extensions_str . ' extensions can be uploaded.'));
+ if ($_FILES['files']['size'][$file_form_name] <= 0)
+ form_set_error($file_form_name, t('File size cannot be zero.'));
+ /* check if valid file name */
+ if (!lab_migration_check_valid_filename($_FILES['files']['name'][$file_form_name]))
+ form_set_error($file_form_name, t('Invalid file name specified. Only alphabets and numbers are allowed as a valid filename.'));
+ } //$file_name
+ } //$_FILES['files']['name'] as $file_form_name => $file_name
+ }
return;
}
function lab_migration_proposal_form_submit($form, &$form_state)
{
+ $root_path = lab_migration_path();
global $user;
if (!$user->uid)
{
@@ -442,11 +481,11 @@ function lab_migration_proposal_form_submit($form, &$form_state)
$university = $v['university'];
$directory_name = _lm_dir_name($lab_title, $proposar_name, $university);
$result = "INSERT INTO {lab_migration_proposal}
- (uid, approver_uid, name_title, name, contact_ph, department, university, city, pincode, state, country, version, lab_title, approval_status, solution_status, solution_provider_uid, solution_display, creation_date, approval_date, solution_date, solution_provider_name_title, solution_provider_name, solution_provider_contact_ph, solution_provider_department, solution_provider_university, solution_provider_city, solution_provider_country, solution_provider_state, solution_provider_pincode, directory_name) VALUES
+ (uid, approver_uid, name_title, name, contact_ph, department, university, city, pincode, state, country, version, lab_title, approval_status, solution_status, solution_provider_uid, solution_display, creation_date, approval_date, solution_date, solution_provider_name_title, solution_provider_name, solution_provider_contact_ph, solution_provider_department, solution_provider_university, solution_provider_city, solution_provider_country, solution_provider_state, solution_provider_pincode, directory_name,problem_statement_file) VALUES
(:uid, :approver_uid, :name_title, :name, :contact_ph, :department, :university, :city, :pincode, :state, :country,
:version, :lab_title, :approval_status, :solution_status, :solution_provider_uid, :solution_display, :creation_date,
:approval_date, :solution_date, :solution_provider_name_title, :solution_provider_name,
- :solution_provider_contact_ph, :solution_provider_department, :solution_provider_university, :solution_provider_city, :solution_provider_country, :solution_provider_state, :solution_provider_pincode, :directory_name)";
+ :solution_provider_contact_ph, :solution_provider_department, :solution_provider_university, :solution_provider_city, :solution_provider_country, :solution_provider_state, :solution_provider_pincode, :directory_name, :problem_statement_file)";
$args = array(
":uid" => $user->uid,
":approver_uid" => 0,
@@ -477,11 +516,45 @@ function lab_migration_proposal_form_submit($form, &$form_state)
":solution_provider_country" => $solution_provider_country,
":solution_provider_state" => $solution_provider_state,
":solution_provider_pincode" => $solution_provider_pincode,
- ":directory_name" => $directory_name
+ ":directory_name" => $directory_name,
+ ":problem_statement_file" => ""
);
$proposal_id = db_query($result, $args, array(
'return' => Database::RETURN_INSERT_ID
));
+ $dest_path = $directory_name . '/';
+ if (!is_dir($root_path . $dest_path))
+ mkdir($root_path . $dest_path);
+ /* uploading files */
+ foreach ($_FILES['files']['name'] as $file_form_name => $file_name)
+ {
+ if ($file_name)
+ {
+ /* checking file type */
+ //$file_type = 'S';
+ if (file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]))
+ {
+ drupal_set_message(t("Error uploading file. File !filename already exists.", array('!filename' => $_FILES['files']['name'][$file_form_name])), 'error');
+ //unlink($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]);
+ } //file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name])
+ /* uploading file */
+ if (move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name]))
+ {
+ $query = "UPDATE lab_migration_proposal SET problem_statement_file = :problem_statement_file WHERE id = :id";
+ $args = array(
+ ":problem_statement_file" => $_FILES['files']['name'][$file_form_name],
+ ":id" => $proposal_id
+ );
+
+ $updateresult = db_query($query, $args);
+ drupal_set_message($file_name . ' uploaded successfully.', 'status');
+ } //move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name])
+ else
+ {
+ drupal_set_message('Error uploading file : ' . $dest_path . $file_name, 'error');
+ }
+ } //$file_name
+ }
if (!$proposal_id)
{
drupal_set_message(t('Error receiving your proposal. Please try again.'), 'error');
diff --git a/run.inc b/run.inc
index 713ceb8..833a34d 100755
--- a/run.inc
+++ b/run.inc
@@ -1,11 +1,12 @@
<?php
function lab_migration_run_form($form, &$form_state)
{
- $options_first = _list_of_labs();
+
$options_two = _ajax_get_experiment_list();
$select_two = isset($form_state['values']['lab_experiment_list']) ? $form_state['values']['lab_experiment_list'] : key($options_two);
$url_lab_id = (int) arg(2);
$url_experiment_id = (int) arg(3);
+ $options_first = _list_of_labs($url_lab_id);
if (!$url_lab_id)
{
$selected = isset($form_state['values']['lab']) ? $form_state['values']['lab'] : key($options_first);
@@ -34,12 +35,10 @@ function lab_migration_run_form($form, &$form_state)
$form['lab'] = array(
'#type' => 'select',
'#title' => t('Title of the lab'),
- '#options' => _list_of_labs(),
+ '#options' => _list_of_labs($selected),
'#default_value' => $selected,
- '#disabled' => TRUE,
-
);
- if (!$url_lab_id)
+ /*if (!$url_lab_id)
{
$form['selected_lab'] = array(
'#type' => 'item',
@@ -61,19 +60,12 @@ function lab_migration_run_form($form, &$form_state)
'#type' => 'select',
'#title' => t('Title of the experiment'),
'#options' => _ajax_get_experiment_list($selected),
- //'#default_value' => isset($form_state['values']['lab_experiment_list']) ? $form_state['values']['lab_experiment_list'] : '',
+ '#default_value' => isset($form_state['values']['lab_experiment_list']) ? $form_state['values']['lab_experiment_list'] : '',
'#ajax' => array(
'callback' => 'ajax_solution_list_callback'
),
'#prefix' => '<div id="ajax_selected_experiment">',
'#suffix' => '</div>',
- '#states' => array(
- 'invisible' => array(
- ':input[name="lab"]' => array(
- 'value' => 0
- )
- )
- )
);
$form['download_experiment'] = array(
'#type' => 'item',
@@ -90,13 +82,6 @@ function lab_migration_run_form($form, &$form_state)
),
'#prefix' => '<div id="ajax_selected_solution">',
'#suffix' => '</div>',
- '#states' => array(
- 'invisible' => array(
- ':input[name="lab"]' => array(
- 'value' => 0
- )
- )
- )
);
$form['download_solution'] = array(
'#type' => 'item',
@@ -120,31 +105,27 @@ function lab_migration_run_form($form, &$form_state)
);
}
else
- {
+ {*/
$lab_default_value = $url_lab_id;
- $form['selected_lab'] = array(
+ $experiment_default_value = $url_experiment_id;
+ /*$form['selected_lab'] = array(
'#type' => 'item',
'#markup' => '<div id="ajax_selected_lab">' . l('Download Lab Solutions', 'lab-migration/download/lab/' . $lab_default_value) . '</div>'
);
- /* $form['selected_lab_pdf'] = array(
- '#type' => 'item',
- '#markup' => '<div id="ajax_selected_lab_pdf">'. l('Download PDF of Lab Solutions', 'lab-migration/generate-lab/' . $lab_default_value . '/1') .'</div>',
-
- );*/
if ($lab_default_value == '2')
{
$form['selected_lab_dwsim'] = array(
'#type' => 'item',
'#markup' => '<div id="ajax_selected_lab_dwsim">' . l('Download Lab Solutions (dwsim Version)', 'lab-migration-uploads/dwsim_Version.zip') . '</div>'
);
- }
- $form['lab_details'] = array(
+ }*/
+ $form['selected_lab'] = array(
'#type' => 'item',
- '#markup' => '<div id="ajax_lab_details">' . _lab_details($lab_default_value) . '</div>'
+ '#markup' => '<div id="ajax_selected_lab">' . l('Download Lab Solutions', 'lab-migration/download/lab/' . $lab_default_value) . '</div>'
);
$form['lab_experiment_list'] = array(
'#type' => 'select',
- '#title' => t('Titile of the experiment'),
+ '#title' => t('Title of the experiment'),
'#options' => _ajax_get_experiment_list($selected),
'#default_value' => $selected_experiment,
'#ajax' => array(
@@ -152,35 +133,35 @@ function lab_migration_run_form($form, &$form_state)
),
'#prefix' => '<div id="ajax_selected_experiment">',
'#suffix' => '</div>',
- '#states' => array(
+ /*'#states' => array(
'invisible' => array(
':input[name="lab"]' => array(
'value' => 0
)
)
- )
+ )*/
);
$form['download_experiment'] = array(
'#type' => 'item',
- '#markup' => '<div id="ajax_download_experiments"></div>'
+ '#markup' => '<div id="ajax_download_experiments">' . l('Download Experiment', 'lab-migration/download/experiment/' . $selected_experiment) . '</div>'
);
$form['lab_solution_list'] = array(
'#type' => 'select',
'#title' => t('Solution'),
'#options' => _ajax_get_solution_list($selected_experiment),
- '#default_value' => isset($form_state['values']['lab_solution_list']) ? $form_state['values']['lab_solution_list'] : '',
+ //'#default_value' => isset($form_state['values']['lab_solution_list']) ? $form_state['values']['lab_solution_list'] : '',
'#ajax' => array(
'callback' => 'ajax_solution_files_callback'
),
'#prefix' => '<div id="ajax_selected_solution">',
'#suffix' => '</div>',
- '#states' => array(
+ /*'#states' => array(
'invisible' => array(
':input[name="lab_experiment_list"]' => array(
'value' => 0
)
)
- )
+ )*/
);
$form['download_solution'] = array(
'#type' => 'item',
@@ -202,54 +183,50 @@ function lab_migration_run_form($form, &$form_state)
)
)
);
- }
- /*
- $form['message'] = array(
- '#type' => 'textarea',
- '#title' => t('If Dis-Approved please specify reason for Dis-Approval'),
- '#prefix' => '<div id= "message_submit">',
- '#states' => array('invisible' => array(':input[name="lab"]' => array('value' => 0,),),),
-
- );
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit'),
- '#suffix' => '</div>',
- '#states' => array('invisible' => array(':input[name="lab"]' => array('value' => 0,),),),
-
- );*/
+ $form['lab_details'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_lab_details">' . _lab_details($lab_default_value) . '</div>'
+ );
+ $form['back_to_completed_labs'] = array(
+ '#type' => 'item',
+ '#markup' => l('Back to Completed Labs', 'lab-migration/completed-labs')
+ );
+ //}
return $form;
}
function ajax_experiment_list_callback($form, $form_state)
{
$commands = array();
$lab_default_value = $form_state['values']['lab'];
+ //var_dump($lab_default_value);die;
if ($lab_default_value != 0)
{
$form['lab_details']['#markup'] = _lab_details($lab_default_value);
$lab_details = _lab_information($lab_default_value);
$user_solution_provider = user_load($lab_details->solution_provider_uid);
//var_dump($lab_details->solution_provider_uid);
- if ($lab_details->solution_provider_uid > 0)
+ /*if ($lab_details->solution_provider_uid > 0)
{
$commands[] = ajax_command_html('#ajax_selected_lab', l('Download Lab Solutions', 'lab-migration/download/lab/' . $lab_default_value));
if ($lab_default_value == '2')
{
$commands[] = ajax_command_html('#ajax_selected_lab_dwsim', l('Download Lab Solutions (dwsim Version)', 'lab-migration_uploads/dwsim_Version.zip'));
}
- /* $commands[] = ajax_command_html('#ajax_selected_lab_pdf', l('Download PDF of Lab Solutions', 'lab-migration/generate-lab/' . $lab_default_value . '/1'));*/
+
}
else
{
$commands[] = ajax_command_html('#ajax_selected_lab', '');
$commands[] = ajax_command_html('#ajax_selected_lab_pdf', '');
$commands[] = ajax_command_html('#ajax_selected_lab_dwsim', '');
- }
+ }*/
$commands[] = ajax_command_html('#ajax_lab_details', _lab_details($lab_default_value));
$form['lab_experiment_list']['#options'] = _ajax_get_experiment_list($lab_default_value);
$commands[] = ajax_command_replace('#ajax_selected_experiment', drupal_render($form['lab_experiment_list']));
$commands[] = ajax_command_html('#ajax_selected_solution', '');
+ /*$form['lab_solution_list']['#options'] = _ajax_get_solution_list();
+ $commands[] = ajax_command_html('#ajax_selected_solution', drupal_render($form['lab_solution_list']));
+ *///$commands[] = ajax_command_replace('#ajax_selected_solution', drupal_render($form['lab_solution_list']));
$commands[] = ajax_command_html('#ajax_solution_files', '');
$commands[] = ajax_command_html('#ajax_download_experiment_solution', '');
$commands[] = ajax_command_html('#ajax_edit_experiment_solution', '');
@@ -259,14 +236,16 @@ function ajax_experiment_list_callback($form, $form_state)
{
$form['lab_experiment_list']['#options'] = _ajax_get_experiment_list();
$commands[] = ajax_command_replace('#ajax_selected_experiment', drupal_render($form['lab_experiment_list']));
+ /*$form['lab_solution_list']['#options'] = _ajax_get_solution_list();*/
$commands[] = ajax_command_html('#ajax_lab_details', '');
$commands[] = ajax_command_html('#ajax_selected_lab', '');
$commands[] = ajax_command_html('#ajax_selected_lab_dwsim', '');
$commands[] = ajax_command_html('#ajax_selected_lab_pdf', '');
- $commands[] = ajax_command_data('#ajax_selected_lab', 'form_state_value_select', $form_state['values']['lab']);
- $commands[] = ajax_command_html('#ajax_selected_experiment', '');
+ //$commands[] = ajax_command_data('#ajax_selected_lab', 'form_state_value_select', $form_state['values']['lab']);
+ //$commands[] = ajax_command_html('#ajax_selected_experiment', '');
$commands[] = ajax_command_html('#ajax_download_experiments', '');
$commands[] = ajax_command_html('#ajax_selected_solution', '');
+ //$commands[] = ajax_command_replace('#ajax_selected_solution', drupal_render($form['lab_solution_list']));
$commands[] = ajax_command_html('#ajax_solution_files', '');
$commands[] = ajax_command_html('#ajax_download_experiment_solution', '');
$commands[] = ajax_command_html('#ajax_edit_experiment_solution', '');
@@ -279,14 +258,17 @@ function ajax_experiment_list_callback($form, $form_state)
function ajax_solution_list_callback($form, $form_state)
{
$commands = array();
+ //$lab_default_value = $form_state['values']['lab'];
$experiment_list_default_value = $form_state['values']['lab_experiment_list'];
- //var_dump($lab_default_value);
+ //var_dump($lab_default_value . ' ' . $experiment_list_default_value);die;
if ($experiment_list_default_value != 0)
{
+ //var_dump($experiment_list_default_value);
$form['lab_solution_list']['#options'] = _ajax_get_solution_list($experiment_list_default_value);
+ $commands[] = ajax_command_replace('#ajax_selected_solution', drupal_render($form['lab_solution_list']));
$commands[] = ajax_command_html('#ajax_download_experiments', l('Download Experiment', 'lab-migration/download/experiment/' . $experiment_list_default_value));
- $commands[] = ajax_command_html('#ajax_selected_experiment', drupal_render($form['lab_experiment_list']));
- $commands[] = ajax_command_html('#ajax_selected_solution', drupal_render($form['lab_solution_list']));
+/* $commands[] = ajax_command_html('#ajax_selected_experiment', drupal_render($form['lab_experiment_list']));
+*/
// $commands[] = ajax_command_html('#ajax_solution_files', '');
// $commands[] = ajax_command_html('#ajax_download_experiment_solution', '');
// $commands[] = ajax_command_html('#ajax_edit_experiment_solution', '');
@@ -294,12 +276,12 @@ function ajax_solution_list_callback($form, $form_state)
else
{
$form['lab_solution_list']['#options'] = _ajax_get_solution_list();
- $commands[] = ajax_command_html('#ajax_selected_solution', drupal_render($form['lab_solution_list']));
- $commands[] = ajax_command_html('#ajax_download_experiments', '');
- $commands[] = ajax_command_html('#ajax_selected_solution', '');
+ $commands[] = ajax_command_html('#ajax_selected_solution', drupal_render($form['lab_solution_list']));
+ /* $commands[] = ajax_command_html('#ajax_download_experiments', '');
+ //$commands[] = ajax_command_html('#ajax_selected_solution', '');
$commands[] = ajax_command_html('#ajax_solution_files', '');
$commands[] = ajax_command_html('#ajax_download_experiment_solution', '');
- $commands[] = ajax_command_html('#ajax_edit_experiment_solution', '');
+ $commands[] = ajax_command_html('#ajax_edit_experiment_solution', '');*/
// $commands[] = ajax_command_replace('#ajax_selected_experiment',drupal_render($form['lab_experiment_list']));
}
return array(
@@ -316,7 +298,6 @@ function ajax_solution_files_callback($form, $form_state)
{
$commands[] = ajax_command_html('#ajax_selected_lab_experiment_solution_action', drupal_render($form['lab_experiment_solution_actions']));
/*************************************************************************************/
- //$solution_list_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $form_state['values']['solution']);
$query = db_select('lab_migration_solution_files');
$query->fields('lab_migration_solution_files');
$query->condition('solution_id', $solution_list_default_value);
@@ -421,17 +402,13 @@ function bootstrap_table_format($headers, $rows)
";
return $table;
}
-/*****************************************************/
-function _list_of_labs()
+ function _list_of_labs($selected)
{
- $lab_titles = array(
- '0' => 'Please select...'
- );
+ $lab_titles = array();
//$lab_titles_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE solution_display = 1 ORDER BY lab_title ASC");
$query = db_select('lab_migration_proposal');
$query->fields('lab_migration_proposal');
- $query->condition('solution_display', 1);
- $query->condition('approval_status', 3);
+ $query->condition('id',$selected);
$query->orderBy('lab_title', 'ASC');
$lab_titles_q = $query->execute();
while ($lab_titles_data = $lab_titles_q->fetchObject())
@@ -440,6 +417,17 @@ function _list_of_labs()
}
return $lab_titles;
}
+/*****************************************************/
+function _selected_lab_name($selected)
+ {
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('id', $selected);
+ $query->condition('approval_status', 3);
+ $lab_titles_q = $query->execute();
+ $lab_titles_data = $lab_titles_q->fetchObject();
+ return $lab_titles_data->lab_title;
+ }
function _ajax_get_experiment_list($lab_default_value = '')
{
$experiments = array(
@@ -462,16 +450,9 @@ function _ajax_get_solution_list($lab_experiment_list = '')
$solutions = array(
'0' => 'Please select...'
);
- // $solutions_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d ORDER BY
- // CAST(SUBSTRING_INDEX(code_number, '.', 1) AS BINARY) ASC,
- // CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(code_number , '.', 2), '.', -1) AS UNSIGNED) ASC,
- // CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(code_number , '.', -1), '.', 1) AS UNSIGNED) ASC", $experiment_id);
$query = db_select('lab_migration_solution');
$query->fields('lab_migration_solution');
$query->condition('experiment_id', $lab_experiment_list);
- //$query->orderBy("CAST(SUBSTRING_INDEX(code_number, '.', 1) AS BINARY", "ASC");
- // $query->orderBy("CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(code_number , '.', 2), '.', -1) AS UNSIGNED", "ASC");
- // $query->orderBy("CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(code_number , '.', -1), '.', 1) AS UNSIGNED", "ASC");
$solutions_q = $query->execute();
while ($solutions_data = $solutions_q->fetchObject())
{
@@ -509,22 +490,22 @@ function _lab_details($lab_default_value)
$user_solution_provider = user_load($lab_details->solution_provider_uid);
if ($user_solution_provider)
{
- $solution_provider = '<span style="color: rgb(128, 0, 0);"><strong>Solution Provider</strong></span></td><td style="width: 35%;"><br />' . '<ul>' . '<li><strong>Solution Provider Name:</strong> ' . $lab_details->solution_provider_name_title . ' ' . $lab_details->solution_provider_name . '</li>' . '<li><strong>Department:</strong> ' . $lab_details->solution_provider_department . '</li>' . '<li><strong>University:</strong> ' . $lab_details->solution_provider_university . '</li>' . '</ul>';
+ $solution_provider = '<span style="color: rgb(128, 0, 0);"><strong>Solution Provider</strong></span>' . '<ul>' . '<li><strong>Solution Provider Name:</strong> ' . $lab_details->solution_provider_name_title . ' ' . $lab_details->solution_provider_name . '</li>' . '<li><strong>Department:</strong> ' . $lab_details->solution_provider_department . '</li>' . '<li><strong>University:</strong> ' . $lab_details->solution_provider_university . '</li>' . '</ul>';
}
else
{
- $solution_provider = '<span style="color: rgb(128, 0, 0);"><strong>Solution Provider</strong></span></td><td style="width: 35%;"><br />' . '<ul>' . '<li><strong>Solution Provider: </strong> (Open) </li>' . '</ul>';
+ $solution_provider = '<span style="color: rgb(128, 0, 0);"><strong>Solution Provider</strong></span>' . '<ul>' . '<li><strong>Solution Provider: </strong> (Open) </li>' . '</ul>';
}
}
else
{
- $solution_provider = '<span style="color: rgb(128, 0, 0);"><strong>Solution Provider</strong></span></td><td style="width: 35%;"><br />' . '<ul>' . '<li><strong>Solution Provider: </strong> (Open) </li>' . '</ul>';
+ $solution_provider = '<span style="color: rgb(128, 0, 0);"><strong>Solution Provider</strong></span>' . '<ul>' . '<li><strong>Solution Provider: </strong> (Open) </li>' . '</ul>';
}}
else{
drupal_goto('lab-migration/lab-migration-run');
}
- $form['lab_details']['#markup'] = '<span style="color: rgb(128, 0, 0);"><strong>About the Lab</strong></span></td><td style="width: 35%;"><br />' . '<ul>' . '<li><strong>Proposer Name:</strong> ' . $lab_details->name_title . ' ' . $lab_details->name . '</li>' . '<li><strong>Title of the Lab:</strong> ' . $lab_details->lab_title . '</li>' . '<li><strong>Department:</strong> ' . $lab_details->department . '</li>' . '<li><strong>University:</strong> ' . $lab_details->university . '</li>' . '<li><strong>Category:</strong> ' . $lab_details->category . '</li>' . '</ul>' . $solution_provider;
+ $form['lab_details']['#markup'] = '<table><tr><td><span style="color: rgb(128, 0, 0);"><strong>About the Lab</strong></span>' . '<ul>' . '<li><strong>Proposer Name:</strong> ' . $lab_details->name_title . ' ' . $lab_details->name . '</li>' . '<li><strong>Title of the Lab:</strong> ' . $lab_details->lab_title . '</li>' . '<li><strong>Department:</strong> ' . $lab_details->department . '</li>' . '<li><strong>University:</strong> ' . $lab_details->university . '</li>' . '<li><strong>Category:</strong> ' . $lab_details->category . '</li>' . '</ul></td><td>' . $solution_provider . '</td></tr></table>';
$details = $form['lab_details']['#markup'];
return $details;
}
diff --git a/settings.inc b/settings.inc
index 1856a25..8af9fd3 100755
--- a/settings.inc
+++ b/settings.inc
@@ -29,6 +29,15 @@ function lab_migration_settings_form($form, $form_state)
'#required' => TRUE,
'#default_value' => variable_get('lab_migration_from_email', '')
);
+ $form['extensions']['proposal_problem_statement'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed extensions for the problem statement in the Proposal form'),
+ '#description' => t('A comma separated list WITHOUT SPACE of file extensions for the problem statement that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('lab_migration_problem_statement_extensions', '')
+ );
$form['extensions']['source'] = array(
'#type' => 'textfield',
'#title' => t('Allowed source file extensions'),
@@ -38,33 +47,24 @@ function lab_migration_settings_form($form, $form_state)
'#required' => TRUE,
'#default_value' => variable_get('lab_migration_source_extensions', '')
);
- $form['extensions']['dependency'] = array(
+ $form['extensions']['code_submission_result_pdf'] = array(
'#type' => 'textfield',
- '#title' => t('Allowed dependency file extensions'),
- '#description' => t('A comma separated list WITHOUT SPACE of dependency file extensions that are permitted to be uploaded on the server'),
+ '#title' => t('Allowed file extensions for results in the form of PDF'),
+ '#description' => t('A comma separated list WITHOUT SPACE of report file extensions that are permitted to be uploaded on the server'),
'#size' => 50,
'#maxlength' => 255,
'#required' => TRUE,
- '#default_value' => variable_get('lab_migration_dependency_extensions', '')
+ '#default_value' => variable_get('lab_migration_result_pdf_extensions', '')
);
- $form['extensions']['result'] = array(
+ $form['extensions']['result_zip'] = array(
'#type' => 'textfield',
- '#title' => t('Allowed result file extensions'),
+ '#title' => t('Allowed result file extensions in the zip format'),
'#description' => t('A comma separated list WITHOUT SPACE of result file extensions that are permitted to be uploaded on the server'),
'#size' => 50,
'#maxlength' => 255,
'#required' => TRUE,
'#default_value' => variable_get('lab_migration_result_extensions', '')
);
- $form['extensions']['xcos'] = array(
- '#type' => 'textfield',
- '#title' => t('Allowed xcos file extensions'),
- '#description' => t('A comma separated list WITHOUT SPACE of xcos file extensions that are permitted to be uploaded on the server'),
- '#size' => 50,
- '#maxlength' => 255,
- '#required' => TRUE,
- '#default_value' => variable_get('lab_migration_xcos_extensions', '')
- );
$form['extensions']['pdf'] = array(
'#type' => 'textfield',
'#title' => t('Allowed pdf file extensions'),
@@ -89,10 +89,10 @@ function lab_migration_settings_form_submit($form, &$form_state)
variable_set('lab_migration_emails', $form_state['values']['emails']);
variable_set('lab_migration_cc_emails', $form_state['values']['cc_emails']);
variable_set('lab_migration_from_email', $form_state['values']['from_email']);
+ variable_set('lab_migration_problem_statement_extensions', $form_state['values']['proposal_problem_statement']);
variable_set('lab_migration_source_extensions', $form_state['values']['source']);
- variable_set('lab_migration_dependency_extensions', $form_state['values']['dependency']);
- variable_set('lab_migration_result_extensions', $form_state['values']['result']);
- variable_set('lab_migration_xcos_extensions', $form_state['values']['xcos']);
+ variable_set('lab_migration_result_pdf_extensions', $form_state['values']['code_submission_result_pdf']);
+ variable_set('lab_migration_result_extensions', $form_state['values']['result_zip']);
variable_set('lab_migration_pdf_extensions', $form_state['values']['pdf']);
drupal_set_message(t('Settings updated'), 'status');
}
diff --git a/upload_code.inc b/upload_code.inc
index 7dca349..be59edc 100755
--- a/upload_code.inc
+++ b/upload_code.inc
@@ -219,7 +219,7 @@ function lab_migration_upload_code_form($form,$form_state)
);
$form['code_warning'] = array(
'#type' => 'item',
- '#title' => t('Upload all the dwsim project files in .zip format'),
+ '#title' => t('Upload all the OpenFOAM project files in .zip format'),
'#prefix' => '<div style="color:red">',
'#suffix' => '</div>',
);
@@ -234,7 +234,7 @@ function lab_migration_upload_code_form($form,$form_state)
'#title' => t('Upload main or source file'),
'#size' => 48,
'#description' => t('Only alphabets and numbers are allowed as a valid filename.') . '<br />' .
- t('Allowed file extensions : ') . variable_get('lab_migration_source_extensions', ''),
+ t('Allowed file extensions: ') . variable_get('lab_migration_source_extensions', ''),
);
/* $form['dep_files'] = array(
@@ -292,40 +292,18 @@ function lab_migration_upload_code_form($form,$form_state)
);
$form['result']['result1'] = array(
'#type' => 'file',
- '#title' => t('Upload result file'),
+ '#title' => t('Upload result file. To view the template for result submission please click <a href="https://cfd.fossee.in/sites/default/files/Template_For_Result.doc" target="_blank">here</a>.'),
'#size' => 48,
'#description' => t('Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' .
- t('Allowed file extensions : ') . variable_get('lab_migration_result_extensions', ''),
+ t('Allowed file extensions: ') . variable_get('lab_migration_result_pdf_extensions', ''),
);
$form['result']['result2'] = array(
'#type' => 'file',
'#title' => t('Upload result file'),
'#size' => 48,
'#description' => t('Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' .
- t('Allowed file extensions : ') . variable_get('lab_migration_result_extensions', ''),
- );
-/*
- $form['xcos'] = array(
- '#type' => 'fieldset',
- '#title' => t('XCOS Files'),
- '#collapsible' => FALSE,
- '#collapsed' => FALSE,
- );
- $form['xcos']['xcos1'] = array(
- '#type' => 'file',
- '#title' => t('Upload xcos file'),
- '#size' => 48,
- '#description' => t('Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' .
- t('Allowed file extensions : ') . variable_get('lab_migration_xcos_extensions', ''),
- );
- $form['xcos']['xcos2'] = array(
- '#type' => 'file',
- '#title' => t('Upload xcos file'),
- '#size' => 48,
- '#description' => t('Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' .
- t('Allowed file extensions : ') . variable_get('lab_migration_xcos_extensions', ''),
+ t('Allowed file extensions: ') . variable_get('lab_migration_result_extensions', ''),
);
-*/
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit')
@@ -357,7 +335,8 @@ function lab_migration_upload_code_form_validate($form, &$form_state)
/* check if atleast one source or result file is uploaded */
if ( ! ($_FILES['files']['name']['sourcefile1'] ))
form_set_error('sourcefile1', t('Please upload atleast one main or source file.'));
-
+if ( ! ($_FILES['files']['name']['result1'] ))
+ form_set_error('result1', t('Please upload the result file in the form of pdf.'));
/* check for valid filename extensions */
foreach ($_FILES['files']['name'] as $file_form_name => $file_name)
{
@@ -366,10 +345,10 @@ function lab_migration_upload_code_form_validate($form, &$form_state)
/* checking file type */
if (strstr($file_form_name, 'source'))
$file_type = 'S';
- else if (strstr($file_form_name, 'result'))
+ else if (strstr($file_form_name, 'result1'))
+ $file_type = 'P';
+ else if (strstr($file_form_name, 'result2'))
$file_type = 'R';
- else if (strstr($file_form_name, 'xcos'))
- $file_type = 'X';
else
$file_type = 'U';
@@ -382,8 +361,8 @@ function lab_migration_upload_code_form_validate($form, &$form_state)
case 'R':
$allowed_extensions_str = variable_get('lab_migration_result_extensions', '');
break;
- case 'X':
- $allowed_extensions_str = variable_get('lab_migration_xcos_extensions', '');
+ case 'P':
+ $allowed_extensions_str = variable_get('lab_migration_result_pdf_extensions', '');
break;
}
$allowed_extensions = explode(',' , $allowed_extensions_str);
@@ -562,17 +541,19 @@ function lab_migration_upload_code_form_submit($form, &$form_state) {
return;
}
+
/* uploading file */
if (move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name]))
{
/* for uploaded files making an entry in the database */
+ //var_dump($_FILES['files']['type'][$file_form_name]);die;
$query = "INSERT INTO {lab_migration_solution_files} (solution_id, filename, filepath, filemime, filesize, filetype, timestamp)
VALUES (:solution_id, :filename, :filepath, :filemime, :filesize, :filetype, :timestamp)";
$args = array(
":solution_id" => $solution_id,
":filename" => $_FILES['files']['name'][$file_form_name],
":filepath" => $file_path . $_FILES['files']['name'][$file_form_name],
- ":filemime" => 'application/zip',
+ ":filemime" => $_FILES['files']['type'][$file_form_name],
":filesize" => $_FILES['files']['size'][$file_form_name],
":filetype" => $file_type,
":timestamp" => time()