summaryrefslogtreecommitdiff
path: root/migrated_labs.inc
blob: 4e5dcdb5b9611189e08f0dd91fb07c290d5344cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
// $Id$

function migrated_labs()
{
  global $user;
  $dl_root_path = 'sites/default/files/lab_migration/';

  /* get pending proposals to be approved */
  $labs_rows = array();
  $labs_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE approval_status = 1 ORDER BY id DESC");
  while ($labs_data = db_fetch_object($labs_q)) {
  	/* file attachments */
  	$file_links = '';
  	$problem_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d AND filetype = 'P'", $labs_data->id);
  	$problem_data = db_fetch_object($problem_q);
  	$file_links .= '<br/>' . l('Problem Statement', $dl_root_path . $problem_data->filepath);
  	$sup_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d AND filetype = 'S'", $labs_data->id);
  	$sup_data = db_fetch_object($sup_q);
  	if ($sup_data)
  		$file_links .= '<br/>' . l('Suplementary Files', $dl_root_path . $sup_data->filepath);

  	$migration_status = '';
  	if ($labs_data->solution_status == 0) {
  		$migration_status = 'In Progress';
  	} else if ($labs_data->solution_status == 1) {
  		$migration_status = 'Migrated';
  		if (($user->uid == $labs_data->uid) || user_access('manage proposal')) {
				$sol_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d AND filetype = 'A'", $labs_data->id);
				$sol_data = db_fetch_object($sol_q);
  			$file_links .= '<br/>' . l('Solution File', $dl_root_path . $sol_data->filepath);
  		}
  	}

    $labs_rows[] = array($labs_data->university, $labs_data->lab_title, $labs_data->problem_topic . $file_links, l($labs_data->name_title . ' ' . $labs_data->name, 'user/' . $labs_data->uid) . '<br/>' . $labs_data->department, $migration_status);
  }

  /* check if there are any pending proposals */
  //if (!$labs_rows) {
  //  drupal_set_message(t('There are no lab migrations.'), 'status');
  //  return '';
  //}

  $output = "
<p>
	Labs Migration Project: Do you want to shift your labs from MATLAB&nbsp; to Scilab?<br />
	<br />
	Please get in touch with us at contact@scilab.in and we will help you.</p>
<p>
	Here are some previous labs that we have shifted from MATLAB to Scilab:</p>
<h4>
	Delhi University</h4>
<ol>
	<li>
		<a href='http://scilab.in/files/labs_migration/experiments/Delhi_University/DU-Signals.pdf'>Signals and Systems</a></li>
	<li>
		<a href='http://scilab.in/files/labs_migration/experiments/Delhi_University/DU-Numerical-Methods.pdf'>Numerical Methods</a></li>
</ol>
<h4>
	SASTRA University</h4>
<ol>
	<li>
		Signal Processing</li>
</ol>
<p>
	If you are a teacher <strong>and</strong> want access to the codes, please get in touch with us at contact@scilab.in from your official email ID.&nbsp;</p>
  ";

  $labs_header = array('University/Institute', 'Title of the Lab', 'Title of the Problem', 'Name of the Proposer and Department', 'Status');
  $output .= theme_table($labs_header, $labs_rows);
  return $output; 
}